Merge remote-tracking branch 'origin'
BIN
assets/npc_front_base_black.png
Normal file
|
After Width: | Height: | Size: 732 B |
BIN
assets/npc_front_base_white.png
Normal file
|
After Width: | Height: | Size: 737 B |
BIN
assets/npc_front_eyes_blue.png
Normal file
|
After Width: | Height: | Size: 232 B |
BIN
assets/npc_front_eyes_brown.png
Normal file
|
After Width: | Height: | Size: 207 B |
BIN
assets/npc_front_eyes_closed.png
Normal file
|
After Width: | Height: | Size: 127 B |
BIN
assets/npc_front_eyes_green.png
Normal file
|
After Width: | Height: | Size: 217 B |
BIN
assets/npc_front_face_glasses.png
Normal file
|
After Width: | Height: | Size: 157 B |
BIN
assets/npc_front_face_moustache.png
Normal file
|
After Width: | Height: | Size: 191 B |
BIN
assets/npc_front_face_redMask.png
Normal file
|
After Width: | Height: | Size: 227 B |
BIN
assets/npc_front_face_whiteMask.png
Normal file
|
After Width: | Height: | Size: 186 B |
BIN
assets/npc_front_hair_blonde.png
Normal file
|
After Width: | Height: | Size: 393 B |
BIN
assets/npc_front_hair_brown.png
Normal file
|
After Width: | Height: | Size: 334 B |
BIN
assets/npc_front_hair_grey.png
Normal file
|
After Width: | Height: | Size: 191 B |
BIN
assets/npc_front_hat_brown.png
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
assets/npc_front_hat_white.png
Normal file
|
After Width: | Height: | Size: 300 B |
BIN
assets/npc_front_shirt_brown.png
Normal file
|
After Width: | Height: | Size: 528 B |
BIN
assets/npc_front_shirt_white.png
Normal file
|
After Width: | Height: | Size: 479 B |
BIN
assets/npc_front_shoes_brown.png
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
assets/npc_front_trousers_blue.png
Normal file
|
After Width: | Height: | Size: 361 B |
BIN
assets/npc_front_trousers_white.png
Normal file
|
After Width: | Height: | Size: 354 B |
BIN
assets/outside_ambience.wav
Normal file
@@ -29,6 +29,20 @@ Str8 Str8_WrapZ(U8 *data) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FNV_OFFSET_BIAS ((U64) 0xCBF29CE484222325)
|
||||||
|
#define FNV_PRIME ((U64) 0x100000001B3)
|
||||||
|
|
||||||
|
U64 Str8_Hash(Str8 v) {
|
||||||
|
U64 result = FNV_OFFSET_BIAS;
|
||||||
|
|
||||||
|
for (S64 it = 0; it < v.count; ++it) {
|
||||||
|
result ^= v.data[it];
|
||||||
|
result *= FNV_PRIME;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Str8 Str8_Copy(M_Arena *arena, Str8 s) {
|
Str8 Str8_Copy(M_Arena *arena, Str8 s) {
|
||||||
Str8 result;
|
Str8 result;
|
||||||
result.count = s.count;
|
result.count = s.count;
|
||||||
|
|||||||
@@ -36,6 +36,11 @@
|
|||||||
#define SLL_PopN(h, next) (((h) != 0) ? (h) = (h)->next : 0)
|
#define SLL_PopN(h, next) (((h) != 0) ? (h) = (h)->next : 0)
|
||||||
|
|
||||||
#define SLL_Enqueue(h, t, n) SLL_EnqueueN(h, t, n, next)
|
#define SLL_Enqueue(h, t, n) SLL_EnqueueN(h, t, n, next)
|
||||||
|
#define SLL_EnqueueFront(h, t, n) SLL_EnqueueFrontN(h, t, n, next)
|
||||||
|
#define SLL_Dequeue(h, t) SLL_DequeueN(h, t, next)
|
||||||
|
|
||||||
|
#define SLL_Push(h, n) SLL_PushN(h, n, next)
|
||||||
|
#define SLL_Pop(h) (((h) != 0) ? (h) = (h)->next : 0)
|
||||||
|
|
||||||
#define function static
|
#define function static
|
||||||
#define internal static
|
#define internal static
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ function Str8 Str8_Wrap(S64 count, U8 *data);
|
|||||||
function Str8 Str8_WrapRange(U8 *start, U8 *end);
|
function Str8 Str8_WrapRange(U8 *start, U8 *end);
|
||||||
function Str8 Str8_WrapZ(U8 *data);
|
function Str8 Str8_WrapZ(U8 *data);
|
||||||
|
|
||||||
|
function U64 Str8_Hash(Str8 v);
|
||||||
|
|
||||||
function Str8 Str8_Copy(M_Arena *arena, Str8 s);
|
function Str8 Str8_Copy(M_Arena *arena, Str8 s);
|
||||||
|
|
||||||
function Str8 Str8_Format(M_Arena *arena, const char *format, ...);
|
function Str8 Str8_Format(M_Arena *arena, const char *format, ...);
|
||||||
|
|||||||
@@ -1,3 +1,59 @@
|
|||||||
|
|
||||||
|
U32 D_ImageHandle(D_Context *draw, Str8 name) {
|
||||||
|
U32 result = 0;
|
||||||
|
|
||||||
|
U64 hash = Str8_Hash(name);
|
||||||
|
U64 index = hash & (D_ASSET_HASH_COUNT - 1);
|
||||||
|
|
||||||
|
D_AssetHash *lookup = draw->lookup[index];
|
||||||
|
while (lookup != 0) {
|
||||||
|
if (lookup->hash == hash && Str8_Equal(lookup->value, name, 0)) {
|
||||||
|
result = lookup->id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lookup = lookup->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void D_AnimationInit(D_Animation *a, U32 id, U32 rows, U32 cols, F32 time) {
|
||||||
|
a->id = id;
|
||||||
|
|
||||||
|
a->rows = rows;
|
||||||
|
a->cols = cols;
|
||||||
|
|
||||||
|
a->time = 0;
|
||||||
|
a->frame_time = time;
|
||||||
|
|
||||||
|
a->frame = V2F(1.0f / (F32) cols, 1.0f / (F32) rows);
|
||||||
|
|
||||||
|
a->index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
R2f D_AnimationFrame(D_Animation *a) {
|
||||||
|
R2f result = { 0 };
|
||||||
|
|
||||||
|
U32 row = a->index / a->cols;
|
||||||
|
U32 col = a->index % a->cols;
|
||||||
|
|
||||||
|
result.min = V2F(a->frame.w * col, a->frame.h * row);
|
||||||
|
result.max = V2F(result.min.x + a->frame.w, result.min.y + a->frame.h);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void D_AnimationUpdate(D_Animation *a, F32 dt) {
|
||||||
|
a->time += dt;
|
||||||
|
if (a->time >= a->frame_time) {
|
||||||
|
a->time = 0;
|
||||||
|
a->index += 1;
|
||||||
|
|
||||||
|
if (a->index >= (a->rows * a->cols)) { a->index = 0; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void D_Begin(D_Context *draw, Vk_Frame *frame, U32 max_rects) {
|
void D_Begin(D_Context *draw, Vk_Frame *frame, U32 max_rects) {
|
||||||
Vk_Buffer *rbo = &frame->rbo;
|
Vk_Buffer *rbo = &frame->rbo;
|
||||||
|
|
||||||
@@ -127,14 +183,19 @@ void _D_Rect(D_Context *draw, D_RectOpts *opts) {
|
|||||||
else {
|
else {
|
||||||
Vk_Image *image = &draw->images[opts->texture].image;
|
Vk_Image *image = &draw->images[opts->texture].image;
|
||||||
|
|
||||||
if (image->width > image->height) {
|
F32 width = cast(F32) image->width;
|
||||||
rect->w = opts->scale * ((F32) image->width / (F32) image->height);
|
F32 height = cast(F32) image->height;
|
||||||
rect->h = opts->scale;
|
|
||||||
}
|
if (opts->flags & D_RECT_UV_ASPECT) {
|
||||||
else {
|
width *= (opts->uv.max.x - opts->uv.min.x);
|
||||||
rect->w = opts->scale;
|
height *= (opts->uv.max.y - opts->uv.min.y);
|
||||||
rect->h = opts->scale * ((F32) image->height / (F32) image->width);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
F32 aspect_w = (width > height) ? (width / height) : 1.0f;
|
||||||
|
F32 aspect_h = (width > height) ? 1.0f : (height / width);
|
||||||
|
|
||||||
|
rect->w = opts->scale * aspect_w;
|
||||||
|
rect->h = opts->scale * aspect_h;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw->n_rects += 1;
|
draw->n_rects += 1;
|
||||||
|
|||||||
@@ -48,8 +48,33 @@ struct D_Rect {
|
|||||||
|
|
||||||
StaticAssert(sizeof(D_Rect) == 64);
|
StaticAssert(sizeof(D_Rect) == 64);
|
||||||
|
|
||||||
|
typedef struct D_Animation D_Animation;
|
||||||
|
struct D_Animation {
|
||||||
|
U32 id;
|
||||||
|
|
||||||
|
U32 rows;
|
||||||
|
U32 cols;
|
||||||
|
F32 frame_time;
|
||||||
|
F32 time;
|
||||||
|
|
||||||
|
V2f frame; // size of one frame
|
||||||
|
|
||||||
|
U32 index;
|
||||||
|
};
|
||||||
|
|
||||||
struct G_Camera;
|
struct G_Camera;
|
||||||
|
|
||||||
|
#define D_ASSET_HASH_COUNT 128
|
||||||
|
|
||||||
|
typedef struct D_AssetHash D_AssetHash;
|
||||||
|
struct D_AssetHash {
|
||||||
|
D_AssetHash *next;
|
||||||
|
|
||||||
|
Str8 value;
|
||||||
|
U64 hash;
|
||||||
|
U32 id; // texture id
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct D_Context D_Context;
|
typedef struct D_Context D_Context;
|
||||||
struct D_Context {
|
struct D_Context {
|
||||||
Vk_Buffer *rbo;
|
Vk_Buffer *rbo;
|
||||||
@@ -73,6 +98,8 @@ struct D_Context {
|
|||||||
U32 window_width;
|
U32 window_width;
|
||||||
U32 window_height;
|
U32 window_height;
|
||||||
|
|
||||||
|
D_AssetHash *lookup[D_ASSET_HASH_COUNT];
|
||||||
|
|
||||||
struct G_Camera *camera;
|
struct G_Camera *camera;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -80,6 +107,7 @@ typedef U32 D_RectFlags;
|
|||||||
enum D_RectFlags {
|
enum D_RectFlags {
|
||||||
D_RECT_IGNORE_ASPECT = (1 << 0), // by default only width is used as a "dimension"
|
D_RECT_IGNORE_ASPECT = (1 << 0), // by default only width is used as a "dimension"
|
||||||
D_RECT_PER_VERTEX_COLOUR = (1 << 1), // split colours per vertex
|
D_RECT_PER_VERTEX_COLOUR = (1 << 1), // split colours per vertex
|
||||||
|
D_RECT_UV_ASPECT = (1 << 2), // get the aspect from the uv rect rather than the full image
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct D_RectOpts D_RectOpts;
|
typedef struct D_RectOpts D_RectOpts;
|
||||||
@@ -111,6 +139,12 @@ struct D_RectOpts {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function U32 D_ImageHandle(D_Context *draw, Str8 name);
|
||||||
|
|
||||||
|
function void D_AnimationInit(D_Animation *a, U32 id, U32 rows, U32 cols, F32 time);
|
||||||
|
function R2f D_AnimationFrame(D_Animation *a);
|
||||||
|
function void D_AnimationUpdate(D_Animation *a, F32 dt);
|
||||||
|
|
||||||
function void D_Begin(D_Context *draw, Vk_Frame *frame, U32 max_rects);
|
function void D_Begin(D_Context *draw, Vk_Frame *frame, U32 max_rects);
|
||||||
function void D_End(D_Context *draw, Vk_Frame *frame);
|
function void D_End(D_Context *draw, Vk_Frame *frame);
|
||||||
|
|
||||||
|
|||||||
60
code/first.c
@@ -26,15 +26,12 @@
|
|||||||
#include "game/impl/bandit.c"
|
#include "game/impl/bandit.c"
|
||||||
#include "game/testnavmesh.h"
|
#include "game/testnavmesh.h"
|
||||||
|
|
||||||
const int width = 1280;
|
|
||||||
const int height = 720;
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
(void)argc;
|
(void) argc;
|
||||||
(void)argv;
|
(void) argv;
|
||||||
|
|
||||||
if (!SDL_Init(SDL_INIT_VIDEO))
|
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO))
|
||||||
{
|
{
|
||||||
printf("[Error] :: Failed to initialise SDL3 (%s)\n", SDL_GetError());
|
printf("[Error] :: Failed to initialise SDL3 (%s)\n", SDL_GetError());
|
||||||
return 1;
|
return 1;
|
||||||
@@ -47,6 +44,30 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_AudioStream *austream;
|
||||||
|
Str8 audio_data;
|
||||||
|
M_TempScope(0, 0) {
|
||||||
|
SDL_AudioSpec spec;
|
||||||
|
spec.format = SDL_AUDIO_S16LE;
|
||||||
|
spec.channels = 2;
|
||||||
|
spec.freq = 44100;
|
||||||
|
|
||||||
|
austream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &spec, 0, 0);
|
||||||
|
|
||||||
|
if (!austream) {
|
||||||
|
printf("Failed to open audio stream (%s)\n", SDL_GetError());
|
||||||
|
}
|
||||||
|
|
||||||
|
Str8 exec = FS_SystemPath(temp.arena, FS_SYSTEM_PATH_EXE);
|
||||||
|
Str8 path = Sf(temp.arena, "%.*s/assets/outside_ambience.wav", Sv(exec));
|
||||||
|
|
||||||
|
SDL_AudioSpec wav_spec;
|
||||||
|
U32 count;
|
||||||
|
|
||||||
|
SDL_LoadWAV((const char *) path.data, &wav_spec, &audio_data.data, &count);
|
||||||
|
audio_data.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
Vk_Setup(window);
|
Vk_Setup(window);
|
||||||
|
|
||||||
G_State *game = 0;
|
G_State *game = 0;
|
||||||
@@ -59,6 +80,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
G_ImagesLoad(game);
|
G_ImagesLoad(game);
|
||||||
G_PipelinesLoad(game);
|
G_PipelinesLoad(game);
|
||||||
|
G_AudioLoad(game);
|
||||||
|
|
||||||
G_Camera *camera = &game->camera;
|
G_Camera *camera = &game->camera;
|
||||||
|
|
||||||
@@ -115,10 +137,20 @@ int main(int argc, char **argv)
|
|||||||
world->player.currentArea = 0;
|
world->player.currentArea = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
D_Animation animation;
|
||||||
|
{
|
||||||
|
U32 id = D_ImageHandle(&game->draw, S("npc_front_base_white"));
|
||||||
|
D_AnimationInit(&animation, id, 1, 4, 1.0f / 20.0f);
|
||||||
|
}
|
||||||
|
|
||||||
bool running = true;
|
bool running = true;
|
||||||
|
|
||||||
printf("%zu size in bytes\n", sizeof(TestNavMesh));
|
printf("%zu size in bytes\n", sizeof(TestNavMesh));
|
||||||
|
|
||||||
|
const int width = 1280;
|
||||||
|
const int height = 720;
|
||||||
|
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
@@ -130,13 +162,14 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
V3f projection = G_CameraUnproject(&game->camera, V2f_Clip(
|
V3f projection = G_CameraUnproject(&game->camera, V2f_Clip(
|
||||||
V2F(e.button.x, e.button.y),
|
V2F(e.button.x, e.button.y),
|
||||||
V2F(width, height)
|
V2F((F32) width, (F32) height)
|
||||||
));
|
));
|
||||||
game->world->mouseProjected = V2F(projection.x, projection.y);
|
game->world->mouseProjected = V2F(projection.x, projection.y);
|
||||||
ProcessEvents(&e, game->world);
|
ProcessEvents(&e, game->world);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateWorld(1.0f / 60.0f, game->world);
|
UpdateWorld(1.0f / 60.0f, game->world);
|
||||||
|
D_AnimationUpdate(&animation, 1.0f / 250.0f);
|
||||||
game->camera.p.x = game->world->player.pos.x;
|
game->camera.p.x = game->world->player.pos.x;
|
||||||
game->camera.p.y = game->world->player.pos.y;
|
game->camera.p.y = game->world->player.pos.y;
|
||||||
|
|
||||||
@@ -176,10 +209,15 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
D_Begin(&game->draw, frame, D_MAX_RECTS);
|
D_Begin(&game->draw, frame, D_MAX_RECTS);
|
||||||
|
|
||||||
RenderWorld(game->world, &game->draw);
|
//RenderWorld(game->world, &game->draw);
|
||||||
D_Rect(&game->draw, 0.0f, 0.0f, .texture = 1);
|
// D_Rect(&game->draw, 0.0f, 0.0f, .texture = D_ImageHandle(&game->draw, S("saloon_ext")), .scale = 4.0f);
|
||||||
D_Rect(&game->draw, -8.0f, 0.0f, .texture = 2, .scale = 2.0f);
|
// D_Rect(&game->draw, -8.0f, 0.0f, .texture = 2, .scale = 2.0f);
|
||||||
D_Rect(&game->draw, 6.0f, 0.0f, .texture = 3);
|
// D_Rect(&game->draw, 6.0f, 0.0f, .texture = 3);
|
||||||
|
|
||||||
|
G_WorldDraw(game, game->world);
|
||||||
|
|
||||||
|
R2f aframe = D_AnimationFrame(&animation);
|
||||||
|
D_Rect(&game->draw, 0, 0, .texture = animation.id, .uv = aframe, .flags = D_RECT_UV_ASPECT);
|
||||||
|
|
||||||
D_End(&game->draw, frame);
|
D_End(&game->draw, frame);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
// @Todo: These should move to draw/core.c
|
// @Todo: These should move to draw/core.c
|
||||||
//
|
//
|
||||||
|
internal void G_AssetNameHash(D_Context *draw, Str8 name, U32 id) {
|
||||||
|
D_AssetHash *result = M_ArenaPush(draw->arena, D_AssetHash);
|
||||||
|
|
||||||
|
U64 hash = Str8_Hash(name);
|
||||||
|
U64 index = hash & (D_ASSET_HASH_COUNT - 1);
|
||||||
|
|
||||||
|
result->value = name;
|
||||||
|
result->hash = hash;
|
||||||
|
result->id = id;
|
||||||
|
|
||||||
|
SLL_Push(draw->lookup[index], result);
|
||||||
|
}
|
||||||
|
|
||||||
void G_ImagesLoad(G_State *game) {
|
void G_ImagesLoad(G_State *game) {
|
||||||
M_TempScope(0, 0) {
|
M_TempScope(0, 0) {
|
||||||
D_Context *draw = &game->draw;
|
D_Context *draw = &game->draw;
|
||||||
@@ -59,6 +72,9 @@ void G_ImagesLoad(G_State *game) {
|
|||||||
|
|
||||||
white->name = S("_WHITE");
|
white->name = S("_WHITE");
|
||||||
|
|
||||||
|
// This doesn't _really_ need one because its just zero and always will be zero
|
||||||
|
G_AssetNameHash(draw, white->name, 0);
|
||||||
|
|
||||||
white->image.width = 2;
|
white->image.width = 2;
|
||||||
white->image.height = 2;
|
white->image.height = 2;
|
||||||
white->image.format = VK_FORMAT_R8G8B8A8_SRGB;
|
white->image.format = VK_FORMAT_R8G8B8A8_SRGB;
|
||||||
@@ -147,10 +163,11 @@ void G_ImagesLoad(G_State *game) {
|
|||||||
|
|
||||||
Assert(offset <= staging->size);
|
Assert(offset <= staging->size);
|
||||||
|
|
||||||
draw->n_images += 1;
|
|
||||||
|
|
||||||
image->name = Str8_Copy(game->arena, Str8_RemoveAfterLast(it->basename, '.'));
|
image->name = Str8_Copy(game->arena, Str8_RemoveAfterLast(it->basename, '.'));
|
||||||
|
|
||||||
|
G_AssetNameHash(draw, image->name, draw->n_images);
|
||||||
|
|
||||||
|
draw->n_images += 1;
|
||||||
printf("[Info] :: Loaded %.*s from %.*s\n", Sv(image->name), Sv(it->basename));
|
printf("[Info] :: Loaded %.*s from %.*s\n", Sv(image->name), Sv(it->basename));
|
||||||
|
|
||||||
image->image.width = w;
|
image->image.width = w;
|
||||||
@@ -290,6 +307,22 @@ void G_PipelinesLoad(G_State *game) {
|
|||||||
Vk_PipelineCreate(basic);
|
Vk_PipelineCreate(basic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void G_AudioLoad(G_State *game) {
|
||||||
|
(void) game;
|
||||||
|
|
||||||
|
M_TempScope(0, 0) {
|
||||||
|
Str8 exe_path = FS_SystemPath(temp.arena, FS_SYSTEM_PATH_EXE);
|
||||||
|
Str8 path = Sf(temp.arena, "%.*s/assets", Sv(exe_path));
|
||||||
|
|
||||||
|
FS_List assets = FS_PathList(temp.arena, path);
|
||||||
|
|
||||||
|
// @Incomplete: finish this
|
||||||
|
|
||||||
|
for (FS_Entry *it = assets.first; it != 0; it = it->next) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void G_CalculateCamera(G_Camera *camera, F32 aspect) {
|
void G_CalculateCamera(G_Camera *camera, F32 aspect) {
|
||||||
Mat4x4FInv proj = M4x4F_Perspective(camera->fov, aspect, camera->nearp, camera->farp);
|
Mat4x4FInv proj = M4x4F_Perspective(camera->fov, aspect, camera->nearp, camera->farp);
|
||||||
Mat4x4FInv view = M4x4F_CameraView(camera->x, camera->y, camera->z, camera->p);
|
Mat4x4FInv view = M4x4F_CameraView(camera->x, camera->y, camera->z, camera->p);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ struct G_State {
|
|||||||
|
|
||||||
function void G_ImagesLoad(G_State *game);
|
function void G_ImagesLoad(G_State *game);
|
||||||
function void G_PipelinesLoad(G_State *game);
|
function void G_PipelinesLoad(G_State *game);
|
||||||
|
function void G_AudioLoad(G_State *game);
|
||||||
|
|
||||||
function void G_CalculateCamera(G_Camera *camera, F32 aspect);
|
function void G_CalculateCamera(G_Camera *camera, F32 aspect);
|
||||||
|
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
#include "game/bandit.h"
|
#include "game/bandit.h"
|
||||||
|
|
||||||
void UpdateBandit(F32 delta, Bandit *bandit, World *world) {
|
void UpdateBandit(F32 delta, Bandit *bandit, World *world) {
|
||||||
if(
|
if (
|
||||||
world->player.controls.shot
|
world->player.controls.shot && AABB_Slab(world->player.pos, world->player.shotPos, bandit->collision) && bandit->currentArea == world->player.currentArea)
|
||||||
&& AABB_Point(bandit->collision, world->player.shotPos)
|
{
|
||||||
&& bandit->currentArea == world->player.currentArea
|
|
||||||
) {
|
|
||||||
printf("You shot the bandit %*.s\n", Sv(bandit->name));
|
printf("You shot the bandit %*.s\n", Sv(bandit->name));
|
||||||
bandit->health--;
|
bandit->health--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <SDL3/SDL_events.h>
|
#include <SDL3/SDL_events.h>
|
||||||
#include <SDL3/SDL_keycode.h>
|
#include <SDL3/SDL_keycode.h>
|
||||||
#include <SDL3/SDL_oldnames.h>
|
#include <SDL3/SDL_oldnames.h>
|
||||||
|
#include "../map.h"
|
||||||
|
|
||||||
void UpdateWorld(F32 delta, World *world)
|
void UpdateWorld(F32 delta, World *world)
|
||||||
{
|
{
|
||||||
@@ -19,11 +20,9 @@ void UpdateNPCs(F32 delta, World *world)
|
|||||||
{
|
{
|
||||||
NPC *npc = &world->npcs[i];
|
NPC *npc = &world->npcs[i];
|
||||||
UpdateNPC(delta, npc, world);
|
UpdateNPC(delta, npc, world);
|
||||||
if(
|
if (
|
||||||
world->player.controls.shot
|
world->player.controls.shot && AABB_Slab(world->player.pos, world->player.shotPos, npc->collision) && npc->currentArea == world->player.currentArea)
|
||||||
&& AABB_Point(npc->collision, world->player.shotPos)
|
{
|
||||||
&& npc->currentArea == world->player.currentArea
|
|
||||||
) {
|
|
||||||
printf("You shot %*.s\n", Sv(world->npcs[i].name));
|
printf("You shot %*.s\n", Sv(world->npcs[i].name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +37,11 @@ void ProcessEvents(SDL_Event *event, World *world)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RenderWorld(World *world, D_Context *draw) {
|
void RenderWorld(World *world, D_Context *draw) {
|
||||||
|
World_Tile tileTypes[] = {dirt, middlePath, middlePathEdgeTop, middlePathEdgeRight, middlePathEdgeBottom, middlePathEdgeLeft, middlePathCornerTopLeft, middlePathCornerTopRight, middlePathCornerBottomRight, middlePathCornerTurnBottomLeft};
|
||||||
|
for (int i = 0; i < 4800; i++)
|
||||||
|
{
|
||||||
|
D_Rect(draw, (F32) (i % 96), (F32) (i / 96), .texture = tileTypes[map[i]].tile, .angle = (F32) tileTypes[map[i]].rotation);
|
||||||
|
}
|
||||||
for(U32 i = 0; i < world->npcCount; i++) {
|
for(U32 i = 0; i < world->npcCount; i++) {
|
||||||
NPC npc = world->npcs[i];
|
NPC npc = world->npcs[i];
|
||||||
if(npc.currentArea == world->player.currentArea) {
|
if(npc.currentArea == world->player.currentArea) {
|
||||||
@@ -59,15 +63,17 @@ void G_WorldDraw(G_State *game, World *world) {
|
|||||||
|
|
||||||
(void) world;
|
(void) world;
|
||||||
|
|
||||||
for (F32 y = -128; y < 128; y += 1.1f) {
|
U32 id = D_ImageHandle(&game->draw, S("tile_dirt_0"));
|
||||||
for (F32 x = -128; x < 128; x += 1.1f) {
|
U32 alt_id = D_ImageHandle(&game->draw, S("tile_dirt_1"));
|
||||||
|
|
||||||
|
for (F32 y = -128; y < 128; y += 1.0f) {
|
||||||
|
for (F32 x = -128; x < 128; x += 1.0f) {
|
||||||
U32 ux = (U32) x;
|
U32 ux = (U32) x;
|
||||||
U32 uy = (U32) y;
|
U32 uy = (U32) y;
|
||||||
|
|
||||||
U32 tid = 15;
|
U32 tid = id;
|
||||||
if ((ux % 11) == 0 || ((uy % 7) == 0)) {
|
if ((ux % 11) == 0 || ((uy % 7) == 0)) {
|
||||||
tid = 16;
|
tid = alt_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
D_Rect(draw, x, y, .texture = tid);
|
D_Rect(draw, x, y, .texture = tid);
|
||||||
|
|||||||
65
code/game/map.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#include "world.h"
|
||||||
|
|
||||||
|
|
||||||
|
World_Tile dirt = {.rotation=0,.collision=false,.tile=16};//0
|
||||||
|
World_Tile middlePath = {.rotation=0,.collision=false,.tile=6};//1
|
||||||
|
World_Tile middlePathEdgeTop = {.rotation=0,.collision=false,.tile=7};//2
|
||||||
|
World_Tile middlePathEdgeRight = {.rotation=PI_F32/2,.collision=false,.tile=7};//3
|
||||||
|
World_Tile middlePathEdgeBottom = {.rotation=PI_F32,.collision=false,.tile=7};//4
|
||||||
|
World_Tile middlePathEdgeLeft = {.rotation=-PI_F32/2,.collision=false,.tile=7};//5
|
||||||
|
World_Tile middlePathCornerTopLeft = {.rotation=0,.collision=false,.tile=5};//6
|
||||||
|
World_Tile middlePathCornerTopRight = {.rotation=PI_F32/2,.collision=false,.tile=5};//7
|
||||||
|
World_Tile middlePathCornerBottomRight = {.rotation=-PI_F32,.collision=false,.tile=5};//8
|
||||||
|
World_Tile middlePathCornerTurnBottomLeft = {.rotation=-PI_F32/2,.collision=false,.tile=5};//9
|
||||||
|
int map[] = {
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||||
|
};
|
||||||
@@ -5,9 +5,22 @@
|
|||||||
|
|
||||||
// Areas are which
|
// Areas are which
|
||||||
typedef U32 World_Area;
|
typedef U32 World_Area;
|
||||||
enum World_Area {
|
enum World_Area
|
||||||
|
{
|
||||||
WORLD_AREA_OUTSIDE = (1 << 0),
|
WORLD_AREA_OUTSIDE = (1 << 0),
|
||||||
WORLD_AREA_SALOON = (1 << 1),
|
WORLD_AREA_SALOON = (1 << 1),
|
||||||
|
WORLD_PATH_MIDDLE_EDGE = (1 << 2),
|
||||||
|
WORLD_PATH_MIDDLE = (1 << 3),
|
||||||
|
WORLD_PATH_CORNER = (1 << 4),
|
||||||
|
WORLD_PATH_CORNER_EDGE = (1 << 5),
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct World_Tile World_Tile;
|
||||||
|
struct World_Tile
|
||||||
|
{
|
||||||
|
World_Area tile;
|
||||||
|
double rotation;
|
||||||
|
bool collision;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct World World;
|
typedef struct World World;
|
||||||
@@ -39,7 +52,7 @@ struct World {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function void UpdateWorld(F32 delta, World *world);
|
function void UpdateWorld(F32 delta, World *world);
|
||||||
function void RenderWorld(World *world, D_Context *drawContext );
|
function void RenderWorld(World *world, D_Context *drawContext);
|
||||||
function void ProcessEvents(SDL_Event *event, World *world);
|
function void ProcessEvents(SDL_Event *event, World *world);
|
||||||
function void UpdateNPCs(F32 delta, World *world);
|
function void UpdateNPCs(F32 delta, World *world);
|
||||||
function void UpdateNPC(F32 delta, NPC *npc, World *world);
|
function void UpdateNPC(F32 delta, NPC *npc, World *world);
|
||||||
|
|||||||