SFML community forums

Help => General => Topic started by: Canvas on September 23, 2012, 01:55:15 am

Title: Top Down car movement help
Post by: Canvas on September 23, 2012, 01:55:15 am
Hey guys

I have a new question for you all, I'm trying to make a car that faces a direction, when the user holds W it will increase the speed, if S is held it will slow down the car, if A or D is held the car will turn in the right direction, so for example
Car is facing North (0 degrees)
Car speed is 4.
player holds D
carDirection += 5

so if the player is holding W and holding D the car will increase and start turning right, but will keep going round in circles and circles.

How can I implement this with SFML and C++???

Cheers
Title: Re: Top Down car movement help
Post by: eXpl0it3r on September 23, 2012, 07:53:11 am
So you're asking how to program a game? ???
We can help you with that, but explaining how everything works is not really our task. There are many open source games for which you can look at the code and learn how to do things, then there are many, many books about game programming. Google will also reveal quite a lot of information.

As for SFML you can look at the official tutorials, the wiki section and the documentation to understand what you can do and how.
Title: Re: Top Down car movement help
Post by: Jove on September 23, 2012, 10:50:56 am
This might be useful:

http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement (http://asgamer.com/2009/as3-character-movement-asteroids-style-360-degree-movement)

The code is simple to understand so easy to change to C++.
Title: Re: Top Down car movement help
Post by: Canvas on September 23, 2012, 11:36:54 am
eXpl0it3r
I know how to code some basic stuff, all I wanted to know how to get around an asteroid type movement, which Jove have posted, so cheers Jove :)
Title: Re: Top Down car movement help
Post by: eXpl0it3r on September 23, 2012, 11:57:08 am
Movement is basic stuff and doesn't have that much to do directly with programming, but it's rather a logical part.
If you had Googled a bit on your own, I bet you would've found some sources in no time. ;)