ELEC2645 (2017/18) / Mbed 2 deprecated ll13jrm

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Food.h Source File

Food.h

00001 #ifndef FOOD_H
00002 #define FOOD_H
00003 
00004 #include "mbed.h"
00005 #include "Gamepad.h"
00006 #include "N5110.h"
00007 
00008 /** Frame_counting function */
00009 
00010 int g_frame_counter(); //
00011 
00012 static int g_fc; /**< int for frame counter */
00013     
00014 /** Food Class
00015 * @brief Describes the methods and functions for the food class
00016 * @author Joshua R. Marshall
00017 * @date Feb, 2018
00018 */
00019 
00020 class Food
00021 {
00022 
00023 public:
00024     Food(); // constructor
00025     ~Food(); // destructor
00026     
00027     /** Initialise position of food */
00028 
00029     void init(bool collision);
00030     
00031     /** Updates food state  */
00032 
00033     void update(bool collision, int n_frames);
00034     
00035     /** Draws food on lcd */
00036     
00037     void draw(N5110 &lcd);
00038     
00039     /** Gets a random position for spawning food */
00040     
00041     Vector2D get_rand_pos();
00042     
00043     /** @brief resets food position when collsion event or a set number of frames have passed
00044     @param set_frames corresponds to frame counter
00045     @param number_frames number of frames before resetting food position
00046     @param when true reset food position
00047     */
00048     
00049     void set_food_position(int set_frames, int number_frames, bool collision);
00050     
00051     /** @return returns food position */
00052     
00053     Vector2D get_food_position ();
00054     
00055 private:
00056 
00057     int _x;
00058     int _y;
00059     int _number_frames;
00060 
00061 };
00062 #endif