Sunday, February 26, 2017

Blog 2 - It's ALIIIIIVE!!!

Alright, first things first. I know you all want to see progress, so here it is!
To move the character (the blue dot), use the WASD keys. To create a zombie (a green dot), click on any part of the black screen. The embedded web version is a little fiddle. Sometimes you need to click on it a few times before it will register your key presses. If it doesn't work for you, or you would rather experience the full desktop experience (because blogger cuts off the screen a bit), click on this link and download the file to play!

You can also check out my code at this link!

Now,onto the progress report...
Starting out, I thought, "wow moving a blue dot and a green dot towards it won't be that hard!" Well, I was mistaken...

Surprisingly, my biggest challenges were BEFORE programming actually began. You see, our IT department doesn't appreciate this thing called "freedom." I wanted to be able to work on my project at school and at home, but our tech department blocks everything, so I could not run my code on our school laptops. I learned that libGDX, the game library I am using, runs off something called Gradle.


Lessons learned by Ryan: GRADLE
Gradle is known as a "dependency-management system." It basically provides an organized way to download libraries that you need in your code off the internet. libGDX is packaged using Gradle, meaning that there is a Gradle file that tells the computer where to download libGDX and how to install it


Since Gradle needs internet access to download libGDX for coding, it is blocked by the school's firewall. I worked around this in two ways. First, I got a big flashdrive to store all my programming files on. I discovered that if I install everything on my flashdrive at my home computer, I could run it and program on my school computer. Second, I used GitHub to sync code between my school computer and my home PC. To do so, I needed to learn command line Git, a version control programming language. Luckily, I found a really helpful website to walk me through the process.


Now that that's out of the way, I could actually start programming, right? Wrong.

You see, I got this book called Learning libGDX Game Development to help teach me the basics of game development. Turns out, the first step to game development is planning! Whoopdee doo. It is important to make a framework from the beginning so you don't have to waste time fixing things unnecessarily in the future. So, the first day I spent trying to code ended up as a planning day for organizing my project. The result was the following diagram of classes and functions to organize the code of the game.

Now, finally, coding began. Learning libGDX itself wasn't very bad this week. Most of the commands are pretty simple. For example, to draw in image on a screen, you just write "SpriteBatch.draw(Texture, xCoord, yCoord)." The difficulties were in structuring the code, and thinking of the math behind it. When making the basic game above, I discovered how necessary encapsulation is.







Lessons learned by Ryan: ENCAPSULATION
Encapsulation is the idea of separating independent aspects of you code into different files. You only let different files, or classes, interact through a specific set of public functions. This way, you can edit one part of your code (the private data) without ruining the functionality of another separate code because the external code only interacts through the public method


As shown in my brainstorming diagram, I encapsulated my WorldController (which dealt with logic), my WorldRenderer (which drew the pretty pictures), and my Zombies into different classes. This really came in handy when I had to modify my Zombie code. I changed the zombie from storing its coordinates as two integers (x and y) to a point object. Yet, because it was encapsulated, my WorldRenderer still functioned perfectly due to the changes being hidden within the Zombie class.

Finally, programming that simple game above required me to learn new math! Hurray! Everything in a video game lies on a coordinate plan. I had to figure out some way to move a coordinate point in a certain direction by a certain amount. Turns out, the best way to do that is with Vectors! (Anyone in Pre-Calc, this is apparently part of our second semester curriculum. Hopefully this is helpful!)


Lessons learned by Ryan: VECTORS
Vectors are a mathematical device used to describe something moving a certain amount in a certain direction. In mathematical terms, these are a vector's magnitude (length) and direction. This is really useful because you can add and subtract vectors just like normal numbers. The link below helps explain vectors pretty easily.


This was really useful for me because libGDX has a Vector2 class to help do vector math! To make zombies move towards the player, I could just create two vectors representing the player and a zombie, then subtract them to get the path a zombie needs to follow to get to the player!

Well, that's the progress report for this week! Next week, I'm hoping to implement bullets and shooting to finish off my "basic mechanics" goal. To that end, I'm going to need your help! If you have any ideas for weapons I should add into the game (i.e. a slow firing sniper, a fast but inaccurate SMG, etc.), please let me know in the comments below! After making these weapons, I'm also going to need people to playtest for balancing. Hopefully I haven't bored you to death, so check in next time for Blog #3.

Tuesday, February 14, 2017

The Beginnings of a Great Adventure

For the six-week long Genius Project, I have decided to pursuit my passion in programming, specifically video game programming. There has always been something about programming that draws me in and intrigues me. If I had to define it, I would say that I have fallen in love with the analytical nature of coding. Everything you program has an algorithm. Tasks we normally think are simple, like walking from point A to point B, can only be implemented through well thought-out, logical commands. I love the challenge of approaching the problem logically and breaking it down into simple repeatable steps for a computer to execute.
At this point, you may be wondering why I chose video game programming as opposed to, let’s say, artificial intelligence or “useful” programs. Well, it’s partially because I just enjoy video games. I’ve spent way too much time gaming on my computer, and I need to put that time to use somehow. But besides, I like the idea of making a tangible, physical product. It is a great feeling to play a video game and know that you built that game from the ground up using your own code. I have never been good at building things with my own hands, but programming video games is an opportunity to create something on my own that doesn’t suck.
So, to the specifics of the Genius Project. Over the course of the next six weeks, I want to learn a Java-based game development library called libGDX. By the end of the six weeks, I want to create a fully functional video game. Specifically, I want to create a 2D zombie survival game where the player controls an armed character that has to fight off waves of zombies. The game must have all the components of a full game, including a playable character that can shoot and kill zombies, a shop/progression system to unlock new weapons, and “good” graphics like pixel art and animation. To track my progress, I will use the following timeline.

By the end of week 2, I wish to have the basic engine completed. This includes player and zombie movement, bullet movement, and being able to shoot and kill zombies.
By the end of week 4, I will have the shop/progression system created. This includes creating various weapons for the player to use and being able to switch between windows such as the shop window and the game window.
By the end of week 6, I want to learn how to implement animation so the movement of characters and the firing of weapons is dynamic.

These basic guidelines are my goals for the project. However, part of the game development process is making an experience fun for the user. To that end, I believe playtesting will reveal areas of my game that I want to implement or fix that I did not think of to begin with. So, be prepared for awesome features that weren’t even included in goals!
To make it easy for everyone to track my progress, I hope to embed weekly updates of my game to this blog. That way, you guys can play every iteration of my game and actually see how it improves. The code itself will also be controlled through my GitHub, so my entire process will be tracked online. Feel free to check it out, and I’ll post again next week!