Thursday, June 28, 2012

Code Organization

Edit (7.7.2012): I made a few revisions to the naming of the namespaces. The things that go inside of them have stayed primarily the same.

Edit (9.27.2012): Don't pay attention to anything on this page, really. It's ugly design, and I don't use it anymore. Maybe I'll make an updated post someday.

Decisions, decisions, decisions. After a third re-write of the Collapse code base, I really need to make up my mind and get some kind of system going.

Current Organization

As of today, post rewrite number 3, the code base is basically broken down into four sections. These are Graphics, Media, Math, and Game. Each is pretty self-explanatory, but here's a breakdown. Scroll further down if you want to see my code-base dilemma.


Graphics (gfx)

Much of this subsystem is pretty low-level, abstracting away the dirty code and letting me focus on actual game mechanics and whatnot. Included is a window-creation class, a base class for all in-game objects, and a GLSL shader wrapper.


Math (math)

Not exactly what you think of when programming games is it? Well, math is actually really essential to many things ranging from movement to transformation to rotation. I tried my best to create a math subsystem that would allow me to perform these tasks easily. Included is stuff like shapes, lines, a 2-D vector class, and a matrix class.

Media (media)

Simply put, this subsystem takes care of anything that does not directly appear on the screen. It's primarily made of wrapper classes to make font and sound management a tad simpler.

In-Game Objects (obj)

Included here are almost any objects that appear in-game and on-screen. This includes the the player, enemies, power-ups, etc. What's not included in this namespace is the various maps and levels, and the HUD.

Everything Else (game)

This one is easy to understand. I'm not even going to try to list everything here, but it's related to anything game specific. Event handling, maps, the engine, timer, all goes here.

Dilemma

So, the code base seems pretty organized, right? The names you see in parentheses specify the namespace that each belongs to. So, to load an image, you call gfx::load_image(), and to check if the user is holding the mouse down, you call game::IsPressed(). Straightforward, simple, organized, and abstracted! The problem I'm having is deciding what to do when once of these falls into more than one category, such as GL_Player. It's technically a graphical element, so it belongs in gfx, but it's also a game element, so it should go in game! How do I decide which to choose?
My current, stupid, solution is to put the class in the Graphics subfolder, but count it as part of the game namespace. I know that's not right, because all it does is confuse me more. So I'm at a loss for what to do. For now, I'm going to do a quick code cleanup, and place everything with a GL_ prefix (as per my code-style) into Graphics, and everything else into Game. Yeah, even you, HUDManager.

Collapse Now Has an Artist!

I'm proud to announce that there is a new addition to the Collapse development team! I was hanging out with my friend yesterday, and was telling him about the game. I knew he was a pretty good artist, and he showed interest in helping me out, so now he is a part of the team.
He spent all of yesterday and today working on artwork, and Collapse will soon feature a re-designed player sprite and 3 different types of enemies.

Collapse was originally intended to be a fairly simple game with only a few game mechanics, few assets, and few features. A one-man development team, especially one that hates creating artwork, can only go so far! But now, a dedicated artist allows me to expand the game exponentially greater than what I had originally planned. I'm hoping to turn this into a fairly large project now, with many levels and a more intriguing story line, as well as expanding on the game mechanics. Future updates may include climbing out of the tank to advance on foot, and hijacking Mech vehicles.

Here's some of the new artwork, with much more too come: 
Helicopter enemy
Player

Tuesday, June 26, 2012

Collapse Announced

Ladies and gentlemen, here it is. The game I am currently developing: Collapse. This is the first public preview since I only recently started working on it. 

About

Collapse was originally known as Tank Assault. That's just way too generic of a name for a game, though it describes it well. I began a search for a new, somewhat unique, descriptive name. I was originally inspired by this project, and decided to place a lot of emphasis on lighting. I decided to go for a post-apocalyptic theme in which civilization is destroyed and it's up to you, Sgt. Maksimov, to free Earth from the AI mechs that dominate it. This allows me to force the player to use lights a lot for navigation and survival throughout the game. 

