i am writing a turn based dungeon crawler type game. the problem i am having is getting my sprite to move 25 pix in any given direction then stopping. My current code he just keeps moving. any help will be appreciated. i know that i probably should be using different classes for my hero and monster but i am just starting this programming thing and will get to that after i have the basics down.
here is my code
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
int PlayerX = 0;
int PlayerY = 0;
dbLoadImage ( "wholemap.png" , 3);
dbLoadImage ( "Hero.png" , 1 );
dbLoadImage ( "enemy.png" , 2);
dbSprite ( 3 , 0 , 0 , 3 );
dbSprite ( 1 , PlayerX , PlayerY , 1 );
dbSprite ( 2 , 0 , 100 , 2);
// our main loop
while ( LoopGDK ( ) )
{
if (dbRightKey ( ))
PlayerX += 25;
if (dbLeftKey ( ) )
PlayerX -= 25;
if (dbDownKey ( ) )
PlayerY += 25;
if (dbUpKey () )
PlayerY -= 25;
dbSprite ( 1 , PlayerX , PlayerY , 1 );
// update the screen
dbSync ( );
}
// return back to windows
return;
}
Pimpin aint eazy