Jump to content

Top-down 2D racing game mechanics

Alvaro Cavaclanti

Recommended Posts

Hey Guys,


My goal is to create a top-down 2d racing game (if the title didn't give it away). I've done a bit of Googling for examples of this mechanic, but haven't found any (yet). On the other hand I've found a lot of "spaceship" mechanics and have been tinkering with it, but couldn't get where I wanted.


My intention is to have a minimalist racing mechanic, acceleration/velocity, braking and drag. Oh, and steering. That's the problem, actually.


I have used both "velocity/accelerationFromRotation" and modifying the acceleration with Math.cos/sin on rotation.


I feel like the issue may be related to reducing the velocity/acceleration while steering (turning left/right), but that didn't work quite well, also.


Finally, I'm not asking for dumb copy/paste code per se (but as this may be very basic, I would not dismiss it), instead I would like to know more about the theory, and then try to code it myself.


p.s.: If everything goes well I'll write a tutorial and share it. :)

Link to comment
Share on other sites

I've been working on a p2.js game based on this great tutorial: http://www.iforce2d.net/b2dtut/top-down-car it walks you through an approach to steering by applying directional forces to your cars wheels. (Hopefully I will actually find time to finish the damn game one day...)


Nice, Alex! I'll go through it and see what I can make use. I wasn't thinking on using such elaborated physics (separated tires) but that will certainly help.


If anybody has more tips, don't be shy. :)

Link to comment
Share on other sites

Hey! Bingo! This might help, funnily enough I was looking at how to shoot a cannon ball in physics and found this:




He ( Rishab ) has a great website - well explained and examples you can run right there on the page.


Well - fancy this! He uses a nice race car physics example on the above page!


he also has a solution for a scrolling background ....   http://codetheory.in/moving-scrolling-sliding-background-in-html5-canvas/


I'll be watching this site. It's fantastic. (you could always use a simple image rotation for tyres and bind it to key codes).


Good luck - I'll go back and see if I can get a cannon ball to arc



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...