http://savas.ca/blog/wp-content/uploads/2014/05/ascii2.png 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:
- Player
- Enemies
- Objects
- Level
- Text Overlays
- 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){
drawLayer(l.game_objects);
drawLayer(l.player);
drawLayer(l.enemies);
}
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.