Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / need help please

Author
Message
AriEf
14
Years of Service
User Offline
Joined: 30th Nov 2009
Location: Indonesia
Posted: 12th Apr 2011 10:53 Edited at: 12th Apr 2011 10:55
i have a new game project called snake and ladder and this is my lastest code
[code#include "DarkGDK.h"

enum modes { _menu, _game, _loading };
modes g_mode = _menu;

void SetupGame (void);
void LoadLevel (int map);
void Jebakan (int turunke);
void Bantuan (int naikke);
void Menang (void);

int posplayer = 1;
int oldposplayer = posplayer;
int random = 1;

int iDelay = 0;

bool MouseOverSprite ( int spriteID )
{
if ( dbMouseX ( ) > dbSpriteX ( spriteID ) && dbMouseX ( ) < dbSpriteX ( spriteID ) + dbSpriteWidth ( spriteID ) &&
dbMouseY ( ) > dbSpriteY ( spriteID ) && dbMouseY ( ) < dbSpriteY ( spriteID ) + dbSpriteHeight ( spriteID ) )
return true;
else
return false;
}

void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
SetupGame ();

while ( LoopGDK ( ) )
{
switch (g_mode)
{
case _loading:
{
dbSprite (10,845,665,10);
dbSync();
dbSync();
g_mode = _game;
for (int a=1; a<15; a++)
{
if (dbSpriteExist (a) == 1)
{
dbDeleteSprite (a);
}
}

break;
}
case _menu:
{
dbSprite (1,0,0,1);
dbSprite (2,0,560,2);

dbCreateAnimatedSprite (3,"Tema/exit.png",1,2,3);
dbSprite (3,720,620,3);

dbCreateAnimatedSprite (4,"Tema/newgame.png",1,2,4);
dbSprite (4,240,620,4);

if (MouseOverSprite (4) == true && dbMouseClick () == 1)
{
dbPlaySound (100);
g_mode = _loading;
for (int i=2; i<10; i++)
{
if (dbSpriteExist (i) == 1)
{
dbDeleteSprite (i);
}
}
}
if (MouseOverSprite (3) == true && dbMouseClick () == 1)
{
dbPlaySound (100);
return;
}
break;
}
case _game:
{
LoadLevel (1);

//dbPrint (dbStr (posplayer));

oldposplayer = posplayer;

dbCreateAnimatedSprite (20,"Sprites/dadu.png",2,3,20);
dbSprite (20,900,100,20);

if (posplayer > 20)
{
posplayer = 20 - (oldposplayer - 20);
}

if (MouseOverSprite (20) == true && dbTimer () > iDelay && dbMouseClick () == 1)
{
iDelay = dbTimer () + 3000;
random = dbRnd (5)+1;
posplayer += random;
}

if (random == 1)
{
dbSetSpriteFrame (20,1);
}
if (random == 2)
{
dbSetSpriteFrame (20,2);
}
if (random == 3)
{
dbSetSpriteFrame (20,3);
}
if (random == 4)
{
dbSetSpriteFrame (20,4);
}
if (random == 5)
{
dbSetSpriteFrame (20,5);
}
if (random == 6)
{
dbSetSpriteFrame (20,6);
}
break;
}
}
dbSync ( );
}

return;
}

void LoadLevel (int map)
{
if (map == 1)
{
dbSprite (50,0,0,50);
if (posplayer == 1)
{
dbSprite (15,0,575,15);
}
if (posplayer == 2)
{
dbSprite (15,160,575,15);
}
if (posplayer == 3)
{
dbSprite (15,320,575,15);
Bantuan (7);
}
if (posplayer == 4)
{
dbSprite (15,480,575,15);
}
if (posplayer == 5)
{
dbSprite (15,640,575,15);
}
if (posplayer == 6)
{
dbSprite (15,640,385,15);
}
if (posplayer == 7)
{
dbSprite (15,480,385,15);
Jebakan (2);
}
if (posplayer == 8)
{
dbSprite (15,320,385,15);
}
if (posplayer == 9)
{
dbSprite (15,160,385,15);
Bantuan (16);
}
if (posplayer == 10)
{
dbSprite (15,0,385,15);
Bantuan (14);
}
if (posplayer == 11)
{
dbSprite (15,0,195,15);
}
if (posplayer == 12)
{
dbSprite (15,160,195,15);
Jebakan (8);
}
if (posplayer == 13)
{
dbSprite (15,320,195,15);
}
if (posplayer == 14)
{
dbSprite (15,480,195,15);
}
if (posplayer == 15)
{
dbSprite (15,640,195,15);
Jebakan (5);
}
if (posplayer == 16)
{
dbSprite (15,640,0,15);
}
if (posplayer == 17)
{
dbSprite (15,480,0,15);
Jebakan (1);
}
if (posplayer == 18)
{
dbSprite (15,320,0,15);
Jebakan (11);
}
if (posplayer == 19)
{
dbSprite (15,160,0,15);
}
if (posplayer == 20)
{
dbSprite (15,0,0,15);
Menang ();
}
}
}

void Jebakan (int turunke)
{
posplayer = turunke;
}
void Bantuan (int naikke)
{
posplayer = naikke;
}
void Menang (void)
{
g_mode = _menu;
posplayer = 1;
for (int a=15;a<100;a++)
{
if (dbSpriteExist (a) == 1)
{
dbDeleteSprite (a);
}
}
}

void SetupGame ( void )
{

dbSetDisplayMode (1024,768,32);
dbSetWindowPosition (0,0);
dbSetTextSize (24);
dbSetTextFont ("Calibri");
//dbDrawSpritesFirst ();
dbSetWindowOff ();
dbRandomize (dbTimer());

dbLoadImage ("Tema/menuscreen.png",1);
dbLoadImage ("Tema/bar.png",2);
dbLoadImage ("Tema/exit.png",3);
dbLoadImage ("Tema/newgame.png",4);

dbLoadImage ("Tema/loading.png",10);

dbLoadImage ("Sprites/player1.png",15);
dbLoadImage ("Sprites/dadu.png",20); // dice

dbLoadImage ("Peta/map1.png",50);

dbLoadSound ("Suara/btn.wav",100);
}

and the question is :
how to animated it so if the player is in 1 and going to 3 the player move forward slowly???

p.s sorry for bad english

Rank : Beginner Coder
Im Indonesian, and I cant speak english, i hope you understand
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 16th Apr 2011 04:09 Edited at: 16th Apr 2011 04:11
I would suggest using a for loop wherever you reposition the player.
Have the loop set from its current position to the new position with a dbSync() command before the end of every loop.

Also, name your post something related to your question, and put your code in
by pressing the code button twice and typing in between the to expressions generated.

Login to post a reply

Server time is: 2024-11-19 12:29:08
Your offset time is: 2024-11-19 12:29:08