![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
main.h@84:9950d561fdf8, 2019-05-06 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Mon May 06 16:15:21 2019 +0000
- Revision:
- 84:9950d561fdf8
- Parent:
- 73:80556a279962
- Child:
- 87:871d9fecb593
Added some more comments to describe what some of my functions and methods do.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 73:80556a279962 | 1 | /** @file main.h |
AhmedPlaymaker | 73:80556a279962 | 2 | * @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 | 3 | */ |
AhmedPlaymaker | 73:80556a279962 | 4 | |
AhmedPlaymaker | 73:80556a279962 | 5 | ///////////// MAIN.CPP //////////////// |
AhmedPlaymaker | 73:80556a279962 | 6 | |
AhmedPlaymaker | 73:80556a279962 | 7 | ///////// pre-processor directives //////// |
AhmedPlaymaker | 73:80556a279962 | 8 | #include "mbed.h" |
AhmedPlaymaker | 73:80556a279962 | 9 | #include "Gamepad.h" |
AhmedPlaymaker | 73:80556a279962 | 10 | #include "N5110.h" |
AhmedPlaymaker | 73:80556a279962 | 11 | #include "FXOS8700CQ.h" |
AhmedPlaymaker | 73:80556a279962 | 12 | #include "StartScreen.h" |
AhmedPlaymaker | 73:80556a279962 | 13 | #include "SnakevsBlock.h" |
AhmedPlaymaker | 73:80556a279962 | 14 | #include "SDFileSystem.h" |
AhmedPlaymaker | 73:80556a279962 | 15 | |
AhmedPlaymaker | 73:80556a279962 | 16 | #ifdef TEST_SNAKE |
AhmedPlaymaker | 73:80556a279962 | 17 | # include "tests.h" |
AhmedPlaymaker | 73:80556a279962 | 18 | #endif |
AhmedPlaymaker | 73:80556a279962 | 19 | |
AhmedPlaymaker | 73:80556a279962 | 20 | |
AhmedPlaymaker | 73:80556a279962 | 21 | /////////////// objects /////////////// |
AhmedPlaymaker | 73:80556a279962 | 22 | N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11); |
AhmedPlaymaker | 73:80556a279962 | 23 | Gamepad pad; |
AhmedPlaymaker | 73:80556a279962 | 24 | FXOS8700CQ device(I2C_SDA,I2C_SCL); |
AhmedPlaymaker | 73:80556a279962 | 25 | StartScreen _start; |
AhmedPlaymaker | 73:80556a279962 | 26 | Stats _stats; |
AhmedPlaymaker | 73:80556a279962 | 27 | SnakevsBlock _game; |
AhmedPlaymaker | 73:80556a279962 | 28 | AnalogIn noisy(PTB0); //This creates a random noise which I can use to seed the random numbers. |
AhmedPlaymaker | 73:80556a279962 | 29 | // Connections to SD card holder on K64F (SPI interface) |
AhmedPlaymaker | 73:80556a279962 | 30 | SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS |
AhmedPlaymaker | 73:80556a279962 | 31 | //Serial serial(USBTX, USBRX); // for PC debug |
AhmedPlaymaker | 73:80556a279962 | 32 | |
AhmedPlaymaker | 73:80556a279962 | 33 | |
AhmedPlaymaker | 73:80556a279962 | 34 | //Constants// |
AhmedPlaymaker | 73:80556a279962 | 35 | int fps = 40; // frames per second, this will be changed in menu. |
AhmedPlaymaker | 73:80556a279962 | 36 | int g_mode = 1; //selects between joystick and motion control. |
AhmedPlaymaker | 73:80556a279962 | 37 | int back; //this allows us to use the back key to exit the game loop; |
AhmedPlaymaker | 73:80556a279962 | 38 | |
AhmedPlaymaker | 73:80556a279962 | 39 | |
AhmedPlaymaker | 73:80556a279962 | 40 | ///////////// prototypes ////////////// |
AhmedPlaymaker | 73:80556a279962 | 41 | void init(); |
AhmedPlaymaker | 73:80556a279962 | 42 | void menu(); |
AhmedPlaymaker | 73:80556a279962 | 43 | void read_write_stats(); |
AhmedPlaymaker | 73:80556a279962 | 44 | void _set_mode_speed(); |
AhmedPlaymaker | 73:80556a279962 | 45 | void gameLoop(); |
AhmedPlaymaker | 84:9950d561fdf8 | 46 | void refresh_game(); |
AhmedPlaymaker | 73:80556a279962 | 47 | //void deinit(); |