Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
gameobject.h
00001 #ifndef GAMEOBJECT_H 00002 #define GAMEOBJECT_H 00003 00004 #include "collision_lib.h" 00005 00006 ///////////////////////////////////////////////////////////////////// 00007 /** 00008 * GameObject Class 00009 * @brief Base class for all objects in the game world. 00010 * @author Dmitrijs Griskovs 00011 * @date 15/04/2019 00012 */ 00013 class GameObject { 00014 public: 00015 /** 00016 * @brief Activates the object at the given postion. 00017 * @param spawn_pos sets position of x and y into pos (Point). 00018 */ 00019 void spawn(Point spawn_pos) { 00020 pos = spawn_pos; 00021 active = true; 00022 } 00023 Point pos; 00024 bool active; 00025 }; 00026 00027 /** 00028 * @brief A simplified function to draw sprites. 00029 * @details This is a specific function I made to simplify drawing the sprites. 00030 * It only works with spawn() function in gameobject.h. 00031 * The parameters for this function are given in the models.cpp for the 00032 * sprites. 00033 */ 00034 static void drawSprite(Point pos, const Sprite& sprite) { 00035 lcd.drawSprite(pos.x, pos.y, sprite.height, sprite.width, (int*)sprite.data); 00036 } 00037 00038 /** 00039 * @brief A simplified function to draw sprites. But this draw black pixels on top of white pixels. 00040 * @details This is an exactly the same function as before, but for the drawing 00041 * sprite function that draws the black pixels on top the white pixels when the 00042 * sprites overlap. 00043 */ 00044 static void drawSpriteOnTop(Point pos, const Sprite& sprite) { 00045 lcd.drawSpriteOnTop(pos.x, pos.y, sprite.height, sprite.width, (int*)sprite.data); 00046 } 00047 #endif
Generated on Wed Dec 20 2023 20:30:17 by
