Make menus and level load work
parent
5b2027c57b
commit
f993c6b7ba
|
@ -146,6 +146,7 @@ bool collide_target(struct kinematic_obj *obj, struct target_obj *target);
|
||||||
//Menu
|
//Menu
|
||||||
void draw_menu();
|
void draw_menu();
|
||||||
void main_menu_check();
|
void main_menu_check();
|
||||||
|
int get_selected_options();
|
||||||
|
|
||||||
//Debug stuff, debug.c
|
//Debug stuff, debug.c
|
||||||
void state_string(char *str, enum PLAYER_STATE state);
|
void state_string(char *str, enum PLAYER_STATE state);
|
||||||
|
|
33
main.c
33
main.c
|
@ -33,7 +33,7 @@ int GRAV = 1000;
|
||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
void main_menu(Camera2D camera);
|
int main_menu(Camera2D camera);
|
||||||
void play_test_level(Camera2D camera);
|
void play_test_level(Camera2D camera);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -49,25 +49,36 @@ int main()
|
||||||
camera.offset = (Vector2){0,0};
|
camera.offset = (Vector2){0,0};
|
||||||
camera.rotation = 0.0f;
|
camera.rotation = 0.0f;
|
||||||
camera.zoom = 1.0f;
|
camera.zoom = 1.0f;
|
||||||
while (!WindowShouldClose())
|
while (!WindowShouldClose()){
|
||||||
//play_test_level(camera);
|
int selected = main_menu(camera);
|
||||||
main_menu(camera);
|
switch(selected){
|
||||||
CloseWindow(); // Close window and OpenGL context
|
case 0:
|
||||||
|
play_test_level(camera);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
goto quit;
|
||||||
|
default:
|
||||||
|
puts("Unknown Command");
|
||||||
|
goto quit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
quit: CloseWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main_menu(Camera2D camera){
|
||||||
void main_menu(Camera2D camera){
|
|
||||||
camera.target = (Vector2){0,0};
|
camera.target = (Vector2){0,0};
|
||||||
|
|
||||||
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
main_menu_check();
|
main_menu_check();
|
||||||
|
if (IsKeyPressed(KEY_SPACE)){
|
||||||
|
return get_selected_options();
|
||||||
|
}
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
draw_menu();
|
draw_menu();
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,11 +130,13 @@ void play_test_level(Camera2D camera){
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose() || IsKeyPressed(KEY_Q)) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyPressed(KEY_Q)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
player_input_check(&player);
|
player_input_check(&player);
|
||||||
|
|
||||||
update_squishy(&sqr);
|
update_squishy(&sqr);
|
||||||
|
|
|
@ -21,6 +21,10 @@ void main_menu_check(){
|
||||||
++option;
|
++option;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_selected_options(){
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
void draw_menu(){
|
void draw_menu(){
|
||||||
DrawFPS(0,0);
|
DrawFPS(0,0);
|
||||||
for(unsigned int i=0;i<2;++i){
|
for(unsigned int i=0;i<2;++i){
|
||||||
|
|
Loading…
Reference in New Issue