120 lines
2.5 KiB
C
120 lines
2.5 KiB
C
/*
|
|
* Metro Siberia 4 - A sequel to Dark Storm's Metro Siberia 3 for CASIO calculators.
|
|
* Copyright (C) 2015 Dark Storm
|
|
* Copyright (C) 2022 Mibi88
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
|
|
int selection, stat;
|
|
|
|
extern bopti_image_t title;
|
|
extern bopti_image_t game_over;
|
|
extern bopti_image_t you_won;
|
|
extern bopti_image_t menu_play;
|
|
extern bopti_image_t menu_play_inv;
|
|
extern bopti_image_t menu_quit;
|
|
extern bopti_image_t menu_quit_inv;
|
|
|
|
extern font_t milifont;
|
|
|
|
extern Ship ship;
|
|
|
|
void waitkey(int key){
|
|
clearevents();
|
|
while(keydown(key)){
|
|
clearevents();
|
|
}
|
|
}
|
|
|
|
void end(){
|
|
dclear(C_WHITE);
|
|
if(stat == 0){
|
|
dimage(0, 0, &game_over);
|
|
}else if(stat == 1){
|
|
dimage(0, 0, &you_won);
|
|
}
|
|
dprint_opt(57, 30, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "Score : %d", ship.score);
|
|
if(stat == 0 || stat == 1){
|
|
dupdate();
|
|
stat = 0;
|
|
clearevents();
|
|
while(!keydown(KEY_EXIT)){
|
|
clearevents();
|
|
if(keydown(KEY_SHIFT))
|
|
break;
|
|
clearevents();
|
|
if(keydown(KEY_EXE))
|
|
break;
|
|
clearevents();
|
|
}
|
|
}else{
|
|
return;
|
|
}
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
dfont(&milifont);
|
|
selection = PLAY;
|
|
stat = 0;
|
|
while(1){
|
|
dclear(C_WHITE);
|
|
if(selection != PLAY){
|
|
dimage(70, 22, &menu_play);
|
|
}else{
|
|
dimage(70, 22, &menu_play_inv);
|
|
}
|
|
if(selection != QUIT){
|
|
dimage(70, 32, &menu_quit);
|
|
}else{
|
|
dimage(70, 32, &menu_quit_inv);
|
|
}
|
|
clearevents();
|
|
if(keydown(KEY_SHIFT) || keydown(KEY_EXE)){
|
|
if(selection == PLAY){
|
|
play_game();
|
|
end();
|
|
waitkey(KEY_SHIFT);
|
|
waitkey(KEY_EXE);
|
|
selection = PLAY;
|
|
stat = 0;
|
|
}else if(selection == QUIT){
|
|
return 1;
|
|
}
|
|
waitkey(KEY_SHIFT);
|
|
waitkey(KEY_EXE);
|
|
}else if(keydown(KEY_UP)){
|
|
if(selection != 0){
|
|
selection--;
|
|
}else{
|
|
selection = MENU_MAX;
|
|
}
|
|
waitkey(KEY_UP);
|
|
}else if(keydown(KEY_DOWN)){
|
|
if(selection != MENU_MAX){
|
|
selection++;
|
|
}else{
|
|
selection = 0;
|
|
}
|
|
waitkey(KEY_DOWN);
|
|
}
|
|
dimage(0, 0, &title);
|
|
dupdate();
|
|
}
|
|
return 1;
|
|
}
|