2022-06-24 20:01:40 +02:00
|
|
|
# include <gint/display.h>
|
|
|
|
# include <gint/keyboard.h>
|
|
|
|
# include <stdlib.h>
|
|
|
|
# include <time.h>
|
|
|
|
# include "msg_fr.h"
|
|
|
|
# include "itemsizes.h"
|
|
|
|
# include "gamesettings.h"
|
|
|
|
# include "worldgen.h"
|
2022-06-23 18:36:15 +02:00
|
|
|
|
|
|
|
extern bopti_image_t title_img;
|
|
|
|
|
|
|
|
void drawselectedgame(int selected) {
|
|
|
|
dclear(C_WHITE);
|
|
|
|
// dimage(16, 8, &title_img);
|
|
|
|
for(int i=0;i!=GAMESNUM;i++){
|
2022-06-24 20:01:40 +02:00
|
|
|
dtext(1, WORLDSEL_MARGIN + i*(LINEHEIGHT), C_BLACK, WORLDSEL_EMPTY);
|
2022-06-23 18:36:15 +02:00
|
|
|
}
|
2022-06-24 20:01:40 +02:00
|
|
|
drect(1, WORLDSEL_MARGIN+selected*(LINEHEIGHT)-(int)(LINEPADDING/2), 128, WORLDSEL_MARGIN+(selected+1)*(LINEHEIGHT)-(int)(LINEPADDING/2), C_INVERT);
|
2022-06-23 18:36:15 +02:00
|
|
|
dupdate();
|
|
|
|
}
|
|
|
|
int main(void) {
|
|
|
|
dclear(C_WHITE);
|
|
|
|
dimage(16, TITLE_IMAGE_MARGIN, &title_img);
|
|
|
|
dtext(1, TITLE_MARGIN, C_BLACK, TITLE_START);
|
|
|
|
dupdate();
|
2022-06-24 20:01:40 +02:00
|
|
|
int key = 0, game = 0, selected = 0, i;
|
2022-06-23 18:36:15 +02:00
|
|
|
while(key != KEY_EXIT){
|
|
|
|
key=getkey().key;
|
|
|
|
////////// TITLE SCREEN //////////
|
|
|
|
if(game == 0){
|
|
|
|
if(key==KEY_EXE){
|
|
|
|
drawselectedgame(selected);
|
|
|
|
game = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
////////// GAME CHOOSING SCREEN //////////
|
|
|
|
else if(game == 1){
|
|
|
|
if(key==KEY_DOWN){
|
|
|
|
if(selected<GAMESNUM - 1){
|
|
|
|
selected++;
|
|
|
|
}else{
|
|
|
|
selected = 0;
|
|
|
|
}
|
|
|
|
drawselectedgame(selected);
|
|
|
|
}else if(key==KEY_UP){
|
|
|
|
if(selected>0){
|
|
|
|
selected--;
|
|
|
|
}else{
|
|
|
|
selected = GAMESNUM - 1;
|
|
|
|
}
|
|
|
|
drawselectedgame(selected);
|
|
|
|
}else if(key==KEY_EXE){
|
|
|
|
dclear(C_WHITE);
|
|
|
|
game = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
}else if(game == 2){
|
2022-06-24 20:01:40 +02:00
|
|
|
unsigned short terrain[WORLD_WIDTH*WORLD_HEIGHT];
|
|
|
|
for(i=0;i!=WORLD_WIDTH*WORLD_HEIGHT;i++){
|
|
|
|
terrain[i] = 0;
|
|
|
|
}
|
|
|
|
srand(clock());
|
|
|
|
generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)rand() % 2, WORLD_HEIGHT - 20, WORLD_HEIGHT - 2, 0, 1);
|
|
|
|
srand(clock());
|
|
|
|
generateworld(terrain, WORLD_WIDTH, WORLD_HEIGHT, (int)rand() % 2, WORLD_HEIGHT - 35, WORLD_HEIGHT - 16, 3, 2);
|
|
|
|
game = 3;
|
|
|
|
}else if(game == 3){
|
|
|
|
dclear(C_WHITE);
|
2022-06-23 18:36:15 +02:00
|
|
|
dupdate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|