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 / how to move sprites to the left or right

Author
Message
ecurbed
15
Years of Service
User Offline
Joined: 2nd Aug 2009
Location:
Posted: 3rd Aug 2009 03:47
Hello I am a beginner,

I know you can use dbMoveSprite(id, #); to move a sprite up or down,
but now what I would like to do is move the sprite left, or right, is there a command that does that? If not then how would I accomplish this?
Bran flakes91093
16
Years of Service
User Offline
Joined: 13th Sep 2008
Location: Crazy Land
Posted: 3rd Aug 2009 06:08
You could keep track of the position of a sprite (x, y) and use them with dbSprite().

Some pseudo-code!


Your_Health = (My_Mood == HAPPY) ? 100 : NULL;
ecurbed
15
Years of Service
User Offline
Joined: 2nd Aug 2009
Location:
Posted: 3rd Aug 2009 18:12
I tried but dbSprite(id, x,y, id) seems to not affect the movement of the sprite.

There isn't any function like: dbMoveSpriteLeft() or dbMoveSpriteRight() ?
Cole Xemi
16
Years of Service
User Offline
Joined: 20th Aug 2008
Location:
Posted: 3rd Aug 2009 19:20
dbSprite() works, try this:

puppyofkosh
17
Years of Service
User Offline
Joined: 9th Jan 2007
Location:
Posted: 3rd Aug 2009 19:23
Quote: "I tried but dbSprite(id, x,y, id) seems to not affect the movement of the sprite. "


Are sure you called it in the loop?
ecurbed
15
Years of Service
User Offline
Joined: 2nd Aug 2009
Location:
Posted: 3rd Aug 2009 21:07
Thanks Guys it worked out perfectly! I appreciate the help from everyone!
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 4th Aug 2009 14:55
If you need you sprite to strafe (move sideways relative to the way you are facing), you can rotate it 90, use the dbMove command then rotate it back straight away.
helpfull programmer
15
Years of Service
User Offline
Joined: 30th Jul 2009
Location:
Posted: 5th Aug 2009 23:42
like matty halewood said,

you could do this,

::left::

dbRotateSprite(ID number,90);
dbMoveSprite(ID number, -(number) );
dbRotateSprite(ID number,0);

::right::

dbRotateSprite(ID number,90);
dbMoveSprite(ID number, (number) );
dbRotateSprite(ID number,0);

Login to post a reply

Server time is: 2024-10-01 10:33:37
Your offset time is: 2024-10-01 10:33:37