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.
Snek.h
00001 #include "mbed.h" 00002 #include "N5110.h" 00003 #include "Gamepad.h" 00004 00005 00006 //Snek has been named as such to avoid confusion when refering to or declaring snake 00007 00008 /** The Snake class 00009 * @brief Stores the location of all the snake segments, handles movement and growth of the snake 00010 * @author Andrew J. Moore 00011 * @date May, 2018 00012 */ 00013 00014 class Snek 00015 { 00016 public: 00017 00018 /** Constructor */ 00019 Snek(); 00020 00021 /** Destructor */ 00022 ~Snek(); 00023 00024 /** Initialisation function 00025 * @param the inital starting position for the snake's head, given in X and Y (int) 00026 */ 00027 void init(int x, int y); 00028 00029 /** Updates the location of the snake 00030 * @param the joystick's current direction (Direction) 00031 */ 00032 void update(Direction d); 00033 00034 /** Gets an X coordinate of the snake 00035 * @param the position in the snake being referenced (int) 00036 * @return the value of _x[ref] 00037 */ 00038 int getX(int ref); 00039 00040 /** Gets an Y coordinate of the snake 00041 * @param the position in the snake being referenced (int) 00042 * @return the value of _y[ref] 00043 */ 00044 int getY(int ref); 00045 00046 /** Gets the length of the snake 00047 * @return the value of _length 00048 */ 00049 int getLength(); 00050 00051 /** Grows the snake in length */ 00052 void grow(); 00053 00054 private: 00055 00056 //Private Variables 00057 int _length; 00058 int _speed; 00059 int _x[484]; //484 is the maximum size of the grid therefor max size of the snake 00060 int _y[484]; 00061 char _oldDirection; 00062 00063 //Private Methods 00064 };
Generated on Sun Jul 17 2022 04:24:16 by
1.7.2