W
W
wolf-98302014-07-22 18:36:44
C++ / C#
wolf-9830, 2014-07-22 18:36:44

How to implement a 2D machine?

Hello! How can I implement car control (top view) in C++ using SDL or SFML (because they are similar)?
I need to make the machine move in the direction with the UP key, and the LEFT and RIGHT keys change the direction, but how can I implement this programmatically?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav, 2014-07-22
@Nirail

Use movement direction vector:
UP - moves the "car" a certain distance along the vector.
LEFT/RIGHT - rotate the direction vector by a certain angle.
The specific implementation is at your own discretion (working with a vector in an elementary form is easily implemented even with standard C ++ tools, using SDL to implement control is easy to find on the Internet).

L
lookid, 2014-07-22
@lookid

www.iforce2d.net/b2dtut/top-down-car
It couldn't be easier.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question