Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

MenuClasses/StartScreen/StartScreen.cpp

Committer:
AhmedPlaymaker
Date:
2019-04-28
Revision:
57:845781aea5ec
Parent:
56:142e9fdb77a8
Child:
58:affb42c56cf8

File content as of revision 57:845781aea5ec:

#include "StartScreen.h"
Settings settings;

int sprite[48][84] = {
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
    {1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,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0,0,0,0,0,0,0,0,0,1},
    {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},

};
    
int arrow[7][9] = {
    {0,0,0,0,1,0,0,0,0},
    {0,0,0,1,1,0,0,0,0},
    {0,0,1,1,1,0,0,0,0},
    {0,1,1,1,1,1,1,1,1},
    {0,0,1,1,1,0,0,0,0},
    {0,0,0,1,1,0,0,0,0},
    {0,0,0,0,1,0,0,0,0},
};
    
int motionControl[12][21] = {
    {0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0},
    {0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0},
    {0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0},
    {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},
    {0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0},
    {1,1,1,0,1,0,0,1,1,1,1,1,1,1,0,0,1,0,1,1,1},
    {1,1,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,1,1},
    {1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1},
    {0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0},
    {0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0},
    {0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0},
};

int joystick[13][48] = {
    {0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0},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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0},
    {0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0},
};

int navL[13][8] = {
    {0,0,0,0,0,0,1,1},
    {0,0,0,0,0,1,1,0},
    {0,0,0,0,1,1,0,0},
    {0,0,0,1,1,0,0,0},
    {0,0,1,1,0,0,0,0},
    {0,1,1,0,0,0,0,0},
    {1,1,1,1,1,1,1,1},
    {0,1,1,0,0,0,0,0},
    {0,0,1,1,0,0,0,0},
    {0,0,0,1,1,0,0,0},
    {0,0,0,0,1,1,0,0},
    {0,0,0,0,0,1,1,0},
    {0,0,0,0,0,0,1,1},
};

int navR[13][8] = {
    {1,1,0,0,0,0,0,0},
    {0,1,1,0,0,0,0,0},
    {0,0,1,1,0,0,0,0},
    {0,0,0,1,1,0,0,0},
    {0,0,0,0,1,1,0,0},
    {0,0,0,0,0,1,1,0},
    {1,1,1,1,1,1,1,1},
    {0,0,0,0,0,1,1,0},
    {0,0,0,0,1,1,0,0},
    {0,0,0,1,1,0,0,0},
    {0,0,1,1,0,0,0,0},
    {0,1,1,0,0,0,0,0},
    {1,1,0,0,0,0,0,0},
};

StartScreen::StartScreen()
{
    
}

StartScreen::~StartScreen()
{

}

void StartScreen::init()
{
    i = 16; //main menu selection arrow position
    g_mode = 1; //game mode selection (joystick/motion control).
    gs = 2; //game speed page selection.
    st = 1; //this is the sr num of settings pages.
    sc = 1; //this helps in wether ot not to show credits to the user.
    cs = 4; //sensitivity of control speed of menu options.
}

void StartScreen::screen_saver(N5110 &lcd, Gamepad &pad)
{
    //this saves the Theme song I want to play at the start.
    int song[18] = {441,494,439,372,392,370,330,246,329,331,370,555,555,495,440,392,392,370};
    pad.leds_on();
    
    for(int ani = -51; ani <= 0; ani+=3)  {
        lcd.clear();
        lcd.drawSprite(0,ani,48,84,(int *)sprite); //Function used to draw the sprite
        lcd.refresh();
        pad.tone(song[(ani+48)/3],0.1);
        wait(0.2);
    }
    
    wait(0.3);
    pad.leds_off();
    lcd.clear();
    
    StartScreen::instruct(lcd,pad); //after the screen_saver is displayed we need to send in instructions of how to preoceed to menu.
}

void StartScreen::instruct(N5110 &lcd, Gamepad &pad)
{
    lcd.printString("Please Press",5,1); //Function used to promt the user to start.
    lcd.printString("Start",25,3);
    lcd.printString("to Begin",15,5);
    lcd.refresh();
    pad.init();
    while ( pad.check_event(Gamepad::START_PRESSED) == false) {
        pad.leds_on();
        wait(0.1);
        pad.leds_off();
        wait(0.1);
    }
    pad.tone(1000.0,0.1);
    lcd.clear();
    pad.leds_off();
}
    
void StartScreen::credits(N5110 &lcd)
{   
    lcd.clear();
    if(sc)  {
        lcd.printString("Created BY",8,1);
        lcd.printString("Ahmed",24,3);
        lcd.printString("Adamjee",20,4);
        lcd.printString("201161436",15,5);
        lcd.refresh();
        wait(2);
    }
    lcd.clear();
}

void StartScreen::read_stats(SDFileSystem &sd)
{
    _stats.read(sd);
}

void StartScreen::main_menu(N5110 &lcd, Gamepad &pad)
{
    lcd.clear();
    //StartScreen::init();
    pad.init();
    while ((pad.check_event(Gamepad::A_PRESSED) == false)&&(pad.check_event(Gamepad::START_PRESSED) == false)) {  //Change this to if button pressed.
        StartScreen::ImplementMenu(lcd, pad);
    }
    pad.tone(1000.0,0.1);
    wait(1/cs);
    StartScreen::NextMenu(lcd, pad);
}

