locked
FPS Flicker (not flickr the photo) shapes. how to fix it. RRS feed

  • Question

  • is there a way to make this program run faster without the flickering.

           display()  

    answerchoice = TextWindow.ReadNumber()

    if answerchoice = 3 then
          player_health = player_level_health  
          While player_magic_energy < player_magic_energy_limit or player_magic_energy = player_magic_energy_limit
            timeneeded = (player_magic_energy_limit - player_magic_energy)*10
            player_magic_energy = player_magic_energy + 5
            Program.Delay(timeneeded)
            display()

           endwhile

    endif

    sub display

      Shapes.Remove(playerhealth)
      Shapes.Remove(playermagic)
      Shapes.Remove(health)
      Shapes.Remove(energy)
      Shapes.Remove(expbar)
      Shapes.Remove(expt)
      GraphicsWindow.BrushColor = "Green"
      hide = Shapes.AddRectangle(100, 30)

      playerhealth = Shapes.AddRectangle((player_health/player_level_health) * 100, 30)
      Shapes.HideShape(playerhealth)
      Shapes.Move(playerhealth,500, 0)
      health = Shapes.AddText("Health = " + player_health + "/" + player_level_health)
      Shapes.HideShape(health)
      Shapes.Move(health, 400, 0)
      GraphicsWindow.BrushColor = "Blue"
      playermagic= Shapes.AddRectangle((player_magic_energy/player_magic_energy_limit)*100, 30)
      Shapes.HideShape(playermagic)
      Shapes.Move(playermagic,500,30)
      energy = Shapes.AddText("Magic = " + player_magic_energy + "/" + player_magic_energy_limit)
      Shapes.HideShape(energy)
      Shapes.Move(energy, 400, 30)
      expbar = Shapes.AddRectangle((player_exp/player_exp_level)*100, 10)
      Shapes.HideShape(expbar)
      Shapes.Move(expbar, 500, 60)
      expt = Shapes.AddText("exp = " + player_exp + "/" + player_exp_level)
      Shapes.HideShape(expt)
      Shapes.Move(expt, 400,  60)

      Shapes.ShowShape(playerhealth)
      Shapes.ShowShape(playermagic)
      Shapes.ShowShape(health)
      Shapes.ShowShape(energy)
      Shapes.ShowShape(expbar)
      Shapes.ShowShape(expt)

    endsub

    Wednesday, September 2, 2015 3:38 PM

Answers

  • I can't run your program - it looks like part of a larger program.

    However you Remove, Add , Hide, Move and Show a lot of shapes (lots of flicker).  Unless you actually change the shape you just need to create them once, say in a subroutine called initialise(),then just move them in the display() subroutine that is called each update.

    Text can be changes in a Shape with Shapes.SetText without flicker.

    To change the size of a shape try Shapes.Zoom.  You can change the X and Y stretch independently with this without flicker.

    You can also Hide and Show shapes and images without Removing and Adding them (the Remove and Add is the main cause of the flicker) - just create all the shapes you will need once at the start and Show or Hide them as required.
    Wednesday, September 2, 2015 6:08 PM