Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKarsten_

Posted 24 December 2012 - 09:21 AM

Just remember that you dont need to (and probably shouldnt) draw the player etc... at the same time you update it's frame.

The following pseudo code might make some sense.


class Player
{
  int currentFrame;
 
  void update()
  {
    // set the frame in here
    currentFrame++;
  }
 
  void draw()
  {
    if(currentFrame == 0)
    {
      // draw this picture
    }
    else if(currentFrame == 1)
    {
      // draw this other picture
    }
    // etc...
  }
}

So in your game, the update function of all your ingame entities should be called during the timer tick etc...
Then in the draw function, you should call draw() on all your ingame entities.

This then separates logic (the increasing of the animation frame etc...) with the drawing (The drawing of the correct picture depending on the frame).

#2Karsten_

Posted 24 December 2012 - 09:21 AM

Just remember that you dont need to (and probably shouldnt) draw the player etc... at the same time you update it's frame.

The following pseudo code might make some sense.

class Player{  int currentFrame;   void update()  {    // set the frame in here    currentFrame++;  }   void draw()  {    if(currentFrame == 0)    {	  // draw this picture    }    else if(currentFrame == 1)    {	  // draw this other picture    }    // etc...  }}
So in your game, the update function of all your ingame entities should be called during the timer tick etc...
Then in the draw function, you should call draw() on all your ingame entities.

This then separates logic (the increasing of the animation frame etc...) with the drawing (The drawing of the correct picture depending on the frame).

#1Karsten_

Posted 24 December 2012 - 09:20 AM

Just remember that you dont need to (and probably shouldnt) draw the player etc... at the same time you update it's frame.

 

The following pseudo code might make some sence.

 

 
class Player
{
  int currentFrame;
 
  void update()
  {
    // set the frame in here
    currentFrame++;
  }
 
  void draw()
  {
    if(currentFrame == 0)
    {
      // draw this picture
    }
    else if(currentFrame == 1)
    {
      // draw this other picture
    }
    // etc...
  }
}
 

 

So in your game, the update function of all your ingame entities should be called during the timer tick etc...

Then in the draw function, you should call draw() on all your ingame entities.

 

This then separates logic (the increasing of the animation frame etc...) with the drawing (The drawing of the correct picture depending on the frame).


PARTNERS