Update main.c

This commit is contained in:
Jason Bou-Samra
2024-10-09 20:02:37 +11:00
committed by GitHub
parent 3a63808b54
commit f525b5c0d7
+8 -44
View File
@@ -11,62 +11,26 @@
#include <sodium.h> #include <sodium.h>
#include <math.h> #include <math.h>
#include <stdint.h> #include <stdint.h>
#include "research.h"
#include "render.h" #include "render.h"
#include "column.h" #include "column.h"
#include "sdl.h" #include "sdl.h"
#include "events.h" #include "menu.h"
#include "hiscore.h"
///////////////// MAIN MENU //////////////////////////// //////////////// ABOUT ///////////////////////
int menu(void) { void about_fc() {
quit = false; printf("Fun Columns\nOriginal IIGS version: Olivier Goguel (FTA 1990/91)\nSDL version 1.0: Jason Bou-Samra\n");
Ren_menu();
while (quit == false) {
// SDL_Delay(20);
SDL_PollEvent(&event);
switch (event.type) {
case SDL_KEYDOWN:
if (event.key.keysym.sym == SDLK_q) {
quit = true; // quit
}
if (event.key.keysym.sym == SDLK_a) {
Ren_about(); // about
check_key();
Ren_menu();
}
if (event.key.keysym.sym == SDLK_i) {
Ren_info(); // info (instructions)
check_key();
Ren_menu();
}
if (event.key.keysym.sym > SDLK_0 && event.key.keysym.sym < SDLK_7) {
if (event.key.keysym.sym == SDLK_1) {speed = 1.0;}
if (event.key.keysym.sym == SDLK_2) {speed = 1.5;}
if (event.key.keysym.sym == SDLK_3) {speed = 2.0;}
if (event.key.keysym.sym == SDLK_4) {speed = 2.5;}
if (event.key.keysym.sym == SDLK_5) {speed = 3.0;}
if (event.key.keysym.sym == SDLK_6) {speed = 3.5;}
handle_events(); // game levels
end_game();
Ren_menu();
}
}
}
} }
///////////////////// MAIN ROUTINE ///////////////////////// ///////////////////// MAIN ROUTINE /////////////////////////
int main(void) { int main(void) {
about_fc();
if (sodium_init() < 0) { // initialise sodium if (sodium_init() < 0) { // initialise sodium
printf("error\n"); // -1 = failure printf("error\n"); // -1 = failure
} }
initSDL(); initSDL(); // init. SDL subsystem
init_gfx(); init_gfx(); // sprite map
next_brick(); menu(); // main menu
initial_brick();
col = new_column();
menu();
shutdownSDL(); shutdownSDL();
return 0; return 0;
} }