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
See a detailed description of this project on Hackster.io . https://www.hackster.io/marcomerli/riotwear-snake-ca6dfc
food.h@81:737dff75e013, 2019-12-27 (annotated)
- Committer:
- batman52
- Date:
- Fri Dec 27 16:04:44 2019 +0000
- Revision:
- 81:737dff75e013
- Parent:
- 80:77210aa1ad9c
add use of touch sensor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
batman52 | 80:77210aa1ad9c | 1 | /***************************************************************************//** |
batman52 | 80:77210aa1ad9c | 2 | * @file food.h |
batman52 | 80:77210aa1ad9c | 3 | * @brief class for creating a food-like object and keeps track of its momvement |
batman52 | 80:77210aa1ad9c | 4 | ******************************************************************************* |
batman52 | 80:77210aa1ad9c | 5 | * @section License |
batman52 | 80:77210aa1ad9c | 6 | * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b> |
batman52 | 80:77210aa1ad9c | 7 | ******************************************************************************* |
batman52 | 80:77210aa1ad9c | 8 | * |
batman52 | 80:77210aa1ad9c | 9 | * Permission is granted to anyone to use this software for any purpose, |
batman52 | 80:77210aa1ad9c | 10 | * including commercial applications, and to alter it and redistribute it |
batman52 | 80:77210aa1ad9c | 11 | * freely, subject to the following restrictions: |
batman52 | 80:77210aa1ad9c | 12 | * |
batman52 | 80:77210aa1ad9c | 13 | * 1. The origin of this software must not be misrepresented; you must not |
batman52 | 80:77210aa1ad9c | 14 | * claim that you wrote the original software. |
batman52 | 80:77210aa1ad9c | 15 | * 2. Altered source versions must be plainly marked as such, and must not be |
batman52 | 80:77210aa1ad9c | 16 | * misrepresented as being the original software. |
batman52 | 80:77210aa1ad9c | 17 | * 3. This notice may not be removed or altered from any source distribution. |
batman52 | 80:77210aa1ad9c | 18 | * |
batman52 | 80:77210aa1ad9c | 19 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
batman52 | 80:77210aa1ad9c | 20 | * obligation to support this Software. Silicon Labs is providing the |
batman52 | 80:77210aa1ad9c | 21 | * Software "AS IS", with no express or implied warranties of any kind, |
batman52 | 80:77210aa1ad9c | 22 | * including, but not limited to, any implied warranties of merchantability |
batman52 | 80:77210aa1ad9c | 23 | * or fitness for any particular purpose or warranties against infringement |
batman52 | 80:77210aa1ad9c | 24 | * of any proprietary rights of a third party. |
batman52 | 80:77210aa1ad9c | 25 | * |
batman52 | 80:77210aa1ad9c | 26 | * Silicon Labs will not be liable for any consequential, incidental, or |
batman52 | 80:77210aa1ad9c | 27 | * special damages, or any other relief, or for any claim by any third party, |
batman52 | 80:77210aa1ad9c | 28 | * arising from your use of this Software. |
batman52 | 80:77210aa1ad9c | 29 | * |
batman52 | 80:77210aa1ad9c | 30 | ******************************************************************************/ |
batman52 | 80:77210aa1ad9c | 31 | |
batman52 | 80:77210aa1ad9c | 32 | #include "mbed.h" |
batman52 | 80:77210aa1ad9c | 33 | #include "settings.h" |
batman52 | 80:77210aa1ad9c | 34 | // #include "LS013B7DH03.h" |
batman52 | 80:77210aa1ad9c | 35 | |
batman52 | 80:77210aa1ad9c | 36 | class Gecko; // Forward declaration |
batman52 | 80:77210aa1ad9c | 37 | #ifndef FOOD_H_ |
batman52 | 80:77210aa1ad9c | 38 | #define FOOD_H_ |
batman52 | 80:77210aa1ad9c | 39 | /* Pixel map for the food |
batman52 | 80:77210aa1ad9c | 40 | * 4 most significant bits y-crd, 4 least significant bits x-crd |
batman52 | 80:77210aa1ad9c | 41 | * The upper left corner of the part is asigned coordinates (x,y)=(0,0) |
batman52 | 80:77210aa1ad9c | 42 | */ |
batman52 | 80:77210aa1ad9c | 43 | class Food{ |
batman52 | 80:77210aa1ad9c | 44 | public: |
batman52 | 80:77210aa1ad9c | 45 | Food(); |
batman52 | 80:77210aa1ad9c | 46 | bool isEaten(Gecko &gck); |
batman52 | 80:77210aa1ad9c | 47 | void reset(ColorMemLCD &display, const Gecko &gck); |
batman52 | 80:77210aa1ad9c | 48 | void draw(ColorMemLCD &display); |
batman52 | 80:77210aa1ad9c | 49 | |
batman52 | 80:77210aa1ad9c | 50 | private: |
batman52 | 80:77210aa1ad9c | 51 | uint8_t x; |
batman52 | 80:77210aa1ad9c | 52 | uint8_t y; |
batman52 | 80:77210aa1ad9c | 53 | void remove(ColorMemLCD &display); |
batman52 | 80:77210aa1ad9c | 54 | }; |
batman52 | 80:77210aa1ad9c | 55 | |
batman52 | 80:77210aa1ad9c | 56 | |
batman52 | 80:77210aa1ad9c | 57 | #endif /* FOOD_H_ */ |
batman52 | 80:77210aa1ad9c | 58 |