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.

Newcomers DBPro Corner / [DBP] Sprite moving help.

Author
Message
Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 1st Mar 2009 02:58
Okay, I'm making a top-down 2d game. It has a car. I used rotate sprite with move sprite to make the car move, and it worked like a charm. But then I wanted the "camera" to follow the car, so I used the same thing but substituting the car for the background (i.e. making background move to give the illusion of a camera). I used the exact same code, just replacing the sprite number with the background number when reffering to movement. I did it, but if you turn the car left and want to then go forward by pressing up, for example, the car looks like it's strafing right. How can i make the way the car moves always relevant to the direction of the car?
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 1st Mar 2009 21:42
If the only thing you changed in your code was the sprite number, that would be the problem. You need to also reverse all the movement - for example, if you press the upkey, you want the sprite to move backwards.

Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 2nd Mar 2009 04:22
Yeah, but that would make so when I facing another direction it would be messed up. I honestly don't think there's a way to solve this besides putting the sprite on a 3d plane and using a camera. Question: How would I do collisions for a sprite on a 3d background?
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 2nd Mar 2009 04:25
Ah, I think I get it now. I can see how one might do this, but 3D has always been a better option - DarkBASIC's 2d sprite system is always said to be pretty slow compared to its 3D commands. I'd try that and see how it goes, it will be much easier.

Login to post a reply

Server time is: 2024-11-25 10:43:52
Your offset time is: 2024-11-25 10:43:52