Game in a Weekend – Day 3.5 (Packaging)

So when I said I’d have an extra day to work on it, I lied. I didn’t end up having that much free time today so most of what I did was just packaging it so it was a functional game. You can download the playable version right here:



(or check out the code here:

Here’s what the final game looks like (in all its glory):


I’ve made these 9 levels but it’s very easy to make your own with instructions in the included text file.


Reflection on C++

I’ve now played around with C++ enough to have an idea of what the language is about, and I’ve decided a few things about it:

1. C++ is not for the faint of heart. It’s very frustrating to do things that are relatively easy in other programming languages, and is a lot less forgiving in many areas.

2. The windows console is not the best engine to make a game from (duh)

3. The fact that C++ is so particular means that it’s difficult to do something quickly and simply (e.g. throw it all together and it works), but if time is taken to plan things out in a way that works, then the code will be very well optimized and run smoothly.

4. C++ having so much control is the main reason that it is favoured for game development nowadays, and I’m only starting to scratch the surface of what C++ can do. I’m excited to work on my next project with C++, mostly because I won’t have to deal with the windows console buffer anymore!

Game in a Weekend – Day 3

notsuspicious.exe.rar.virus.jpg.pdf.ext <– Runnable game

Goods news: apparently tomorrow is Victoria day (stat holiday), meaning this “game in a weekend” is actually “game in a long weekend”. I’ve got most of the game set up so I’ll be able to spend tomorrow ironing out bugs and adding content to the game. My game is currently in a playable state, to the point where it’s actually kind of difficult (try it yourself above – I swear it’s not a virus, I’ve just zipped the .exe and the two necessary .dll files). Here’s what the game currently looks like:
Day 3 830w" sizes="(max-width: 830px) 100vw, 830px" />
Pretty cool, aye?
Originally I was planning on having the game as more of an adventure scroller, where you collect coins and powerups as you progress, but now I’m considering making it more of a puzzler – you get given a certain number of shots and shields, and you then have to complete the level. I’d still like to implement a powerup system, though, so I’ll have to think about how those two things can tie together (maybe they can’t).
I accomplished most of my goals for the day, mostly getting the graphics to look pretty (isn’t it pretty??). Tomorrow the one added functionality I’d like is to be able to load levels from text files that contain not only the level, but things like your number of shields and bolts, as well as saving progress to another text file. I don’t really care if it’s editable, the point is to playthrough, not to just win.
How I’m feeling about C++
To be completely honest, I’m still kind of mucking around. I understand how to code the basic things in C++ but I’m definitely not optimising it properly. For example, when an Entity dies, instead of deleting it from memory, my code simply “shuts it off”, leaving it in the array of Entities. This is definitely not ideal, but the alternative would have been more complex than I wanted it to be so I’ve left it how it is for now. Being able to control memory with C++ is definitely making me notice where I’m using it and what I’m using it on. I’m getting the impression that most games pass around a lot of pointers in functions and very rarely do actual objects change hands.
As always, the game’s code is here:

Game in a Weekend – Day 2

Current level

I’ve made significant progress today. I’ve learned (kind of) how to use pointers properly and effectively, in the sense that some of the things I did could not be done without them. I’ve also run into some of the odd things about C++, for instance that you can’t return an array from a function.



Continuing where I left off yesterday, I ended up modifying the way that my graphics code worked for performance reasons. As you might remember, I was drawing each layer individuallyon to the screen. The windows console is not optimised for being able to do this, so by the time I had a functioning game I quickly realised that running at 5fps was simply not an option and that I was going to have to change the function that was taking the most time to do: drawing all the layers.


To solve this problem, I ended up creating a function called compress_layers(). This function takes all of the layers and puts them into one layer (in order) BEFORE the console actually prints them out. This way, every frame is only one write to the console, and all of the layer processing is done behind the scenes. This improved the performance remarkably, but still not to the level that I needed.


My next problem was a bit more difficult to be okay with changing (and I’m still not happy with it). My drawLayer() function was working very well up to this point, and it worked by running through every character in the layer and writing it individually to the console (in it’s designated position). This allowed me the freedom to color each character as I wanted to, which was great and gave the game a lot more character. Here’s what my *current code* looks like with the *old* drawLayer() function:

Old drawLayer()

Pretty, right? Unfortunately going through each character was killing my framerate, so I was forced to write each line individually, meaning I can’t choose the individual colours. I’m still looking for a workaround for this, and I stumbled across which might be able to help me with that, but for now I’m unfortunately left with having a single printed colour :(.


Game Loop

Today, I also implemented a very basic game loop that runs physics 20 times per second, but lets the computer refresh the monitor as fast as it can. This isn’t ideal because it means my computer is working way harder than it needs to, but it’s functional which is enough for now.



Today I actually added physics to the game. An entity can either be flagged to be effected by physics or not. If it isn’t, then the physics function simply moves the object accordingly, but if it is it will also try to affect the Entity with gravity (making it fall). In the image above, “m” (a bat) is not affected by gravity, so it simply flies left and right on the screen, whereas the player (“p”) is affected by gravity, and therefore falls.

Input Handling

The player can now move left, right, jump, and shoot a projectile. In the image above, the player is facing left, shooting two projectiles, and is jumping in the air.



Looking back at my code, I’m very happy with some of the way that my code is set up. The modules are almost entirely independent of eachother; all the entities are held in a vector, which is then modified by each game state, and drawn to the screen independently. Most of the functions and classes are independent of one another(modularization) which is something that I am constantly striving to improve in my games. My main function is very concise and manages to do very little work itself. The one thing that is still left in the Main() function that I’d ideally like separated is that the input handling is all located inside the main() loop: ideally I’d want it in it’s own header.



Tomorrow is my last day to finish up this game. Tomorrow, I’d like to add:

  1. Hopefully I can figure out the console color issue: it’s a real bummer not to be able to make it look prettier.
  2. More enemies + AI
  3. An actual level system, saved progress (gold, powerups, etc.)
  4. Title screen
  5. Save games (even if it’s just to a text file)
  6. Loaded levels (from text files)
  7. Interaction between projectiles and enemies

I don’t expect to be able to do all of this, but I’ll do as much as I can!

Game in a Weekend – Day 1

Day One 827w" sizes="(max-width: 827px) 100vw, 827px" />

Day 1 of my programming challenge has proven pretty successful, considering I only had a night of programming. I still have yet to put code into the game loop, so the game loads up a screen and stops. My main() function runs somewhat like this:


Set up the window

Draw the GUI (the border with the swirls)

Load the level (find player spawn, pull all objects, enemies, out of it)

Initialize the player (location: spawn)

Paint the layers to the screen


After this would come the game loop, where physics would be calculated and the screen would be redrawn each frame.


Most of my time tonight was spent on getting the graphics in the game to work properly. I’ve modeled the way that graphics are drawn slightly off of PyGame (which I used earlier this year to make a game for a contest at my University).


The layers that I want painted are as follows:

  1. Player
  2. Enemies
  3. Objects
  4. Level
  5. Text Overlays
  6. Game GUI


gfx.h keeps all the layers in a conveniently named layers class. When a layers object is first instantiated, each layer within it is filled with an empty layer. As the game loop runs, each frame all entities are added to their respective layers (e.g. chests would be added to the game_objects layer, while the enemies would be on the enemies layer).


When draw_all_layers() is called, each layer is drawn in order (actually only the top 3, since the bottom 3 will be relatively static during the game).

void draw_all_layers(layers l){

Check out the code here


Tomorrow I’m going to try to get physics working and a real game loop running, hopefully I can get most of it done so that I can spend Sunday on content, because my game will be pretty bland with only one level.


Reflection on Progress with C++

I’m getting the hang of it, kind of. I’m still trying to wrap my head around pointers and how I can use them most effectively, as well as some of the quirks that C++ has, but I’m confident that another day with the language will leave me much more confident with it. I love having the internet as a resource, I honestly don’t know what I’d do without it. I’ve also gotten some help from my friend Sebastian, since he has already played with C++ quite a bit. Having him as a resource is also incredibly helpful.

Game in a weekend

ascii 807w" sizes="(max-width: 807px) 100vw, 807px" />

As mentioned in my first post, one of my current goals is to learn C++. In my mind, one of my dream careers has always been programming games- from all accounts, C++ is one of _the_ languages to know. Learning a completely new language is always a challenge and I can’t stand reading through documentation and honestly some of the codeacademy type courses get dull as well.

With this in mind, I’m going to learn C++ by programming a game! In a weekend! Without any prior knowledge of the language! Sounds like a great idea, huh? I’ve done some thinking & preparation about this game beforehand, but all of the actual coding will be done over the next 3 days. I’ll make a “developer blog” type post every night updating progress. I don’t expect to be able to add all the features that I’d like but I expect a reasonably functional game by the end of the weekend.

I know that if I were to implement serious physics or serious graphics, then there is no way I’d finish it in a weekend, especially not in a new language, so I’ve opted to code the game using the console as a graphics engine and with very minimalistic physics. It’s going to be a simple 2d scroller, with enemies, powerups, and gold, but no real animations or anything really complex.

Wish me luck!

(this is where I tell all of my readers that if they want to join me, I’ll feature their games as well, but I don’t have any readers so I wont…)


Alright, this is my first post. No idea whether this will go anywhere or whether I’ll have the dedication to stick with it, but I’m going to try to make a development blog to document my various projects. It’s been a while since I’ve done any real writing (Engineering lol) so this will also hopefully be a way for me to at least maintain my writing skills.

What I’m up to

Example of LastWave (click for full size)

I’ve just finished my first year of university and I’ve got a few small projects under my belt, the latest being LastWave. I’ll go a bit into some of the algorithms I used in the making of it in future posts hopefully, but for now suffice to say that it was written in Javascript (check out the about page for more info). LastWave is actually the first coding project (not including websites) that I’ve actually shipped to the public so it’s been a huge learning experience for me and overall I’m very happy with what I was able to accomplish with it.

Going forward this summer I’ve got an internship at Circle Learning, where I’ll be further developing my PHP and Javascript skills. I’m really excited to have the opportunity to get a job in the field right after first year, I’m very lucky to have the opportunity. While I’m happy to be developing the aforementioned skills, I’m also finding that most of my bigger projects have been coded in Javascript and PHP, which is fine but ultimately I feel that I need to get some experience with other non-web languages.



Outside of web languages, I’ve got some very basic experience in Java and Python, but nothing serious. After doing some research, I’ve decided to learn C++ over the summer. C++ is one of the main languages used in game development, and as that’s one of the industries I’m considering out of university I figured I’d try to learn it.

My first impression of C++ was that it is a much more “hardcore” language than any I’ve dealt with previously. The compiler doesn’t come packaged with everything like it does with Java, and it’s not interpreted like Python or Javascript. Not only that, but getting the compiler is a huge pain. After following a couple of online guides, I managed to install MinGW and MinSYS, as well as Code::Blocks for editing.

My first project is going to be making an extremely simple ASCII platformer, so that I don’t have to deal with graphics quite yet. I don’t expect this to be very difficult as I’ve got a pretty good handle on 2d platformers at this point. After that, I’m hoping to take a foray into the 3d world. I’ll discuss all of that in a future blog post.
Alright, I don’t know how to end blog posts but I think this has been a long enough introduction (I also know nobody is going to read this :P), so I’ll end it here.