Welcome to Dream.In.Code
Become an Expert!

Join 149,615 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,857 people online right now. Registration is fast and FREE... Join Now!




SDL C++ Turning sprites

 
Reply to this topicStart new topic

SDL C++ Turning sprites, Turning a corner with 2D sprites

Trake
28 Aug, 2007 - 07:39 AM
Post #1

D.I.C Head
**

Joined: 29 Jun, 2007
Posts: 61


My Contributions
Hi all,

I'm currently trying to write a simple 2D car racing game in C++ using SDL. But I can't think how to turn a corner with a sprite realistically, ie not just suddenly turning left after x seconds of holding the key down.

The two solutions that I have thought of are, firstly, to animate the sprite, but I'm not great with graphics, and I wouldn't be sure how to make it look real still. The second idea I have had is, if its possible, to take the angle at which the sprite is moving in relation to the direction of the road and increase that angle based on time the direction key is pressed. I know I haven't provided any code, but if you could just show me the right direction i would be grateful.

Thanks in advance.

Trake
User is offlineProfile CardPM
+Quote Post

Trogdor
RE: SDL C++ Turning Sprites
30 Aug, 2007 - 07:11 AM
Post #2

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 549



Thanked: 4 times
Dream Kudos: 125
My Contributions
The second method sounds to me the most programaticaly and thus will save you work on the graphics making side.
It will have to involve some transformation trickery though, and i am not sure this is provided by SDL. If it is, then that is what you should use smile.gif
Perhaps there are rotation functions, or perhaps you can 'project' your sprite onto a new one. Not sure what the terminology is, neither what SDL exactly offers.
If you find out, let us (me) know !
User is offlineProfile CardPM
+Quote Post

Tomas
RE: SDL C++ Turning Sprites
30 Aug, 2007 - 11:45 AM
Post #3

New D.I.C Head
Group Icon

Joined: 12 Jun, 2007
Posts: 34


Dream Kudos: 100
My Contributions
Try visiting this site:

http://www.lazyfoo.net

they have great tutorials to download and may be able to help you ph34r.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 12:31AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month