Animator
Animate - animates a GameObject by replacing the image to be displayed with the next sprite of the animation at a specified interval
CharacterAnimate - animates a Character according to its speed
SingleAnimate - animates a Missil taking only the 1st line of the spritesheet
BackgroundManager
BackgroundManager - loads an image file onto the backgroundTexture
Render - renders the backgroundTexture
Game
gameInit - initializes SDL, creates a window and renderer, a BackgroundManager and initial GameObjects, as well as creating an InputHandler for the player-controlled Character
gameUpdate - calls the update functions of all existing gameObjects (except missiles)
gameRender - clears the renderer, calls the render functions of all gameObjects, then renders the scene (SDL_RenderPresent)
handleEvents - calls the InputHandler's KeyboardUpdate function for each event
gameCleaner - frees the memory used up by the window and renderer
InputHandler
KeyboardUpdate - runs a checkKey for every inputed key
checkKey - verifies if a given input is valid i.e. checks if inputed key corresponds to an action
actions - HORIZONTALLEFT, HORIZONTALRIGHT, Fire1, etc... are arrays of keycodes. It's possible to define the controls of the program by adding new keys into the arrays
GameObject
setSprite - creates an Animator (called sprite)
goUpdate - calls sprite's Animate function
goRender - gets the sprite's current animation frame and renders it on the gameObject's position
Character
- extends GameObject
goUpdate - calls its sprite's CharacterAnimate function, as well as the goUpdate function for each missil
move - changes the position of the ship by [dx, dy] amount
action - creates a new Missil and adds it to the missiles list
Missil
- extends GameObject
goUpdate - moves self upwards 1 pixel and calls it's sprite's SingleAnimate function.
main
Creates a new Game and calls its gameInit function.
Will call game's handleEvents, gameUpdate and gameRender functions (in that order) for as long as the game is running.
When the game is over, calls game's gameCleaner function.
TextureLoader
Loads a BMP file onto a surface, then creates a texture from that surface onto the renderTarget
TimeManager
A timer to control the refresh rate of the animations based on deltatime.