Bläddra i källkod

Trace weapon ammo

The magazines for each weapon except the rifles have been drawn.
feature/data-structs
TheoryOfNekomata 2 år sedan
förälder
incheckning
63021f04d1
6 ändrade filer med 88 tillägg och 6 borttagningar
  1. +27
    -0
      CMakeLists.txt
  2. Binär
      assets/gfx/weapons-rigged.cdr
  3. +26
    -1
      src/packages/game/IZ_app_video.c
  4. +1
    -0
      src/packages/game/IZ_app_video.h
  5. +5
    -1
      src/packages/game/output/video/IZ_video.c
  6. +29
    -4
      src/packages/game/output/video/IZ_video.h

+ 27
- 0
CMakeLists.txt Visa fil

@@ -6,6 +6,7 @@ project(izanagi C)
set(CMAKE_C_STANDARD 11)

if (WIN32)
# TODO set arch on target instead of generator
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PROJECT_ARCH x64)
else ()
@@ -26,6 +27,8 @@ endif()

include_directories(
"${PROJECT_SOURCE_DIR}/dependencies/SDL2/include"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/include"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/include"
"${PROJECT_SOURCE_DIR}/dependencies/minIni/dev"
"${PROJECT_SOURCE_DIR}/dependencies/bdd-for-c"
"${PROJECT_SOURCE_DIR}/dependencies/portmidi/pm_common"
@@ -38,6 +41,8 @@ include_directories(

link_directories(
"${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}"
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}"
"${PROJECT_SOURCE_DIR}/dependencies/portmidi/Release"
"${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/lib/Release"
"${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/lib"
@@ -96,6 +101,8 @@ target_link_libraries(
game
SDL2main
SDL2
SDL2_image
SDL2_ttf
portmidi
libcrypto
libssl
@@ -229,6 +236,16 @@ if (WIN32)
"${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll" # <--this is in-file
$<TARGET_FILE_DIR:game>) # <--this is out-file path

add_custom_command(TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_image/lib/${PROJECT_ARCH}/SDL2_image.dll" # <--this is in-file
$<TARGET_FILE_DIR:game>) # <--this is out-file path

add_custom_command(TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${PROJECT_SOURCE_DIR}/dependencies/SDL2_ttf/lib/${PROJECT_ARCH}/SDL2_ttf.dll" # <--this is in-file
$<TARGET_FILE_DIR:game>) # <--this is out-file path

add_custom_command(TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${PROJECT_SOURCE_DIR}/dependencies/portmidi/Release/portmidi.dll" # <--this is in-file
@@ -249,6 +266,11 @@ if (WIN32)
"${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll" # <--this is in-file
$<TARGET_FILE_DIR:game>) # <--this is out-file path

add_custom_command(TARGET server POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${PROJECT_SOURCE_DIR}/dependencies/SDL2/lib/${PROJECT_ARCH}/SDL2.dll" # <--this is in-file
$<TARGET_FILE_DIR:server>) # <--this is out-file path

add_custom_command(TARGET server POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E copy_if_different..."
"${PROJECT_SOURCE_DIR}/dependencies/libwebsockets/build/bin/Release/websockets.dll" # <--this is in-file
@@ -264,3 +286,8 @@ if (WIN32)
"${PROJECT_SOURCE_DIR}/dependencies/openssl/${PROJECT_ARCH}/bin/libcrypto-1_1-x64.dll" # <--this is in-file
$<TARGET_FILE_DIR:server>) # <--this is out-file path
endif ()

add_custom_command(TARGET game POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory # which executes "cmake - E copy_if_different..."
"${PROJECT_SOURCE_DIR}/assets" # <--this is in-file
$<TARGET_FILE_DIR:game>/assets) # <--this is out-file path

Binär
assets/gfx/weapons-rigged.cdr Visa fil


+ 26
- 1
src/packages/game/IZ_app_video.c Visa fil

@@ -114,13 +114,38 @@ void IZ_VideoUpdate(IZ_VideoState* video_state) {
// Update window
SDL_SetRenderDrawColor(video_state->renderer, 0x00, 0x00, 0x00, 0xff);
SDL_RenderClear(video_state->renderer);
u8 sprite_index;
u16 sprite_index;
for (sprite_index = 0; sprite_index < MAX_ACTIVE_SPRITES; sprite_index += 1) {
if (!video_state->active_sprites[sprite_index]) {
continue;
}
// TODO draw sprites
}

FILE* f = fopen("assets/gfx/beretta-test.svg", "r");
static const u16 sprite_length_bytes = 15316 + 1;
static const f32 sprite_size = 271.25f;
u8 sprite[sprite_length_bytes] = "";
fread(sprite, 1, sprite_length_bytes, f);
SDL_SetRenderDrawBlendMode(video_state->renderer, SDL_BLENDMODE_ADD);
SDL_Surface* test_surface = IMG_LoadSVG_RW(SDL_RWFromConstMem(sprite, sprite_length_bytes));
if (test_surface) {
SDL_Texture* test_texture = SDL_CreateTextureFromSurface(video_state->renderer, test_surface);
SDL_RenderCopyExF(video_state->renderer, test_texture, NULL, &(SDL_FRect) {
.x = 0,
.y = 0,
.w = sprite_size,
.h = sprite_size,
}, 180, &(SDL_FPoint) {
.x = sprite_size / 2,
.y = sprite_size / 2,
}, SDL_FLIP_NONE);
SDL_DestroyTexture(test_texture);
// our goal is to render the svg files and apply custom transforms to some SVG groups if ever.
// TODO perhaps we can parse the SVG for easier transforms?
}
SDL_FreeSurface(test_surface);

IZ_VideoUpdateForDebugTicks(video_state, ticks);
IZ_VideoUpdateForDebugInput(video_state, input_state);
IZ_VideoUpdateForDebugNet(video_state, net_state);


+ 1
- 0
src/packages/game/IZ_app_video.h Visa fil

@@ -1,6 +1,7 @@
#ifndef IZ_APP_VIDEO_H
#define IZ_APP_VIDEO_H

#include <math.h>
#include "output/video/IZ_video.h"
#include "IZ_subsystem.h"



+ 5
- 1
src/packages/game/output/video/IZ_video.c Visa fil

@@ -87,10 +87,14 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState* state, void* user_data, con
}
state->window = window;
state->renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

return 0;
}

void IZ_VideoTeardown(IZ_VideoState* state) {
SDL_DestroyWindow(state->window);
}

void IZ_VideoLoadTexture(IZ_VideoState* state, const char* path, SDL_Texture** out) {
out = NULL;

}

+ 29
- 4
src/packages/game/output/video/IZ_video.h Visa fil

@@ -4,16 +4,38 @@
#include <stdio.h>
#include "minIni.h"
#include "SDL_render.h"
#include <SDL_image.h>

#include "../../../net/IZ_net_client.h"
#include "../../../config/IZ_config.h"
#include "../../input/IZ_input.h"
#include "../../../common/IZ_common.h"
#include "../../input/IZ_input.h"

#define MAX_ACTIVE_SPRITES 512u

#define MAX_ACTIVE_SPRITES 32
typedef enum {
// eyecandy, e.g. sparks
IZ_VIDEO_SPRITE_PRIORITY_LOWEST,
// bottom backgrounds
IZ_VIDEO_SPRITE_PRIORITY_LOWER,
// top backgrounds
IZ_VIDEO_SPRITE_PRIORITY_LOW,
// projectiles
IZ_VIDEO_SPRITE_PRIORITY_MEDIUM,
// foreground objects
IZ_VIDEO_SPRITE_PRIORITY_HIGH,
// pickups
IZ_VIDEO_SPRITE_PRIORITY_HIGHER,
// player, enemies, weapons
IZ_VIDEO_SPRITE_PRIORITY_HIGHEST,
} IZ_VideoSpritePriority;

// TODO properly define sprites
typedef char IZ_Sprite;
typedef struct {
SDL_Texture* texture;
f32 scale_factor;
f32 rotate_degrees;
} IZ_Sprite;

typedef struct {
u16 width;
@@ -27,7 +49,7 @@ typedef struct {
u64 last_update_at;
SDL_Window* window;
SDL_Renderer* renderer;
IZ_Sprite active_sprites[MAX_ACTIVE_SPRITES];
IZ_Sprite* active_sprites[MAX_ACTIVE_SPRITES];
} IZ_VideoState;

static const IZ_VideoState IZ_VIDEO_DEFAULT_STATE = {
@@ -47,6 +69,9 @@ IZ_ProcedureResult IZ_VideoInitialize(IZ_VideoState*, void*, const char*, u8, co

IZ_ProcedureResult IZ_VideoSaveConfig(IZ_VideoState*, const char*);

// TODO implement
void IZ_VideoLoadTexture(IZ_VideoState*, const char*, SDL_Texture**);

void IZ_VideoTeardown(IZ_VideoState*);

#endif

Laddar…
Avbryt
Spara