Compare commits
3 Commits
fd9fd453b3
...
b842bd0095
| Author | SHA1 | Date | |
|---|---|---|---|
| b842bd0095 | |||
| bb28285794 | |||
| 6621decc09 |
@@ -113,6 +113,8 @@ void handle_event() {
|
||||
ALLEGRO_EVENT evnt;
|
||||
al_wait_for_event(event_queue, &evnt);
|
||||
|
||||
do
|
||||
{
|
||||
switch(evnt.type)
|
||||
{
|
||||
case ALLEGRO_EVENT_TIMER:
|
||||
@@ -136,6 +138,7 @@ void handle_event() {
|
||||
set_key(evnt.keyboard.keycode, 0);
|
||||
break;
|
||||
}
|
||||
} while(al_get_next_event(event_queue, &evnt));
|
||||
}
|
||||
|
||||
int key_is_down(int code) {
|
||||
|
||||
30
src/main.c
30
src/main.c
@@ -20,11 +20,6 @@
|
||||
#include "event_manager.h"
|
||||
#include "ship.h"
|
||||
|
||||
int run;
|
||||
int redraw;
|
||||
int show_help;
|
||||
int show_info;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
@@ -38,6 +33,7 @@ const char *help =
|
||||
"P - pause/unpause the simulation\n"
|
||||
"I - show/hide simulation information\n"
|
||||
"H - show/hide this help information\n"
|
||||
"F - toggle fullscreen\n"
|
||||
"Q/ESC - quit";
|
||||
|
||||
const char *info_format =
|
||||
@@ -49,6 +45,10 @@ const char *info_format =
|
||||
"velY: %f px/sec";
|
||||
|
||||
int main() {
|
||||
int run;
|
||||
int redraw;
|
||||
int show_help;
|
||||
int show_info;
|
||||
char title[32];
|
||||
sprintf(title, "SpaceShipSim v%s", VERSION);
|
||||
puts(title);
|
||||
@@ -107,6 +107,7 @@ int main() {
|
||||
show_info = 1;
|
||||
int paused = 0;
|
||||
int old_paused = 0;
|
||||
int just_toggled_fullscreen = 0;
|
||||
while(run)
|
||||
{
|
||||
handle_event();
|
||||
@@ -127,6 +128,23 @@ int main() {
|
||||
ship_update(&ship);
|
||||
}
|
||||
|
||||
if (key_is_down(KEY_FULLSCREEN) && !just_toggled_fullscreen)
|
||||
{
|
||||
if(al_get_display_flags(display) & ALLEGRO_FULLSCREEN_WINDOW)
|
||||
{
|
||||
al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, 1);
|
||||
}
|
||||
just_toggled_fullscreen = 1;
|
||||
}
|
||||
else if (!key_is_down(KEY_FULLSCREEN) && just_toggled_fullscreen)
|
||||
{
|
||||
just_toggled_fullscreen = 0;
|
||||
}
|
||||
|
||||
al_clear_to_color(al_map_rgb(0, 0, 0));
|
||||
ship_draw(&ship);
|
||||
if(show_info)
|
||||
@@ -148,7 +166,7 @@ int main() {
|
||||
{
|
||||
al_draw_multiline_text(font,
|
||||
al_map_rgb(0xFF, 0xFF, 0xFF),
|
||||
WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2 - 50,
|
||||
(float)WINDOW_WIDTH / 2, (float)WINDOW_HEIGHT / 2 - 50,
|
||||
WINDOW_WIDTH, 10.0f,
|
||||
ALLEGRO_ALIGN_CENTRE,
|
||||
help);
|
||||
|
||||
Reference in New Issue
Block a user