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.
Dependencies: mbed
Fork of el17dg by
sprite.h
00001 #ifndef SPRITE_H 00002 #define SPRITE_H 00003 00004 #include "collision_lib.h" 00005 #include "main.h" 00006 00007 /** @struct Sprite 00008 * @brief A function to put a sprite and its data in one variable. 00009 * @details A struct that alows to create an object containing a sprite, its width and height. 00010 * It is used with another function located in main.h. 00011 * @var Sprire::width . 00012 * Member 'width' contains witdh of the sprite. 00013 * @var Sprire::height. 00014 * Member 'height' contains height of the sprite. 00015 * @var Sprire::data. 00016 * Member 'data' contains the array of 1s and 0s of the sprite. 00017 */ 00018 struct Sprite { 00019 /*@{*/ 00020 Sprite(int _width, int _height, const int* _data) : width(_width), height(_height), data(_data) {} 00021 int width; /**< The width of the sprite*/ 00022 int height; /**< The height of the sprite*/ 00023 const int* data; /**< The array of 1s and 0s of the sprite.*/ 00024 }; 00025 00026 /** 00027 * @brief A simplified function to draw sprites. 00028 * @details This is a specific function I made to simplify drawing the sprites. 00029 * It only works with spawn() function in gameobject.h. 00030 * The parameters for this function are given in the models.cpp for the 00031 * sprites. 00032 */ 00033 static void drawSprite(Point pos, const Sprite& sprite) { 00034 lcd.drawSprite(pos.x, pos.y, sprite.height, sprite.width, (int*)sprite.data); 00035 } 00036 00037 /** 00038 * @brief A simplified function to draw sprites. But this draw black pixels on top of white pixels. 00039 * @details This is an exactly the same function as before, but for the drawing 00040 * sprite function that draws the black pixels on top the white pixels when the 00041 * sprites overlap. 00042 */ 00043 static void drawSpriteOnTop(Point pos, const Sprite& sprite) { 00044 lcd.drawSpriteOnTop(pos.x, pos.y, sprite.height, sprite.width, (int*)sprite.data); 00045 } 00046 00047 #endif
Generated on Thu Jul 14 2022 14:15:02 by
1.7.2
