diff options
| author | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-11-04 16:48:51 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrik@amftech.nl> | 2023-11-04 16:48:51 +0100 |
| commit | c162e010ae85c636131ff59e8d810be4e9960caa (patch) | |
| tree | 03d2e88a7fdb7730b54eb4524abf436c098b8249 | |
| parent | 88e4037c0b526e33cd03f0b62783b198d8585768 (diff) | |
throwables ui
| -rw-r--r-- | build/data/imgs/icons/grenade.png | bin | 0 -> 3336 bytes | |||
| -rw-r--r-- | build/data/imgs/icons/molotov.png | bin | 0 -> 2109 bytes | |||
| -rw-r--r-- | build/zombies.exe | bin | 1997811 -> 1999947 bytes | |||
| -rw-r--r-- | data/imgs/icons/grenade.png | bin | 0 -> 3336 bytes | |||
| -rw-r--r-- | data/imgs/icons/molotov.png | bin | 0 -> 2109 bytes | |||
| -rw-r--r-- | include/asset_defs.h | 3 | ||||
| -rw-r--r-- | include/players.h | 4 | ||||
| -rw-r--r-- | include/throwables.h | 1 | ||||
| -rw-r--r-- | main.c | 1 | ||||
| -rw-r--r-- | src/asset_defs.c | 3 | ||||
| -rw-r--r-- | src/game.c | 2 | ||||
| -rw-r--r-- | src/guns.c | 1 | ||||
| -rw-r--r-- | src/overlay.c | 39 | ||||
| -rw-r--r-- | src/players.c | 2 |
14 files changed, 47 insertions, 9 deletions
diff --git a/build/data/imgs/icons/grenade.png b/build/data/imgs/icons/grenade.png Binary files differnew file mode 100644 index 0000000..3253924 --- /dev/null +++ b/build/data/imgs/icons/grenade.png diff --git a/build/data/imgs/icons/molotov.png b/build/data/imgs/icons/molotov.png Binary files differnew file mode 100644 index 0000000..9f94000 --- /dev/null +++ b/build/data/imgs/icons/molotov.png diff --git a/build/zombies.exe b/build/zombies.exe Binary files differindex af07907..b5f879c 100644 --- a/build/zombies.exe +++ b/build/zombies.exe diff --git a/data/imgs/icons/grenade.png b/data/imgs/icons/grenade.png Binary files differnew file mode 100644 index 0000000..3253924 --- /dev/null +++ b/data/imgs/icons/grenade.png diff --git a/data/imgs/icons/molotov.png b/data/imgs/icons/molotov.png Binary files differnew file mode 100644 index 0000000..9f94000 --- /dev/null +++ b/data/imgs/icons/molotov.png diff --git a/include/asset_defs.h b/include/asset_defs.h index 0fc0f92..cdf9614 100644 --- a/include/asset_defs.h +++ b/include/asset_defs.h @@ -3,6 +3,7 @@ #include <projectbase/project_base.h> +font* fnt_32; font* fnt_24; font* fnt_20; @@ -17,6 +18,8 @@ image* img_3d; image* img_tiles; image* img_sunny; image* img_disconnected; +image* img_icon_grenade; +image* img_icon_molotov; // Objects image* img_spawner; diff --git a/include/players.h b/include/players.h index 0c7433e..d34f83a 100644 --- a/include/players.h +++ b/include/players.h @@ -51,6 +51,10 @@ typedef struct t_player { sprite sprite; vec3f velocity; network_state connection_state; + struct { + int grenades; + int molotovs; + } throwables; } player; #include "protocol.h" diff --git a/include/throwables.h b/include/throwables.h index 5e49c16..4053826 100644 --- a/include/throwables.h +++ b/include/throwables.h @@ -12,6 +12,7 @@ typedef enum t_throwable_type { THROWABLE_NONE = 0, THROWABLE_GRENADE, + THROWABLE_MOLOTOV, } throwable_type; typedef enum t_throwable_state @@ -1,5 +1,6 @@ #define ASSET_IMAGE_COUNT 50 #define ASSET_QUEUE_COUNT 50 +#define ASSET_FONT_COUNT 10 #include <projectbase/project_base.h> diff --git a/src/asset_defs.c b/src/asset_defs.c index c4e229f..15a948a 100644 --- a/src/asset_defs.c +++ b/src/asset_defs.c @@ -1,6 +1,7 @@ #include "../include/asset_defs.h" void load_assets() { + fnt_32 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 32); fnt_24 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 24); fnt_20 = assets_load_font(noto_regular_ttf, noto_regular_ttf+noto_regular_ttf_len, 20); @@ -15,6 +16,8 @@ void load_assets() { img_tiles = assets_load_image_from_file("data/imgs/icons/tiles.png"); img_sunny = assets_load_image_from_file("data/imgs/icons/sunny.png"); img_disconnected = assets_load_image_from_file("data/imgs/icons/disconnected.png"); + img_icon_grenade = assets_load_image_from_file("data/imgs/icons/grenade.png"); + img_icon_molotov = assets_load_image_from_file("data/imgs/icons/molotov.png"); // Throwables img_grenade = assets_load_image_from_file("data/imgs/throwables/grenade.png"); @@ -358,8 +358,6 @@ static void move_camera(platform_window* window) { _camera_buffer.y += diry*speedy; _global_camera.x = (int)_camera_buffer.x; _global_camera.y = (int)_camera_buffer.y; - //_global_camera.x = _next_camera_pos.x; - //_global_camera.y = _next_camera_pos.y; } void update_game(platform_window* window) { @@ -9,6 +9,7 @@ image* get_image_of_gun(gun_type type) { switch (type) { case GUN_NOVA: return img_icon_nova; break; + case GUN_MP5: return img_icon_nova; break; default: break; diff --git a/src/overlay.c b/src/overlay.c index 6388d5b..485373b 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -11,16 +11,41 @@ static void draw_gun_info(platform_window* window) { gun g = get_gun_by_type(p->guntype); - - int y = window->height - fnt_24->px_h - EDGE_PADDING; + int y = window->height - fnt_32->px_h - EDGE_PADDING; int x = EDGE_PADDING; + int icon_h = 26; + + { // Ammo + char ammo_txt[50]; + sprintf(ammo_txt, "%d/%d", p->ammo_in_mag, p->total_ammo); + renderer->render_text(fnt_32, _global_camera.x + x+1, _global_camera.y + y+1, ammo_txt, rgba(0,0,0,120)); + renderer->render_text(fnt_32, _global_camera.x + x, _global_camera.y + y, ammo_txt, rgb(255,255,255)); + } - renderer->render_text(fnt_24, (int)_global_camera.x + x, (int)_global_camera.y + y, g.name, rgb(255,255,255)); - y -= fnt_24->px_h; + y -= icon_h + 5; + + { // Throwables + int offset_x = 0; + for (int i = 0; i < p->throwables.grenades; i++) + { + renderer->render_image_tint(img_icon_grenade, _global_camera.x + x-1 + offset_x, _global_camera.y + y-1, icon_h, icon_h, rgba(0,0,0,100)); + renderer->render_image(img_icon_grenade, _global_camera.x + x + offset_x, _global_camera.y + y, icon_h, icon_h); + + offset_x += icon_h/3; + } + + y -= icon_h + 5; + + offset_x = 0; + for (int i = 0; i < p->throwables.molotovs; i++) + { + renderer->render_image_tint(img_icon_molotov, _global_camera.x + x-1 + offset_x, _global_camera.y + y-1, icon_h, icon_h, rgba(0,0,0,100)); + renderer->render_image(img_icon_molotov, _global_camera.x + x + offset_x, _global_camera.y + y, icon_h, icon_h); + + offset_x += icon_h/3; + } + } - char ammo_txt[50]; - sprintf(ammo_txt, "%d / %d", p->ammo_in_mag, p->total_ammo); - renderer->render_text(fnt_20, (int)_global_camera.x + x, (int)_global_camera.y + y, ammo_txt, rgb(255,255,255)); } static void draw_leaderboard_entry(int x, int y, int w, int h, char* name, char* kills, char* deaths, char* ping, bool highlighted, bool disconnected) { diff --git a/src/players.c b/src/players.c index f62f53e..3e657a0 100644 --- a/src/players.c +++ b/src/players.c @@ -61,6 +61,8 @@ void spawn_player(u32 id, network_client client) { players[i].sprite = create_sprite(img_player_running, 22, 108, 136, 0.02f); players[i].direction = DIRECTION_DOWN; players[i].connection_state = CONNECTED; + players[i].throwables.grenades = 3; + players[i].throwables.molotovs = 1; gun g = get_gun_by_type(players[i].guntype); players[i].total_ammo = g.max_ammunition; |
