xlib_playground

Xlib playground for experiments.
Log | Files | Refs

commit bcbc8858ab29cda780143eceeeda5875e1ff8027
parent 800429750907d7f1041a9af4199bc2ae6d45969b
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri, 23 Dec 2022 13:29:18 +0900

add game over screen

Diffstat:
Mex3/ex3.c | 21+++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/ex3/ex3.c b/ex3/ex3.c @@ -53,8 +53,8 @@ void setup(void); void cleanup(void); void start_menu(void); void game_play(void); -void receive_events(int *); -void handle_inputs(int *); +void receive_events(int[]); +void handle_inputs(int[]); void next_tick(long); void game_over(void); @@ -81,7 +81,7 @@ setup(void) XSetWMProtocols(display, window, &wm_delete_window, 1); XSelectInput(display, window, - ExposureMask|KeyPressMask|KeyReleaseMask); + ExposureMask | KeyPressMask | KeyReleaseMask); XSetForeground(display, gc, 0x00FFFF); XMapWindow(display, window); @@ -262,7 +262,7 @@ game_play(void) // fix fps // TODO: This method create some strange stripe when - // rendered in 60fps monitor. + // rendered in 60fps on a 60fps monitor. dt = 0; while (dt < 1.0 * 1000 * 1000 * 1000 / FPS){ clock_gettime(CLOCK_MONOTONIC, &ts); @@ -296,6 +296,19 @@ game_play(void) void game_over(void) { + XEvent event; + char *menu_char = "GAME OVER"; + + XClearArea(display, window, + 0, 0, // position + win_width, win_height, // width and height + False); + XDrawString(display, window, gc, + win_width/2 - strlen(menu_char)/2, win_height/2, + menu_char, strlen(menu_char)); + XFlush(display); + + sleep(1); next_menu = START_MENU; }