DEV Community

Aryan Rawlani
Aryan Rawlani

Posted on • Edited on

Rain - A 2D Game, My experience, learning, and following along a tutorial series for GameDev!

My Project: Rain - A 2D Game


Intro

Ever since I was little, gaming has always been providing a very exciting and happy experience for me. I was drawn into computer science because of gaming and the thought of creating such experiences for people felt something like what I wanted to do. I live in India, where the GameDev scene is not too big and no local university (within my reach) had such a program, wherein I could learn more about it.

After a very good and thorough gaining of foundations of CS and making several small projects of my own, I thought to myself - I want to get started with the GameDev scene, I've always been interested in it but never worked on it before - so let's get started with learning something completely new!

Onwards, I started searching online for some courses or tutorials to see what I could learn. Even though Unity and Unreal is a pretty big deal for someone who wants to learn GameDev, I wanted somewhat of a simpler and more programming-focused kind of introduction. I should also mention, in 8th grade or so - I had a pretty fantastic experience with Unity where I created an entire map (Mountains, rains, ponds, a basic player, waterfalls, rocks, stones) and it was very big! (It was by no means a masterpiece, but it was very nice to see in my eyes, back then) I may have misplaced my original files so I can't show some screenshots but I had a lot of fun then, so I felt like I was going to get back on track now.

I feel like Game Programming, was something I could get into very easily. After searching a good amount of time, I came upon TheCherno's some older videos, which were titled Game Programming - using Java.

Heck yes, I thought! I had been watching Cherno's videos for a while now (he has an amazing series of C++ tutorial series too!) so I felt quite comfortable with the Author. The only issue was the programming language used in the project - which was Java. I'm not a huge fan of Java because of many issues, but it isn't a bad language. The readability is very similar (and quite simpler) compared to C++ and I had a great working knowledge of it before from some of my previous simpler projects, so I decided to stick with it.

The project description, my working steps:

Before I describe the project, please be noted that this is NOT a fully functional game with a story or anything like that. Quite simply put, this project was done to gain a better understanding (for me) on how game programming works and how some of the older games were built.

I first started with how the videos will be structured and while my original intention was to just watch the videos after I watched some of the ending videos (around 100 or so) I thought how cool would it be if I could make something like this?

So, let's dive in!

Rain is very much based on how "Realm of the Mad God" looked and worked like, so that was the inspiration behind this project. All you can do in rain is walk around, see how different types of enemies are structured, create custom sprite sheets and make new maps, make shooting loose health and make something like an insane difficulty game and so much more!

I first started with a very general game loop and setup multithreading. Every game refreshes every "tick" to update the graphics and a basic event system was made up to capture small events. This went something like press up arrow, and something happens.

After that, I set up sprite sheets and individual sprites from the theme. I also created a custom map, which was SO simple! It went something like this:
1) Open paint.net (which is surprisingly good)
2) Setup the resolution and set up a grid
3) Based on your existing sprites, place similar kinds of colors on the grid.
For example, if I had brown color sitting on an individual grid, in code - I would replace it with the "Rock" sprite.

It was that simple!

After that, I worked on adding some NPCs (or Mobs, if that's how you prefer to call them :D) and giving them the ability to do random things. i.e: move around, stop for a random time, etc. Kind of like the NPCs in Skyrim!

At this point, I had a pretty good basic framework for a game. Protagonist, NPCs, maps, movements, etc. It was time to add some projectiles and collision detections! The latter I had a lot of trouble understanding at first, but I eventually understood what was going on.

However, the most exciting thing I got working a while later when I was working on NPC AI. The point was basically to calculate a path to my current position (which updates every second or so, because I can keep moving) and move NPC according to it. (A* Search algorithm). It was really fun to see this happen :D

Lastly, I touched on some topics like Multiplayer and GUI - but to be honest - these weren't my big spots or the things I was most interested in. But, I thought - being a part of game dev means that you should have a basic understanding of how everything works - from GUI to programming, to 3D graphics drawing to multiplayer. So, I stuck with it and learned some new things.


Demo Link & Link to Code:

Rain - A 2D Game on GitHub
Since the project is pure Java-based, all you'd need to do is clone the repo, open an IDE (for messing around with the game according to your constraints) and just build, it's that easy :D


Additional Thoughts / Feelings / Stories

So, yeah! If you were to point out that this wasn't much of a "project", I'd kinda agree with you. My other projects - some were good, some rather easy & simple, some challenging, but this was the one I had the most fun with because of how well it aligned with my interests. So, this is the one I picked! I completed this a few months back.

About Java: I was really surprised at the collection of java libraries there are. I didn't expect Java to be this huge, and the Graphics libraries were relatively simple to use.

It was very fun to see the result! Even though not a fully functional game, it taught me so many things in Game Programming, that I know will be useful sometime soon ;)

Soon, when I'm done with some of my current projects, I plan to begin learning and programming in Unity or Unreal to make fully functional games. I have a great idea that I cannot wait to bring to life, so I cannot wait!

Thanks for reading :D

Top comments (0)