Ahmed Adamjee
/
SnakeVSBlock
Snake vs Block Game to be run upon K64F.
Diff: main.cpp
- Revision:
- 83:329da564799a
- Parent:
- 79:35cb65c52d25
- Child:
- 84:9950d561fdf8
--- a/main.cpp Mon May 06 10:49:50 2019 +0000 +++ b/main.cpp Mon May 06 14:28:35 2019 +0000 @@ -23,12 +23,12 @@ #endif init(); - _start.titleScreen(lcd, pad); + _start.titleScreen(); while(1) { //This loop is created for Play/Continue configuration menu(); //pops up the menu by calling the StartScreen Classes. // start the game - _start.credits(lcd); // this is after the menu to allow us to hide credits if we want to play the game without wasting any time. + _start.credits(); // this is after the menu to allow us to hide credits if we want to play the game without wasting any time. wait(1.0f/fps); // snakeVSblock game loop - detect input respect to the menu options, and update data and refresh screen gameLoop(); @@ -44,8 +44,8 @@ lcd.init(); //init for the N5110 Library. device.init(); //init for the FXOS8700CQ Library. pad.init(); //init for the Gamepad Library. - _game.init(); //init for the SnakeVSBlock Class. - _start.init(); //init for the Menu Class --> StartScreen. + _start.init(&lcd, &pad); //init for the Menu Class --> StartScreen. + _game.init(&lcd, &pad); //init for the SnakeVSBlock Class. srand(100000*noisy.read_u16()); //seeds the random number generator with a random noise from the K64F. } @@ -53,7 +53,7 @@ void menu() { read_write_stats(); //inside menu because used in a menu function for displaying the highest level saved. - _start.menu(lcd, pad); // this takes us to main menu inside startscreen, and connects automatically to all other menu functions. + _start.menu(); // this takes us to main menu inside startscreen, and connects automatically to all other menu functions. _set_mode_speed(); //takes all the data collected from the menu to configure the game. } @@ -61,7 +61,7 @@ void refresh_game() { lcd.clear(); //clears the N5110 screen for the next frame - _game.draw(lcd, pad); //draws the next game frame + _game.draw(); //draws the next game frame lcd.refresh(); //refreshes the N5110 screen to display the frame. } @@ -79,7 +79,7 @@ g_mode = _start.g_mode;// allows us to pass this information on to the snakevsblock class, to set the controls to either joystick or motion control. if (g_mode == 2) { //show instructions to handle motion control. - _start.motionControlInstructions(lcd); //this only comes up on the screen is the user selects motion control from menu options. + _start.motionControlInstructions(); //this only comes up on the screen is the user selects motion control from menu options. } } @@ -88,13 +88,13 @@ { while (1) { refresh_game(); - _game.read_input(pad, device, g_mode); //this reads the angle or joystick direction, on the condition of either of them being selected. + _game.read_input(device, g_mode); //this reads the angle or joystick direction, on the condition of either of them being selected. _game.get_pos(); //takes the game object coordinates and saves it privately to use later for implementing collisions. - _game.update(lcd, pad); //updates the game screen and checks for any collisions. + _game.update(); //updates the game screen and checks for any collisions. //the int back stores the value 1 if back is pressed inside the update function of snakevsblock, //This function also handles level progression and level failure operations by using the class WinLoose. - back = _game.CheckGameProgression(lcd, pad, sd); //and also sends relevant data to the sd card to implement stats functionality. + back = _game.CheckGameProgression(sd); //and also sends relevant data to the sd card to implement stats functionality. if(back) { break; //and this allows us to return to main menu by using the keyword break.