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 ll16j23s_test_docs
Food/Food.h@14:2dfe04ced21c, 2020-05-27 (annotated)
- Committer:
 - JoeShotton
 - Date:
 - Wed May 27 03:18:16 2020 +0000
 - Revision:
 - 14:2dfe04ced21c
 - Parent:
 - 13:7b7ec5db56b2
 
Final Version
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| JoeShotton | 3:fcd6d70e9694 | 1 | #ifndef FOOD_H | 
| JoeShotton | 3:fcd6d70e9694 | 2 | #define FOOD_H | 
| JoeShotton | 3:fcd6d70e9694 | 3 | |
| JoeShotton | 3:fcd6d70e9694 | 4 | #include "mbed.h" | 
| JoeShotton | 3:fcd6d70e9694 | 5 | #include "N5110.h" | 
| JoeShotton | 3:fcd6d70e9694 | 6 | #include "Gamepad.h" | 
| JoeShotton | 5:06fa7674622a | 7 | #include "FXOS8700CQ.h" | 
| JoeShotton | 10:a2d643b3c782 | 8 | |
| JoeShotton | 14:2dfe04ced21c | 9 | /** SnakeEngine: | 
| JoeShotton | 13:7b7ec5db56b2 | 10 | @brief - Functions that exclusively control the food | 
| JoeShotton | 10:a2d643b3c782 | 11 | @author Joseph Shotton | 
| JoeShotton | 10:a2d643b3c782 | 12 | @date May 2020 | 
| JoeShotton | 10:a2d643b3c782 | 13 | @version V1.0 | 
| JoeShotton | 10:a2d643b3c782 | 14 | */ | 
| JoeShotton | 10:a2d643b3c782 | 15 | |
| JoeShotton | 3:fcd6d70e9694 | 16 | class Food | 
| JoeShotton | 3:fcd6d70e9694 | 17 | { | 
| JoeShotton | 5:06fa7674622a | 18 | |
| JoeShotton | 3:fcd6d70e9694 | 19 | public: | 
| JoeShotton | 3:fcd6d70e9694 | 20 | |
| JoeShotton | 3:fcd6d70e9694 | 21 | Food(); | 
| JoeShotton | 3:fcd6d70e9694 | 22 | ~Food(); | 
| JoeShotton | 3:fcd6d70e9694 | 23 | |
| JoeShotton | 12:33a5cff31339 | 24 | |
| JoeShotton | 12:33a5cff31339 | 25 | /** Initialises magnetometer and seeds random function | 
| JoeShotton | 12:33a5cff31339 | 26 | *@param Gamepad | 
| JoeShotton | 12:33a5cff31339 | 27 | *@param LCD | 
| JoeShotton | 12:33a5cff31339 | 28 | *@param Magnetometer | 
| JoeShotton | 12:33a5cff31339 | 29 | */ | 
| JoeShotton | 10:a2d643b3c782 | 30 | void init(Gamepad &pad, N5110 &lcd, FXOS8700CQ &mag); | 
| JoeShotton | 12:33a5cff31339 | 31 | |
| JoeShotton | 12:33a5cff31339 | 32 | |
| JoeShotton | 12:33a5cff31339 | 33 | /** Chooses random coordinates for food | 
| JoeShotton | 12:33a5cff31339 | 34 | *@param Gamepad | 
| JoeShotton | 12:33a5cff31339 | 35 | *@param LCD | 
| JoeShotton | 12:33a5cff31339 | 36 | *@returns returns true if selected position is already on (ie the snake or walls are at this coordinate) | 
| JoeShotton | 12:33a5cff31339 | 37 | */ | 
| JoeShotton | 8:bcc3403d7e79 | 38 | bool rand_pos(Gamepad &pad, N5110 &lcd); | 
| JoeShotton | 12:33a5cff31339 | 39 | |
| JoeShotton | 12:33a5cff31339 | 40 | |
| JoeShotton | 12:33a5cff31339 | 41 | /** Animates food | 
| JoeShotton | 12:33a5cff31339 | 42 | *@param LCD | 
| JoeShotton | 12:33a5cff31339 | 43 | */ | 
| JoeShotton | 12:33a5cff31339 | 44 | void draw(N5110 &lcd); | 
| JoeShotton | 12:33a5cff31339 | 45 | |
| JoeShotton | 12:33a5cff31339 | 46 | |
| JoeShotton | 12:33a5cff31339 | 47 | /** Runs food functions that need looping | 
| JoeShotton | 12:33a5cff31339 | 48 | *@param LCD | 
| JoeShotton | 12:33a5cff31339 | 49 | */ | 
| JoeShotton | 9:0571880085cc | 50 | void run(N5110 &lcd); | 
| JoeShotton | 3:fcd6d70e9694 | 51 | |
| JoeShotton | 13:7b7ec5db56b2 | 52 | int x; | 
| JoeShotton | 13:7b7ec5db56b2 | 53 | int y; | 
| JoeShotton | 4:ea3fa51c4386 | 54 | |
| JoeShotton | 4:ea3fa51c4386 | 55 | private: | 
| JoeShotton | 4:ea3fa51c4386 | 56 | int _frame; | 
| JoeShotton | 5:06fa7674622a | 57 | float _values; | 
| JoeShotton | 5:06fa7674622a | 58 | float _seed; | 
| JoeShotton | 3:fcd6d70e9694 | 59 | }; | 
| JoeShotton | 3:fcd6d70e9694 | 60 | #endif |