aka "so, you want to write a game, do you?"
© 2008 PeeJay
© 2008 PeeJay
Warning: Undefined array key "keywords_en" in /mnt/web218/a3/28/510129628/htdocs/main.php on line 234 Warning: Undefined array key "description_en" in /mnt/web218/a3/28/510129628/htdocs/main.php on line 235 Warning: Undefined array key "commercials" in /mnt/web218/a3/28/510129628/htdocs/main.php on line 261
GLOBAL planim=0With 16 frames of animation in each direction, that means that this figure will want to be between 0 and 15 inclusive. There's a change in the updateplayer function:
IF dirx<>0 OR diry<>0 planim=planim+1 IF planim>15 THEN planim=0 ENDIFHere's a new idea - IF ..... ENDIF. This quite simply let's GL do a number of things if a certain decision is true. So, we are saying that if we are trying to move in the x direction or the y direction then do the following:- add 1 to the animation counter check the counter - if it is over 15, then set it back to 0 Easy huh? But why are we checking dirx and diry? Well, if the player hasn't moved, we don't want the walking animation to continue, now do we? So, the only other change is in the drawthescreen function, namely DRAWANIM 0,16*pldir+planim,px,py If you look at the imagestrip again, you'll see that images 0 to 15 are all for the player moving in pldir=0, and so on. So, this little bit of maths will set the image pointer to the proper place, taking into account both the direction the player is facing, and the animation counter. Go on, run it. Is it starting to look any good yet? I'll bet you're now feeling that programming in GL isn't so bad after all!