A First Look at LibGDX

Since the only language I knew was Java, I’ve decided to stick with Java and chose to use the LibGDX library. The only coding experience I’ve had was the AP Computer Science A course which taught me the very basics of Java, and some messing around with Graphics and Swing. Here is my proudest achievement to date, just a simple Conway’s Game of Life 🙂

Of course, I have also tried to use Graphics to make a simple platformer which resulted in an awkward mess of blocks, messy code, and a big failure. I knew that to produce a playable game, a solution like LibGDX was the answer.

Upon first glance, the setup for LibGDX took forever. Transitioning from Eclipse to IntelliJ CE along with setting up LibGDX resulted in hours of troubleshooting and fiddling around to learn the controls of everything. But after some time, I finally got the library setup, and was time to make my first project:

Instead of going in blind, I started off with some easy resources to get an idea of how the library worked. A great guide I used: http://tann.space/HelloLibgdx/ (Shoutout to tann on discord, really helped me a lot) took me step by step, exploring the boundaries of what I could do. I quickly learned the format of create(), render(), dispose() and wrote a very simple paddle game following the guide.

Nonetheless, I still had tons of questions and no answers. Over the next two weeks, I worked on various topics like Box2D, Sprites, Tiled Map, Cameras, and more. At first, I used the book Learning LibGDX Game Development by Andreas Oehike and Suryakumar Nair but figured out quickly that the book was outdated. Although it had a great step by step tutorial, it was mostly just plain code to be copied, there was minimal explanation. From that book, I learned about using Pixmaps, Properties of the Orthographic Camera, and how to set up a project. The game used a main ApplicationAdapter class with a worldController class, worldRenderer class, Assets Manager class, CameraHelper class, and many more individual classes for different objects. The assets were loaded from images and the game used a small 128 x 32 drawing with each pixel representing an object as a basis for the level layout.

Even though it was a good start, the process was more complicated than it should, as each object even the background had to be drawn manually. Some useful features that the game taught me were manipulating the camera to zoom, toggle follow, and move. The frustration from creating the level map made me stumble upon a much better tool: Tiled. Surprisingly, the LibGDX documentation was enough for me to understand how to load the Tiled map and that version of loading a level layout came with much success.

The next resource I used was ForeignGuyMike’s youtube series on Box2D called Block Bunny. I wanted to way to do collision detection and handling and decided on checking out Box2D as a more realistic approach. At this time, I wanted to make something top-down so even though it seemed like an overkill to use Box2D, I could apply the same knowledge I learn from it to other types of contexts. The way that ForeignGuyMike set his game up was also different from the way Learning LibGDX Game Development had done it. He used a Game class as the main and had Game States and a GameState Manager class. ForeignGuyMike’s explanation of Box2D was very thorough, and just three videos in, I had a decent understanding of creating bodies and fixtures along with other gimmicks like friction, bounce, applying velocities on dynamic bodies, and filtering. Here's something I made from concepts from the video:

Originally published at http://noviceprogramming667661022.wordpress.com on July 6, 2018.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store