Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Top Down car movement help  (Read 3608 times)

0 Members and 1 Guest are viewing this topic.

Canvas

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Top Down car movement help
« 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Top Down car movement help
« Reply #1 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
Re: Top Down car movement help
« Reply #2 on: September 23, 2012, 10:50:56 am »
This might be useful:

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

The code is simple to understand so easy to change to C++.
{much better code}

Canvas

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Top Down car movement help
« Reply #3 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 :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Top Down car movement help
« Reply #4 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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything