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 / My first attempt

Author
Message
James Nunez
15
Years of Service
User Offline
Joined: 25th Apr 2009
Location:
Posted: 25th Apr 2009 23:50
I have never made anything before and I need help on getting objects to move.

So far I have:

#include "DarkGDK.h"
void DarkGDK ( void )
{
int i = 0;
dbSyncOn ( );
dbSyncRate ( 60 );
dbLoadImage ( "a.bmp", 1 );
dbSprite ( 1, 250+i, 420, 1 );
while ( LoopGDK ( ) )
{
if ( dbRightKey ( ) )
{i+=100;
dbSync ( );
}
if ( dbLeftKey ( ) )
{i-=100;
dbSync ( );
}
dbSync ( );
}
return;
}

My problem is that when I press the left and right keys, the a.bmp does not move on my screen.

James Nunez
BiggAdd
Retired Moderator
20
Years of Service
User Offline
Joined: 6th Aug 2004
Location: != null
Posted: 26th Apr 2009 01:04
Moved this to the DarkGDK Board.

AlexI
19
Years of Service
User Offline
Joined: 31st Dec 2004
Location: UK
Posted: 26th Apr 2009 01:26 Edited at: 26th Apr 2009 01:27
Fixed below


ABXG
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Canada
Posted: 26th Apr 2009 02:12
That is because you have not written any lines of code related to moving the sprite. When you paste the image it doesn't remember the command as "250 + i", it just pastes the image at what ever location 250 + i happens to be the first time you call, in this case at position 250.

You may want to try something like this:




Also, you may want to consider organizing your code a bit better (although it is completely up to how you want to do organize your code), it will make it easier to follow.

One more thing, try to keep the use of dbSync(); to a minimum, calling more often than it needs to can make a game feel choppy, in my experience.

------------------------------------
Currently 900+ lines of code into an "over-the-shoulder" action RPG with combat based on rag-doll physics.

Login to post a reply

Server time is: 2024-11-25 13:33:56
Your offset time is: 2024-11-25 13:33:56