Jump to content
  • Advertisement
Sign in to follow this  
MrJake

Dark GDK - 2D sidescroller jumping...

This topic is 2975 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on this jump function for a few days now and just can't seem to figure it out. I can get the sprite to move up, but not back down. Anyone have any suggestions? Here's the code: (space key is used for jump) #include "DarkGDK.h" void DarkGDK(void) { dbSyncOn ( ); dbSyncRate ( 60 ); dbDisableEscapeKey (); dbSetImageColorKey (255,0,255); dbLoadImage("temptitle.bmp", 11); dbSprite(11,0,0,11); dbLoadImage("Idle_r90.bmp", 1); dbLoadImage("Run_r90.bmp", 2); dbLoadImage("Idle_r90_flip.bmp", 3); dbLoadImage("Run_r90_flip.bmp", 4); dbLoadImage("Crouch.bmp",5); dbLoadImage("Crouch_flip.bmp",6); dbLoadImage("Jump.bmp",7); int IWidth = 2; int IHeight = 4; int Idle = 1; int Frames = 7; int Crouch = 5; dbCreateAnimatedSprite(1, "Idle_r90.bmp", IWidth, IHeight, 1); dbSprite(1, 100, 300, 1); while (LoopGDK ()) { //dbLoadMusic("wiz-penguin_adventure-forest.mp3", 10); //dbPlayMusic(10); dbRotateSprite(1,90); dbPlaySprite(1,1,Frames,60); if (dbRightKey()) { Idle = 1; Crouch = 5; dbStretchSprite(1, 100, 100); dbSprite(1, (dbSpriteX(1)), 300, Idle); dbSetSpriteImage(1,2); Frames = 8; dbMoveSprite(1,3); } else if (dbLeftKey()) { Idle = 3; Crouch = 6; dbStretchSprite(1, 100, 100); dbSprite(1, (dbSpriteX(1)), 300, Idle); dbSetSpriteImage(1,4); Frames = 8; dbMoveSprite(1, -3); } else if (dbDownKey()) { dbSetSpriteImage(1,Crouch); Frames = 8; dbSprite(1, (dbSpriteX(1)), 310, Crouch); dbStretchSprite(1, 87, 100); } else if (dbSpaceKey()) { int MaxVal = 200; int Direction = 3; dbSetSpriteImage(1,7); Frames = 3; dbRotateSprite(1,0); dbStretchSprite(1, 87, 120); dbSetSpriteFrame(1, 2); if (dbSpriteY(1) == 200) { MaxVal = 100; Direction = (-3); } if (dbSpriteY(1) > MaxVal) dbMoveSprite(1,Direction); } else { dbStretchSprite(1, 100, 100); dbSprite(1, (dbSpriteX(1)), 300, Idle); dbSetSpriteImage(1,Idle); Frames = 7; } if (dbEscapeKey()) break; dbSync(); } return; }

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!