Engine library
Embed:
(wiki syntax)
Show/hide line numbers
Engine.h
00001 #ifndef ENGINE_H 00002 #define ENGINE_H 00003 #include "N5110.h" 00004 #include "Gamepad.h" 00005 #include "Character.h" 00006 #include "Levels.h" 00007 #include "FXOS8700CQ.h" 00008 #include "Science.h" 00009 00010 00011 00012 /** Engine Class 00013 @brief A class to run a game loop 00014 @brief Interfaces with the N5110 class, Gamepad class, Levels class, FXOS8700CQ class, Levels class, Science class, and Character class. 00015 @author Victoria Filor 00016 @date May 17 00017 */ 00018 00019 00020 00021 /** current coordinate struct */ 00022 typedef struct current_coordinate_struct {//https://www.quora.com/How-can-I-return-a-structure-from-a-function-in-c 00023 int current_x; /**< integer for the current_x coordinate */ 00024 int current_y; /**< integer for the current_y coordinate */ 00025 } current_coordinate_struct; 00026 00027 00028 00029 /** new coordinate struct */ 00030 typedef struct new_coordinate_struct {//https://www.quora.com/How-can-I-return-a-structure-from-a-function-in-c 00031 int new_x; /**< integer for the new_x coordinate */ 00032 int new_y; /**< integer for the new_y coordinate */ 00033 } new_coordinate_struct; 00034 00035 00036 class Engine 00037 { 00038 public: 00039 00040 00041 void init(); 00042 00043 00044 /** handles the input 00045 * 00046 *Handles the inputs and returns the current coordinates of the character 00047 *@param new_x - new_x from calculations 00048 *@param new_y - new_y from calculations 00049 *@param Gamepad - to interact with the Gamepad class 00050 *@param N5110 - to interact with the Nokia N5110 class 00051 *@param Character - to interact with the Character class 00052 *@param Levels - to interact with the Levels class 00053 *@param Science - to interact with the Science class 00054 * 00055 *@return current_coordinate_struct - returns a struct containing the current coordinate 00056 */ 00057 current_coordinate_struct handle_input(int new_x, int new_y, Gamepad &pad, N5110 &lcd,Character &character, Levels &levels, Science &science);//smooth sensor, current = new/fullycorrected 00058 00059 00060 00061 /** update variables 00062 * 00063 * Updates the coordinates based on movements and collisions of the character 00064 *@param radius - radius of the character 00065 *@param current_x - current central x coordinate of the character 00066 *@param current_y - current central y coordinate of the character 00067 *@param Device - to read from the accelerometer of the FRDM K64F 00068 *@param N5110 - to interact with the Nokia N5110 class 00069 *@param Levels - to interact with the Levels class 00070 *@param Science - to interact with the Science class 00071 *@param Gamepad - to interact with the Gamepad class 00072 * 00073 *@return new_coordinate_struct - returns a struct containing the new coordinate of where the character shall move to 00074 */ 00075 new_coordinate_struct update(int radius, int current_x, int current_y, Science &science, FXOS8700CQ &device, N5110 &lcd, Levels &levels, Gamepad &pad); 00076 00077 00078 00079 /** draw 00080 * 00081 *Draws the maze, exit and character as appropriate 00082 *@param current_x - current centre x coordinate of the character 00083 *@param current_y - current centre y coordinate of the character 00084 *@param radius - radius of the character 00085 *@param Character - to draw the character 00086 *@param N5110 - to interact with the Nokia N5110 class 00087 *@param Levels - to interact with the Levels class 00088 * 00089 *@return current_coordinate_struct - returns a struct containing the current coordinate 00090 */ 00091 void draw(int new_x, int new_y, int radius, Character &character, Levels &levels, N5110 &lcd); //uses the fully corrected/ latest new_x/y to update 00092 00093 00094 00095 /** checks if levels need updating 00096 * 00097 *Compares the position of the where the character will be in the next frame to the exit, to see if the next level needs to be set 00098 *@param current_x - next central x coordinate of the character 00099 *@param current_y - next central y coordinate of the character 00100 *@param Levels - to interact with the Levels class 00101 */ 00102 void check_for_level_update( int new_x, int new_y, Levels &levels); 00103 00104 private: 00105 00106 00107 00108 volatile int level_index; // index indicating the level 00109 00110 00111 }; 00112 00113 #endif
Generated on Tue Jul 19 2022 23:47:38 by
1.7.2