Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Thu May 09 10:10:10 2019 +0000
Revision:
99:4841f326200f
Parent:
87:871d9fecb593
Child:
100:6403c1705a08
added file documentation lines to non classes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AhmedPlaymaker 87:871d9fecb593 1 #ifndef MAIN_H
AhmedPlaymaker 87:871d9fecb593 2 #define MAIN_H
AhmedPlaymaker 87:871d9fecb593 3
AhmedPlaymaker 73:80556a279962 4 /** @file main.h
AhmedPlaymaker 73:80556a279962 5 * @brief Main.cpp's header file that defines all the directives and objects to use along with the definition of it's own function prototypes.
AhmedPlaymaker 73:80556a279962 6 */
AhmedPlaymaker 73:80556a279962 7
AhmedPlaymaker 87:871d9fecb593 8 ///////////// MAIN.H ////////////////
AhmedPlaymaker 73:80556a279962 9
AhmedPlaymaker 73:80556a279962 10 ///////// pre-processor directives ////////
AhmedPlaymaker 73:80556a279962 11 #include "mbed.h"
AhmedPlaymaker 73:80556a279962 12 #include "Gamepad.h"
AhmedPlaymaker 73:80556a279962 13 #include "N5110.h"
AhmedPlaymaker 73:80556a279962 14 #include "FXOS8700CQ.h"
AhmedPlaymaker 73:80556a279962 15 #include "StartScreen.h"
AhmedPlaymaker 73:80556a279962 16 #include "SnakevsBlock.h"
AhmedPlaymaker 73:80556a279962 17 #include "SDFileSystem.h"
AhmedPlaymaker 73:80556a279962 18
AhmedPlaymaker 73:80556a279962 19 #ifdef TEST_SNAKE
AhmedPlaymaker 73:80556a279962 20 # include "tests.h"
AhmedPlaymaker 73:80556a279962 21 #endif
AhmedPlaymaker 73:80556a279962 22
AhmedPlaymaker 73:80556a279962 23 /////////////// objects ///////////////
AhmedPlaymaker 73:80556a279962 24 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
AhmedPlaymaker 73:80556a279962 25 Gamepad pad;
AhmedPlaymaker 73:80556a279962 26 FXOS8700CQ device(I2C_SDA,I2C_SCL);
AhmedPlaymaker 73:80556a279962 27 StartScreen _start;
AhmedPlaymaker 73:80556a279962 28 Stats _stats;
AhmedPlaymaker 73:80556a279962 29 SnakevsBlock _game;
AhmedPlaymaker 73:80556a279962 30 AnalogIn noisy(PTB0); //This creates a random noise which I can use to seed the random numbers.
AhmedPlaymaker 73:80556a279962 31 // Connections to SD card holder on K64F (SPI interface)
AhmedPlaymaker 73:80556a279962 32 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS
AhmedPlaymaker 73:80556a279962 33 //Serial serial(USBTX, USBRX); // for PC debug
AhmedPlaymaker 73:80556a279962 34
AhmedPlaymaker 73:80556a279962 35
AhmedPlaymaker 73:80556a279962 36 //Constants//
AhmedPlaymaker 73:80556a279962 37 int fps = 40; // frames per second, this will be changed in menu.
AhmedPlaymaker 73:80556a279962 38 int g_mode = 1; //selects between joystick and motion control.
AhmedPlaymaker 73:80556a279962 39 int back; //this allows us to use the back key to exit the game loop;
AhmedPlaymaker 73:80556a279962 40
AhmedPlaymaker 73:80556a279962 41
AhmedPlaymaker 73:80556a279962 42 ///////////// prototypes //////////////
AhmedPlaymaker 99:4841f326200f 43 //Initialises main.cpp
AhmedPlaymaker 73:80556a279962 44 void init();
AhmedPlaymaker 99:4841f326200f 45 //calls functions using class objects to display menu.
AhmedPlaymaker 73:80556a279962 46 void menu();
AhmedPlaymaker 99:4841f326200f 47 //Constantly reads and writes stats from and to the SD card.
AhmedPlaymaker 73:80556a279962 48 void read_write_stats();
AhmedPlaymaker 99:4841f326200f 49 //sets game mode and game speed into snakevsblocks class by reading these from startscreen.
AhmedPlaymaker 73:80556a279962 50 void _set_mode_speed();
AhmedPlaymaker 99:4841f326200f 51 //this is executed when the player starts the game.
AhmedPlaymaker 73:80556a279962 52 void gameLoop();
AhmedPlaymaker 99:4841f326200f 53 //refreshes display and draws game objects using snakevsblock class.
AhmedPlaymaker 84:9950d561fdf8 54 void refresh_game();
AhmedPlaymaker 87:871d9fecb593 55 //void deinit();
AhmedPlaymaker 87:871d9fecb593 56
AhmedPlaymaker 87:871d9fecb593 57 #endif