drawing something longer than one frame?

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
lloganm
Posts: 87
Joined: August 10th, 2012, 11:26 pm

drawing something longer than one frame?

Post by lloganm » December 5th, 2012, 5:50 pm

Basically all I want is when kbd.buttonispressed, drawsomething() will only be drawn for, lets say 60 frames, no matter how long you hold down the button, only 60 frames. I've tried the keyPressedLastFrame method but then it only draws it for one frame. So, anybody have any idea how to do this?

Paradox
Posts: 22
Joined: July 14th, 2012, 4:11 pm

Re: drawing something longer than one frame?

Post by Paradox » December 6th, 2012, 1:10 am

Use an if statement.

Code: Select all

drawSomething()
{
if(kbd.spaceIsPressed)
{
      //draw stuff
      frames++;
}
}

Code: Select all

composeFrame()
{
      if(frames <= 60)
     {
           drawSomething();
     }
}

User avatar
LuX
Posts: 1492
Joined: April 22nd, 2012, 12:33 pm
Location: Finland

Re: drawing something longer than one frame?

Post by LuX » December 7th, 2012, 4:11 pm

You would need a boolean and integer for that.

Once you press a button the boolean will become true and the integer 0. Then as an independant function, if the boolean is true, draw something and add one to the integer. Once the integer becomes 60 the boolean will be false again.
ʕ •ᴥ•ʔ

Post Reply