From 8a43c39405f2497bf3982b0d16620bf4cc685bd7 Mon Sep 17 00:00:00 2001 From: _N3m0 Date: Wed, 20 Mar 2024 11:57:31 +0100 Subject: [PATCH] add map --- data/map.aseprite | Bin 0 -> 412 bytes data/map.png | Bin 0 -> 204 bytes main.c | 60 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 data/map.aseprite create mode 100644 data/map.png diff --git a/data/map.aseprite b/data/map.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..c806460672c7fe17b1ac0ed0d0b1b02f7304e5e1 GIT binary patch literal 412 zcmbQk$iVPmDIyADL{+>3Ji=OK?VUJqy>-xn*Qq}3)of`pao(;%&q{o63MzO zAe)5&D5?NtC@Gk@YS^S%8uo`--!D|VxghP`;aR^wnaz9}khRaid`g~orhbsOijj?_ zy?u#6LQ{0!!{pijk44ofy`glX(f`w0XKXhIn+o zowk?nfC5L$#*e(#CNG&M8GPs|D=_@GWnv6FuesHoy += step; + break; + case SUD: + map->y -= step; + break; + case EST: + map->x -= step; + break; + case OUEST: + map->x += step; + break; + + case NORD_EST: + map->y += diag_step; + map->x -= diag_step; + break; + case NORD_OUEST: + map->y += diag_step; + map->x += diag_step; + break; + case SUD_EST: + map->y -= diag_step; + map->x -= diag_step; + break; + case SUD_OUEST: + map->y -= diag_step; + map->x += diag_step; + break; + } +} + int main(void) { SetTraceLogLevel(LOG_ERROR); @@ -137,9 +181,14 @@ int main(void) SetWindowState(FLAG_WINDOW_RESIZABLE); SetTargetFPS(60); - handle_resize_window(); - player = (Vec2i) {.x = screen.width/2, .y = screen.height/2}; + map = LoadTexture("data/map.png"); + map_coord = (Vector2){ + screen.width/2 - map.width*map_factor/2, + screen.height/2 - map.height*map_factor/2, + }; + + handle_resize_window(); while (!WindowShouldClose()) { BeginDrawing(); @@ -152,13 +201,12 @@ int main(void) if (!move_player_inside_trap(&player, trap, player_speed, DT)) { Cardinal direction = snap_player_inside_trap(&player, trap); -#ifndef RELEASE - printf("[%s]\n", cardinal_text[direction]); -#endif + move_map(&map_coord, direction, player_speed, DT); } + DrawTextureEx(map, map_coord, 0.0f, map_factor, WHITE); DrawCircle(player.x, player.y, player_radius, BLUE); - DrawRectangleLinesEx(trap, 1, RED); + // DrawRectangleLinesEx(trap, 1, RED); } EndDrawing(); }