Sign in to follow this  
MrJake

Dark GDK - 2D sidescroller jumping...

Recommended Posts

MrJake    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this