NXP Rapid IoT prototyping kit port of Silabs "hungry gecko" smake-like game. https://os.mbed.com/teams/SiliconLabs/code/Hungry_gecko/
Dependencies: lib_sx9500 GraphicsDisplay ColorMemLCD Large_fonts
gecko.h
00001 /***************************************************************************//** 00002 * @file gecko.h 00003 * @brief class for creating a gecko-like object and keeps track of its momvement 00004 ******************************************************************************* 00005 * @section License 00006 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> 00007 ******************************************************************************* 00008 * 00009 * Permission is granted to anyone to use this software for any purpose, 00010 * including commercial applications, and to alter it and redistribute it 00011 * freely, subject to the following restrictions: 00012 * 00013 * 1. The origin of this software must not be misrepresented; you must not 00014 * claim that you wrote the original software. 00015 * 2. Altered source versions must be plainly marked as such, and must not be 00016 * misrepresented as being the original software. 00017 * 3. This notice may not be removed or altered from any source distribution. 00018 * 00019 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no 00020 * obligation to support this Software. Silicon Labs is providing the 00021 * Software "AS IS", with no express or implied warranties of any kind, 00022 * including, but not limited to, any implied warranties of merchantability 00023 * or fitness for any particular purpose or warranties against infringement 00024 * of any proprietary rights of a third party. 00025 * 00026 * Silicon Labs will not be liable for any consequential, incidental, or 00027 * special damages, or any other relief, or for any claim by any third party, 00028 * arising from your use of this Software. 00029 * 00030 ******************************************************************************/ 00031 00032 // #include "LS013B7DH03.h" 00033 #include "settings.h" 00034 #include "asymmetricPart.h" 00035 00036 class Gecko{ 00037 private: 00038 uint8_t _position[MAXLENGTH]; 00039 uint8_t _last; 00040 uint8_t _length; 00041 00042 asymmetricPart _head; 00043 00044 void drawPart(ColorMemLCD &display, uint8_t x, uint8_t y) const; 00045 void removePart(ColorMemLCD &display, uint8_t x, uint8_t y) const; 00046 00047 public: 00048 Gecko(); 00049 00050 /* Moves the snake and redraws it on the display */ 00051 void move(ColorMemLCD &display, Direction dir); 00052 00053 /* Redraw the entire snake */ 00054 void draw(ColorMemLCD &display) const; 00055 00056 /* Check if the snake has collides with itself */ 00057 bool selfCollision() const; 00058 00059 /* Increases the length of the snake by one STEPSIZE x STEPSIZE tile */ 00060 void increaseLength(ColorMemLCD &display, Direction dir); 00061 00062 /* Checks if the head of the snake occupies a STEP */ 00063 bool headOccupiesTile(uint8_t x, uint8_t y) const; 00064 00065 /* Chech if the snake occupies a STEPSIZE x STEPSIZE tile */ 00066 bool occupiesTile(uint8_t x, uint8_t y) const; 00067 00068 /* Get coordinates */ 00069 uint8_t getX(uint8_t indx) const; 00070 uint8_t getY(uint8_t indx) const; 00071 }; 00072 00073
Generated on Mon Aug 1 2022 14:25:58 by 1.7.2