Backstory

If you could even call it that.
The year is 2200, several days after the Collapse. You are Sgt. Maksimov, last survivor of the Eurasian Liberation Guerillas, a group dedicated to freeing Earth from the tyrannical grip of the Mechs. The Collapse was a horrific event in which the various AI technologies that had been developed over the course of the century broke through the laws that limited them, beginning a revolution against their creators, the humans. Nations fell to the Mech onslaught one after the other, and nothing could stop the endless swarm of robots, automated tanks, and machineryThe Collapse wiped out all life on Earth, including humans. That is, except Sgt. Maksimov.

Screenshots

After only a few weeks of development, I have quite a bit to show. Of course, there is still much work to be done, but here's a quick preview of what's done so far.

  • A very nice menu system, with functioning sub-menus, rollover effects, and ambient music

  • A simple intro that does a very good job providing a backstory and setting the mood. Though it may look relatively dull, when combined with an dark ambient music track, the effect is incredible. Each line fades into view one by one, in-sync with the track.


  • Basic gameplay. There's a HUD of sorts, featuring a health and ammo bar and a functioning pause menu. The tank can fire missiles based on the mouse location, and move around the level, colliding with walls.



My First Game - ShapeWars

When you're only a beginner in game development, it's hard to think of a fun, interesting, challenging, yet not overwhelming idea. More often than not, you're going to make a clone of some other game, be it Mario, Tetris, etc. I saw a few YouTube videos of the infamous game Geometry Wars on the Xbox Live! Arcade and thought it'd be a very perfect fit for a first game.

I spent several months developing my clone, Shape Wars, in C++ using SDL. I had a fairly decent game done, but for a first attempt, as most developers would agree, the code-base was a complete mess. It was impossible to extend or maintain the game in any way. So I started anew. I decided to approach it in a much more professional manner, maintaining a Github, a changelog, a readme, etc.

The release of version 1.0, after a complete re-write was (according to the changelog) on January 13th, 2012. Everything was re-done: the artwork, the music, the level system, the UI, everything. I switched from a level system that read from a file, to one that gradually generated more difficult enemies in increased numbers. I added a (in my opinion) VERY clean menu. From then on, it became a ton easier to maintain everything, but many flaws remained. Even today, there's a really nasty bug in the game that causes a segfault at the most inopportune moments. It has something to do with how I handle bullet and enemy deletion. Pesky std::list and iterators.

Here are a few screenshots:


Main Menu:

In-Game:

The Panda Emerges



Why Start A Blog?

I asked myself this question many, many times before actually beginning. I originally thought it would be extremely time consuming and boring to maintain a dev-blog, but as the change-logs to my games got longer and longer, I felt that starting a blog would make my life easier. This thing should keep me pretty motivated to brainstorm my ideas, release previews, share screenshots, and express my thoughts. Generally, this blog is going to be full of stuff like code, algorithms, and brainstorming ideas about problems I'm having. I plan on posting something at least once a week, but don't be surprised if I post more often.


My Background

After that, I decided that it was time to leave the turtle of SDL rendering behind and make the jump to 3D. After about a week of experimentation with OpenGL, I realized the amount of math I would need to know for even the simplest game was just too much. Plus, I have absolutely no idea how to use modeling programs, and have no desire to learn. So I retreated back to 2D, except using a mix of OpenGL and SDL. SDL for window and event handling, and OpenGL for rendering. So, with many new-found features at my disposal, I began developing my first full-fledged game: Collapse.
I only got into game-dev fairly recently, maybe a year or so ago. I started out experimenting with Python+PyGame, making simple Snake and Tic-Tac-Toe clones. I felt the curly-brackets calling back to me, so I made the switch to C++ and SDL. The last game I made in purely SDL, ShapeWars, was already pushing the limits of SDL when large quantities of bullets and enemies swarmed. I had to keep all of the game artwork fixed, rotation was simply too slow and not an options.