void StartScreen::ImplementMenu(N5110 &lcd, Gamepad &pad)
{   
    lcd.printString("SnakeVSBlock",5,0);
    lcd.printString("Play",0,2);
    lcd.printString("Settings",0,3);
    lcd.printString("Stats",0,4);
    lcd.printString("Tutorial",0,5);
    Direction d = pad.get_direction();
    if((d==N)&&(i>16))  {
            i=i-8;
    }
    if((d==S)&&(i<40))  {
            i=i+8;
    }
    lcd.drawSprite(50,i,7,9,(int *)arrow); //Function used to draw the sprite.
    lcd.refresh();
    wait(1/cs);
    lcd.clear();
}

void StartScreen::NextMenu(N5110 &lcd, Gamepad &pad)
{
    switch (i) {
    case 16:
        game_mode(lcd, pad);
        break;
    case 24:
        float *cs_sc;
        cs_sc = settings.Implement(lcd, pad, cs);
        cs = cs_sc[0]; //saves the number in cs which controls the control speed of the menu oftions (basically the wait time of between reading joystick input).
        sc = cs_sc[1]; //saves the number in sc which decides weather or not to show credits when game starts.
        main_menu(lcd, pad); //to return to main_menu if back is pressed
        break;
    case 32:
        _stats.StatsDisplay(lcd, pad);
        main_menu(lcd, pad); //to return to main_menu if back is pressed
        break;
    default:
        main_menu(lcd, pad); //to return to main_menu if back is pressed
        break;
    }
}

void StartScreen::game_mode(N5110 &lcd, Gamepad &pad)
{
    lcd.clear();
    wait(2/cs);
    pad.init();
    while ((pad.check_event(Gamepad::A_PRESSED) == false)&&(pad.check_event(Gamepad::START_PRESSED) == false)) {  //Change this to if button pressed.
        StartScreen::ModeOptions(lcd); //displays to the user what are the mode options
        StartScreen::SelectMode(pad);  //the mode is selected by moving joystick in this function.
        if (pad.check_event(Gamepad::BACK_PRESSED) == true) {  //This is a very important process, this helps the code to not get stuck in  menu loop.
            pad.tone(1000.0,0.1);
            back_pressed = 1;
            break;
        }
        else {back_pressed = 0;}
    }
    if(back_pressed) {
        main_menu(lcd, pad);
    }
    else {
        pad.tone(1000.0,0.1);
        lcd.clear();
        game_speed(lcd, pad);
    }
}

void StartScreen::ModeOptions(N5110 &lcd)
{
    lcd.clear();
    switch (g_mode) {
    case 1:
        lcd.printString("Joystick",18,1);
        lcd.drawSprite(17,22,13,48,(int *)joystick); //Function used to draw the sprite.
        lcd.refresh();
        break;
    case 2:
        lcd.drawSprite(10,22,13,8,(int *)navL); //Function used to draw the sprite.
        lcd.drawSprite(65,22,13,8,(int *)navR); //Function used to draw the sprite.
        lcd.printString("Motion Control",1,1);
        lcd.drawSprite(32,22,12,21,(int *)motionControl); //Function used to draw the sprite.
        break;
    }
        
    lcd.refresh();
}

void StartScreen::SelectMode(Gamepad &pad)
{   
    Direction d = pad.get_direction();
    wait(1/cs);
    if(((d==E)||(d==W))&&(g_mode==1))  {
        g_mode=2;
    }
    
    else if(((d==E)||(d==W))&&(g_mode==2))  {
        g_mode=1;
    }
}

void StartScreen::game_speed(N5110 &lcd, Gamepad &pad)
{
    lcd.clear();
    wait(2/cs);
    pad.init();
    while ((pad.check_event(Gamepad::A_PRESSED) == false)&&(pad.check_event(Gamepad::START_PRESSED) == false)) {  //Change this to if button pressed.
        StartScreen::ImplementGS(pad);
        StartScreen::DisplayGSContents(lcd);
        if (pad.check_event(Gamepad::BACK_PRESSED) == true) {  //This is a very important process, this helps the code to not get stuck in  menu loop.
            pad.tone(1000.0,0.1);
            back_pressed = 1;
            break;
        }
        else {back_pressed = 0;}
    }
    if(back_pressed) {
        game_mode(lcd, pad);
    }
    else {
        pad.tone(1000.0,0.1);
        lcd.clear();
        wait(1/cs);
    }
}

void StartScreen::ImplementGS(Gamepad &pad)
{   
    Direction d = pad.get_direction();
    wait(1/cs);
    if((d==E)&&(gs==4))  {
        gs=1;
    }
    else if((d==W)&&(gs==1))  {
        gs=4;
    }
    else if((d==E)&&(1<=gs<=3))  {
        gs=gs+1;
    }
    else if((d==W)&&(2<=gs<=4))  {
        gs=gs-1;
    }
}

void StartScreen::DisplayGSContents(N5110 &lcd)
{   
    lcd.clear();
    lcd.drawSprite(10,22,13,8,(int *)navL); //Function used to draw the sprite.
    lcd.drawSprite(65,22,13,8,(int *)navR); //Function used to draw the sprite.
    lcd.printString("Game Speed",10,1);
    switch (gs) {
    case 1:
        lcd.printString("SNAIL",28,3);
        fps = 12;
        break;
    case 2:
        lcd.printString("HUMAN",28,3);
        fps = 18;
        break;
    case 3:
        lcd.printString("HORSE",28,3);
        fps = 22;
        break;
    case 4:
        lcd.printString("CHEETHA",21,3);
        fps = 27;
    }
    
    lcd.refresh();
}