Henry Triff
/
ELEC2645_Project_el18ht
Game
Diff: main.cpp
- Revision:
- 26:f1d3b7e31091
- Parent:
- 25:31761087a83f
- Child:
- 27:7e230a7891f8
--- a/main.cpp Wed Apr 29 10:53:21 2020 +0000 +++ b/main.cpp Fri May 22 16:27:56 2020 +0000 @@ -9,11 +9,12 @@ Student ID Number: 201224295 Date: 10/02/2020 -INFO -> For a complete guide on how maps are drawn see Maps.h -> Before using ghost mode, ensure that you format the SD card in settings as this will cause the game to freeze -> When playing, i would recommend starting with the Basic car. The Alien space ship is REALLY REALLY hard to control - because it is so fast +DIAGNOSTICS AND TEST FUNCTIONS +> I created a separate program that allows me to test functions of this code and to test and view the maps that i have +created. The code is 'quick and dirty' but works well. the controls are a little confusing. Stick moves the view of the track +around and X and A zoom in and out. Pots are used to show/hide different aspects of the map. +> It can be found here: https://os.mbed.com//users/HenryWTriff/code/ELEC2645_Project_el18ht_Map_Viewer/ + */ //DEBUG DEFINITIONS @@ -32,17 +33,6 @@ #include "Ghost.h" #include <string> -//OBJECTS -Gamepad Device; //Controller -N5110 LCD; //LCD -FXOS8700CQ Gyro(I2C_SDA,I2C_SCL); //Gyroscope -SDFileSystem SD(PTE3, PTE1, PTE2, PTE4, "sd"); //SD card (For recording ghost data) -Graphics Graphics; //Graphics Class -Mechanics Mechanics; //Mechanics Class -Menu Menu; //Menu Class -LEDs LEDs; //LEDs Class -Ghost Ghost; //Ghost Class (For racing against a previos version of you) - #ifndef STRUCTS #define STRUCTS @@ -67,11 +57,17 @@ int Type; //The direction of the hypoentuse on the right angled triangle ( 1 = Top right, 2 = Bottom right, 3 = Bottom left, 4 = Top Left ) }; +struct Sprite_2D { + float x; + float y; + int type; +}; + struct Map_Data { //Information about the number of elements in each array int number_of_track_lines; int number_of_dotted_lines; - int number_of_flags; + int number_of_sprites; int number_of_walls; int number_of_off_track_squares; int number_of_off_track_triangles; @@ -98,19 +94,31 @@ #endif -#include "Maps.h" - //GLOBAL VARIABLES #ifndef ENUMS #define ENUMS enum track {Small, Medium, Large}; //Track Names enum cars {Basic, Offroad, Drifter, Sportscar, Racecar, Stupid}; //Car Names (Stupid is now the alien space ship) +enum sprites {Flag, Helicopter, People_Standing_1, People_Standing_2, People_Cheering}; #endif +//OBJECTS +Gamepad Device; //Controller +N5110 LCD; //LCD +FXOS8700CQ Gyro(I2C_SDA,I2C_SCL); //Gyroscope +SDFileSystem SD(PTE3, PTE1, PTE2, PTE4, "sd"); //SD card (For recording ghost data) +Graphics Graphics; //Graphics Class +Mechanics Mechanics; //Mechanics Class +Menu Menu; //Menu Class +LEDs LEDs; //LEDs Class +Ghost Ghost; //Ghost Class (For racing against a previos version of you) + +#include "Maps.h" + //Transform int angle = 0; //The angle of roation of the track -Point_2D translation = {0,0}; //The translationof the track -float horizon_factor = 0.02; //The translationof the track +Point_2D translation = {0,0}; //The translation of the track +float horizon_factor = 0.02; //The translation of the track float squish = 0.15; //The amount of squish of the track //Vehicle parameters @@ -130,7 +138,7 @@ bool ghost_enable = false; //Game Settings -int game_fps = 50; //Frame rate +int game_fps = 60; //Frame rate bool leds = true; //Turning the LEDs on / off (Useful for people with epilepsy as they flash quickly) bool gyro_enabled = false; //Gyro steering option @@ -206,7 +214,7 @@ (Line_2D *) Map_1_Track_Lines, (Line_2D *)Map_1_Track_Dotted_Lines, (Line_2D *)Map_1_Walls, - (Point_2D *)Map_1_Flags, + (Sprite_2D *)Map_1_Sprites, (Triangle_2D *)Map_1_Boost_Plates, Map_1, car_model, @@ -265,7 +273,7 @@ (Line_2D *) Map_1_Track_Lines, (Line_2D *)Map_1_Track_Dotted_Lines, (Line_2D *)Map_1_Walls, - (Point_2D *)Map_1_Flags, + (Sprite_2D *)Map_1_Sprites, (Triangle_2D *)Map_1_Boost_Plates, Map_1, car_model, @@ -290,7 +298,7 @@ (Line_2D *) Map_1_Track_Lines, (Line_2D *)Map_1_Track_Dotted_Lines, (Line_2D *)Map_1_Walls, - (Point_2D *)Map_1_Flags, + (Sprite_2D *)Map_1_Sprites, (Triangle_2D *)Map_1_Boost_Plates, Map_1, car_model, @@ -352,7 +360,7 @@ (Line_2D *) Map_2_Track_Lines, (Line_2D *)Map_2_Track_Dotted_Lines, (Line_2D *)Map_2_Walls, - (Point_2D *)Map_2_Flags, + (Sprite_2D *)Map_2_Sprites, (Triangle_2D *)Map_2_Boost_Plates, Map_2, car_model, @@ -410,7 +418,7 @@ (Line_2D *) Map_2_Track_Lines, (Line_2D *)Map_2_Track_Dotted_Lines, (Line_2D *)Map_2_Walls, - (Point_2D *)Map_2_Flags, + (Sprite_2D *)Map_2_Sprites, (Triangle_2D *)Map_2_Boost_Plates, Map_2, car_model, @@ -436,7 +444,7 @@ (Line_2D *) Map_2_Track_Lines, (Line_2D *)Map_2_Track_Dotted_Lines, (Line_2D *)Map_2_Walls, - (Point_2D *)Map_2_Flags, + (Sprite_2D *)Map_2_Sprites, (Triangle_2D *)Map_2_Boost_Plates, Map_2, car_model, @@ -498,7 +506,7 @@ (Line_2D *) Map_3_Track_Lines, (Line_2D *)Map_3_Track_Dotted_Lines, (Line_2D *)Map_3_Walls, - (Point_2D *)Map_3_Flags, + (Sprite_2D *)Map_2_Sprites, (Triangle_2D *)Map_3_Boost_Plates, Map_3, car_model, @@ -557,7 +565,7 @@ (Line_2D *) Map_3_Track_Lines, (Line_2D *)Map_3_Track_Dotted_Lines, (Line_2D *)Map_3_Walls, - (Point_2D *)Map_3_Flags, + (Sprite_2D *)Map_3_Sprites, (Triangle_2D *)Map_3_Boost_Plates, Map_3, car_model, @@ -581,7 +589,7 @@ (Line_2D *) Map_3_Track_Lines, (Line_2D *)Map_3_Track_Dotted_Lines, (Line_2D *)Map_3_Walls, - (Point_2D *)Map_3_Flags, + (Sprite_2D *)Map_3_Sprites, (Triangle_2D *)Map_3_Boost_Plates, Map_3, car_model,