Quantcast
Channel: Level 1 Gamer » Level 1 Gamer
Viewing all articles
Browse latest Browse all 10

Top-Down Car using libGDX and Box2D

0
0


Click in the box and Control the car using the arrow keys.
(For some reason in Chrome, the down arrow key will scroll the page. So, if you want to play the game in Chrome, go to this link: Game)

I’m working on a top down car game using libGDX, the Desktop/Android/HTML5 Java game development framework. I am new to all this, so the idea of creating a car with the correct physics from scratch seemed daunting. Rather than reinventing the wheel (or car in this case), I set out to to find someone who had done something similar and use that as a foundation.

Lo and behold, I found exactly what I was looking for here: Top Down Car Example using Gamejs and Box2D. This demonstration was created by Domas Lapinskas using Gamejs (a JavaScript game dev library) and Box2D (a popular 2D physics engine for games). Based on this earlier example, the car was built for a cool racing game called Bandit Racer. The source code for the whole game is open and available under MIT license, so check it out.

Domas created a nifty little car that will work perfectly for my game and he has simple, well commented code describing how to do it. I only needed to convert it to libGDX. His example uses Box2D. libGDX has its own implementation of Box2D built in which made the conversion pretty easy. Since Domas and team were so kind to release the code for BanditRacer and this Top-Down Car, I felt I should share the code for this conversion.

I have included a link to a zip file of the code. I’ve kept it pretty simple and have just included the four java files. You can just plop the four java files into a new libGDX project. If anyone is interested, I can put the complete libGDX Eclipse projects online somewhere, so that you can just import them into Eclipse and you’d be up and running. I just haven’t gone to the trouble to do that.

I hope you can make use of this code in your own project. Enjoy!

Here is the code >> TopDownCar-Code


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images