xlib_playground

Xlib playground for experiments.
Log | Files | Refs

commit 8327a537703df651ba70e0a3e69d446bda5b238b
parent 9d1848f4cfb5963a20608b2499b1267313715e9d
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Thu, 29 Dec 2022 11:03:44 +0900

move world map to a separate file

Diffstat:
Mex7/ex7.c | 76++++++++--------------------------------------------------------------------
Aex7/world_map.h | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 68 deletions(-)

diff --git a/ex7/ex7.c b/ex7/ex7.c @@ -6,6 +6,7 @@ #include <math.h> #include "x.h" +#include "world_map.h" /* macros */ #define FPS (60) @@ -14,9 +15,6 @@ #define GRAVITY (1000) #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) -#define WORLD_WIDTH (80) -#define WORLD_HEIGHT (60) -#define BLOCK_SIZE (10) // #define COUNT_FPS @@ -58,68 +56,6 @@ struct circle { int m; }; -char world_map[WORLD_WIDTH * WORLD_HEIGHT + 1] = -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"........b......................................................................." -"................................................................................" -"................................................................................" -"....b..........................................................................." -"................................................................................" -"................b..............................................................." -"..........................................................b..........b.........." -"................................................................................" -".......................b........................................................" -"...........................................b...................................." -"...........................................b...................................." -"................................................................................" -"..................b............................................................." -"................................................................................" -"...........................................b...................................." -"................................................................................" -"................................................................................" -"...........................b...................................................." -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"....................................bbbbbbbbbb.................................." -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"..............................................bbbbbbbbbb........................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"....................................bbbbbbbbbb.................................." -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"..........................bbbbbbbbbb............................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................................................................................" -"................bbbbbbbbbb......................................................" -"................................................................................" -"................................................................................" -"...p............................................................................" -"bbbbbbbbbbbbbbbbbbbbbbbbb.......bbbbbbbbbbbbbbbbbbbbbbbb...bbbbbbbbbbbbbbbbbbbbb" -"........................b.......b......................b...b...................." -"........................b.......b......................b...b...................." -"........................b.......b......................b...b...................." -"........................b.......b......................b...b...................."; - /* variables */ struct rect block[NUM_RECT]; struct rect player; @@ -129,10 +65,15 @@ enum next_menu next_menu = START_MENU; /* function prototypes */ void cleanup(void); +/* menus */ void start_menu(void); void game_play(void); +void game_over(void); +/* events */ void receive_events(enum key_state[]); void handle_inputs(enum key_state[]); +void update_falling_status(struct rect *, long); +/* physics */ void rect_next_tick(struct rect *, long); int rect_test_collision(struct rect *, struct rect *); void rect_handle_collision_mf(struct rect *, struct rect *); @@ -140,8 +81,6 @@ void rect_handle_collision(struct rect *, struct rect *); void rect_handle_collision_elastic(struct rect *, struct rect *); void circle_next_tick(struct circle *, long); int circle_test_collision(struct circle *, struct circle *); -void update_falling_status(struct rect *, long); -void game_over(void); void start_menu(void) @@ -656,7 +595,8 @@ game_over(void) x_clear_area(); x_draw_string(0x00FFFF, - WORLD_WIDTH * BLOCK_SIZE/2 - 10 * strlen(menu_char)/2, WORLD_HEIGHT * BLOCK_SIZE/2, + WORLD_WIDTH * BLOCK_SIZE/2 - 10 * strlen(menu_char)/2, + WORLD_HEIGHT * BLOCK_SIZE/2, menu_char, strlen(menu_char)); x_flush(); diff --git a/ex7/world_map.h b/ex7/world_map.h @@ -0,0 +1,65 @@ +#define WORLD_WIDTH (80) +#define WORLD_HEIGHT (60) +#define BLOCK_SIZE (10) + +char world_map[WORLD_WIDTH * WORLD_HEIGHT + 1] = +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"........b......................................................................." +"................................................................................" +"................................................................................" +"....b..........................................................................." +"................................................................................" +"................b..............................................................." +"..........................................................b..........b.........." +"................................................................................" +".......................b........................................................" +"...........................................b...................................." +"...........................................b...................................." +"................................................................................" +"..................b............................................................." +"................................................................................" +"...........................................b...................................." +"................................................................................" +"................................................................................" +"...........................b...................................................." +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"....................................bbbbbbbbbb.................................." +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"..............................................bbbbbbbbbb........................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"....................................bbbbbbbbbb.................................." +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"..........................bbbbbbbbbb............................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................................................................................" +"................bbbbbbbbbb......................................................" +"................................................................................" +"................................................................................" +"...p............................................................................" +"bbbbbbbbbbbbbbbbbbbbbbbbb.......bbbbbbbbbbbbbbbbbbbbbbbb...bbbbbbbbbbbbbbbbbbbbb" +"........................b.......b......................b...b...................." +"........................b.......b......................b...b...................." +"........................b.......b......................b...b...................." +"........................b.......b......................b...b....................";