Compare commits
2 Commits
3e527f473b
...
8a360df98a
| Author | SHA1 | Date | |
|---|---|---|---|
|
8a360df98a
|
|||
|
3a84947750
|
BIN
assets/barrel.png
Normal file
|
After Width: | Height: | Size: 590 B |
BIN
assets/can.png
Normal file
|
After Width: | Height: | Size: 168 B |
BIN
assets/candle.png
Normal file
|
After Width: | Height: | Size: 176 B |
BIN
assets/clock.png
Normal file
|
After Width: | Height: | Size: 584 B |
BIN
assets/house.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
assets/house_int.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
BIN
assets/log_pile.png
Normal file
|
After Width: | Height: | Size: 519 B |
BIN
assets/nightstand.png
Normal file
|
After Width: | Height: | Size: 244 B |
BIN
assets/pool_table.png
Normal file
|
After Width: | Height: | Size: 846 B |
BIN
assets/rug0.png
Normal file
|
After Width: | Height: | Size: 634 B |
BIN
assets/rug1.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/saloon_int.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
assets/skull.png
Normal file
|
After Width: | Height: | Size: 555 B |
BIN
assets/table.png
Normal file
|
After Width: | Height: | Size: 1012 B |
224
code/first.c
@@ -95,9 +95,10 @@ int main(int argc, char **argv)
|
|||||||
camera->farp = 1000.0f;
|
camera->farp = 1000.0f;
|
||||||
|
|
||||||
game->draw.camera = camera;
|
game->draw.camera = camera;
|
||||||
World *world = LoadWorld(arena);
|
World *world = M_ArenaPush(arena, World);//LoadWorld(arena);
|
||||||
game->world = world;
|
game->world = world;
|
||||||
world->arena = arena;
|
world->arena = arena;
|
||||||
|
world->navMesh = &TestNavMesh;
|
||||||
world->random = Random_Seed(29237489723847);
|
world->random = Random_Seed(29237489723847);
|
||||||
world->npcCount = 2;
|
world->npcCount = 2;
|
||||||
for(U32 i = 0; i < world->npcCount; i++) {
|
for(U32 i = 0; i < world->npcCount; i++) {
|
||||||
@@ -133,8 +134,91 @@ int main(int argc, char **argv)
|
|||||||
world->player.pos.y = 0;
|
world->player.pos.y = 0;
|
||||||
world->player.bulletsLoaded = PLAYER_BULLET_COUNT;
|
world->player.bulletsLoaded = PLAYER_BULLET_COUNT;
|
||||||
world->player.reloadTimer = 0;
|
world->player.reloadTimer = 0;
|
||||||
world->player.currentArea = 0;
|
world->player.currentArea = WORLD_AREA_OUTSIDE;
|
||||||
|
for(int i =0; i< 4200; i++) {
|
||||||
|
world->map[i] = map[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
world->tileTypes[0].rotation=0;
|
||||||
|
world->tileTypes[0].collision=false;
|
||||||
|
world->tileTypes[0].tile=D_ImageHandle(&game->draw, S("tile_dirt_0"));
|
||||||
|
world->tileTypes[1].rotation=0,
|
||||||
|
world->tileTypes[1].collision=false,
|
||||||
|
world->tileTypes[1].tile=D_ImageHandle(&game->draw, S("path_middle"));
|
||||||
|
world->tileTypes[2].rotation=0;
|
||||||
|
world->tileTypes[2].collision=false;
|
||||||
|
world->tileTypes[2].tile=D_ImageHandle(&game->draw, S("path_middle_edge"));
|
||||||
|
world->tileTypes[3].rotation=PI_F32/2;
|
||||||
|
world->tileTypes[3].collision=false;
|
||||||
|
world->tileTypes[3].tile=D_ImageHandle(&game->draw, S("path_middle_edge"));
|
||||||
|
world->tileTypes[4].rotation=PI_F32;
|
||||||
|
world->tileTypes[4].collision=false;
|
||||||
|
world->tileTypes[4].tile=D_ImageHandle(&game->draw, S("path_middle_edge"));
|
||||||
|
world->tileTypes[5].rotation=-PI_F32/2;
|
||||||
|
world->tileTypes[5].collision=false;
|
||||||
|
world->tileTypes[5].tile=D_ImageHandle(&game->draw, S("path_middle_edge"));
|
||||||
|
world->tileTypes[6].rotation=0;
|
||||||
|
world->tileTypes[6].collision=false;
|
||||||
|
world->tileTypes[6].tile=D_ImageHandle(&game->draw, S("path_middle"));
|
||||||
|
world->tileTypes[7].rotation=PI_F32/2;
|
||||||
|
world->tileTypes[7].collision=false;
|
||||||
|
world->tileTypes[7].tile=D_ImageHandle(&game->draw, S("path_middle"));
|
||||||
|
world->tileTypes[8].rotation=-PI_F32;
|
||||||
|
world->tileTypes[8].collision=false;
|
||||||
|
world->tileTypes[8].tile=D_ImageHandle(&game->draw, S("path_middle"));
|
||||||
|
world->tileTypes[9].rotation=-PI_F32/2;
|
||||||
|
world->tileTypes[9].collision=false;
|
||||||
|
world->tileTypes[9].tile=D_ImageHandle(&game->draw, S("path_middle"));
|
||||||
|
world->tileTypes[10].rotation=0;
|
||||||
|
world->tileTypes[10].collision=false;
|
||||||
|
world->tileTypes[10].tile=D_ImageHandle(&game->draw, S("path_corner"));
|
||||||
|
world->tileTypes[11].rotation=PI_F32/2;
|
||||||
|
world->tileTypes[11].collision=false;
|
||||||
|
world->tileTypes[11].tile=D_ImageHandle(&game->draw, S("path_corner"));
|
||||||
|
world->tileTypes[12].rotation=-PI_F32/2;
|
||||||
|
world->tileTypes[12].collision=false;
|
||||||
|
world->tileTypes[12].tile=D_ImageHandle(&game->draw, S("path_corner"));
|
||||||
|
world->tileTypes[13].rotation=PI_F32;
|
||||||
|
world->tileTypes[13].collision=false;
|
||||||
|
world->tileTypes[13].tile=D_ImageHandle(&game->draw, S("path_corner"));
|
||||||
|
world->tileTypes[14].rotation=0;
|
||||||
|
world->tileTypes[14].collision=false;
|
||||||
|
world->tileTypes[14].tile=D_ImageHandle(&game->draw, S("tile_dirt_1"));
|
||||||
|
|
||||||
|
world->propTypes[0].assetHandle=D_ImageHandle(&game->draw, S("rug0"));
|
||||||
|
world->propTypes[0].scale=1;
|
||||||
|
world->propTypes[1].assetHandle=D_ImageHandle(&game->draw, S("rug1"));
|
||||||
|
world->propTypes[1].scale=1;
|
||||||
|
world->propTypes[2].assetHandle=D_ImageHandle(&game->draw, S("skull"));
|
||||||
|
world->propTypes[2].scale=1;
|
||||||
|
world->propTypes[3].assetHandle=D_ImageHandle(&game->draw, S("table"));
|
||||||
|
world->propTypes[3].scale=1;
|
||||||
|
world->propTypes[4].assetHandle=D_ImageHandle(&game->draw, S("barrel"));
|
||||||
|
world->propTypes[4].scale=1;
|
||||||
|
world->propTypes[5].assetHandle=D_ImageHandle(&game->draw, S("can"));
|
||||||
|
world->propTypes[5].scale=1;
|
||||||
|
world->propTypes[6].assetHandle=D_ImageHandle(&game->draw, S("candle"));
|
||||||
|
world->propTypes[6].scale=1;
|
||||||
|
world->propTypes[7].assetHandle=D_ImageHandle(&game->draw, S("clock"));
|
||||||
|
world->propTypes[7].scale=1;
|
||||||
|
world->propTypes[8].assetHandle=D_ImageHandle(&game->draw, S("log_pile"));
|
||||||
|
world->propTypes[8].scale=1;
|
||||||
|
world->propTypes[9].assetHandle=D_ImageHandle(&game->draw, S("nightstand"));
|
||||||
|
world->propTypes[9].scale=1;
|
||||||
|
world->propTypes[10].assetHandle=D_ImageHandle(&game->draw, S("pool_table"));
|
||||||
|
world->propTypes[10].scale=1;
|
||||||
|
world->propTypes[11].assetHandle=D_ImageHandle(&game->draw, S("saloon_ext"));
|
||||||
|
world->propTypes[11].scale=6.875f;
|
||||||
|
world->propTypes[12].assetHandle=D_ImageHandle(&game->draw, S("saloon_int"));
|
||||||
|
world->propTypes[12].scale=6.875f;
|
||||||
|
world->propTypes[11].assetHandle=D_ImageHandle(&game->draw, S("house"));
|
||||||
|
world->propTypes[11].scale=6.875f;
|
||||||
|
world->propTypes[12].assetHandle=D_ImageHandle(&game->draw, S("house_int"));
|
||||||
|
world->propTypes[12].scale=6.875f;
|
||||||
}
|
}
|
||||||
|
game->editor.enabled = true;
|
||||||
|
game->editor.mode = G_EDITOR_MODE_TILE;
|
||||||
|
game->editor.currentLevel = WORLD_AREA_OUTSIDE;
|
||||||
|
|
||||||
|
|
||||||
D_Animation animation;
|
D_Animation animation;
|
||||||
@@ -164,13 +248,105 @@ int main(int argc, char **argv)
|
|||||||
V2F((F32) width, (F32) 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);
|
if(e.type==SDL_EVENT_MOUSE_MOTION) {
|
||||||
|
game->editor.cursor = V2F(projection.x, projection.y);
|
||||||
|
}
|
||||||
|
if (!game->editor.enabled) {
|
||||||
|
ProcessEvents(&e, game->world);
|
||||||
|
} else {
|
||||||
|
if(e.type==SDL_EVENT_MOUSE_BUTTON_DOWN && e.button.button == SDL_BUTTON_LEFT) {
|
||||||
|
switch(game->editor.mode){
|
||||||
|
case G_EDITOR_MODE_TILE: {
|
||||||
|
F32 tilex = (S32)(game->editor.cursor.x+TILE_SIZE/2);
|
||||||
|
F32 tiley = (S32)(game->editor.cursor.y+TILE_SIZE/2);
|
||||||
|
game->world->map[(S32)tilex + (S32)tiley * 96] = game->editor.currentAsset;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case G_EDITOR_MODE_PROP: {
|
||||||
|
game->world->props[game->world->propCount].propType = game->editor.currentAsset;
|
||||||
|
game->world->props[game->world->propCount].area = game->editor.currentLevel;
|
||||||
|
game->world->props[game->world->propCount].pos = game->editor.cursor;
|
||||||
|
game->world->propCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case G_EDITOR_MODE_HITBOX: {
|
||||||
|
game->editor.dragStart = game->editor.cursor;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
|
||||||
|
// Add hitbox
|
||||||
|
V2f topLeft = V2F(Min(game->editor.cursor.x, game->editor.dragStart.x), Min(game->editor.cursor.y, game->editor.dragStart.y));
|
||||||
|
game->world->hitboxes[game->world->hitboxCount].pos = topLeft;
|
||||||
|
game->world->hitboxes[game->world->hitboxCount].size = V2F(
|
||||||
|
Abs(game->editor.cursor.x-game->editor.dragStart.x),
|
||||||
|
Abs(game->editor.cursor.y-game->editor.dragStart.y)
|
||||||
|
);
|
||||||
|
game->world->hitboxCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.type == SDL_EVENT_KEY_DOWN) {
|
||||||
|
switch(e.key.key) {
|
||||||
|
case SDLK_F10: {
|
||||||
|
game->editor.enabled = !game->editor.enabled;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_RIGHT: {
|
||||||
|
game->editor.currentAsset = Min(game->editor.currentAsset+1, 64);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_LEFT: {
|
||||||
|
game->editor.currentAsset = Max(game->editor.currentAsset-1, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_A: {
|
||||||
|
game->camera.p.x -= 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_D: {
|
||||||
|
game->camera.p.x += 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_W: {
|
||||||
|
game->camera.p.y -= 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_S: {
|
||||||
|
game->camera.p.y += 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_UP: {
|
||||||
|
game->editor.currentLevel++;
|
||||||
|
game->world->player.currentArea++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_DOWN: {
|
||||||
|
game->editor.currentLevel--;
|
||||||
|
game->world->player.currentArea--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_SPACE: {
|
||||||
|
game->editor.mode = (game->editor.mode + 1) % 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SDLK_U: {
|
||||||
|
switch(game->editor.mode) {
|
||||||
|
case G_EDITOR_MODE_PROP: {game->world->propCount--;}
|
||||||
|
case G_EDITOR_MODE_HITBOX: {game->world->hitboxCount--;}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateWorld(1.0f / 60.0f, game->world);
|
if(!game->editor.enabled) {
|
||||||
D_AnimationUpdate(&animation, 1.0f / 250.0f);
|
UpdateWorld(1.0f / 60.0f, game->world);
|
||||||
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;
|
||||||
|
}
|
||||||
|
D_AnimationUpdate(&animation, 1.0f / 250.0f);
|
||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
@@ -184,7 +360,7 @@ int main(int argc, char **argv)
|
|||||||
VkCommandBuffer cmd = frame->cmd;
|
VkCommandBuffer cmd = frame->cmd;
|
||||||
|
|
||||||
VkClearValue clear_colour;
|
VkClearValue clear_colour;
|
||||||
clear_colour.color.float32[0] = 1.0f;
|
clear_colour.color.float32[0] = 0.0f;
|
||||||
clear_colour.color.float32[1] = 0.0f;
|
clear_colour.color.float32[1] = 0.0f;
|
||||||
clear_colour.color.float32[2] = 0.0f;
|
clear_colour.color.float32[2] = 0.0f;
|
||||||
clear_colour.color.float32[3] = 1.0f;
|
clear_colour.color.float32[3] = 1.0f;
|
||||||
@@ -208,14 +384,38 @@ 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 = 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, 6.0f, 0.0f, .texture = 3);
|
|
||||||
|
|
||||||
R2f aframe = D_AnimationFrame(&animation);
|
R2f aframe = D_AnimationFrame(&animation);
|
||||||
D_Rect(&game->draw, 0, 0, .texture = animation.id, .uv = aframe, .flags = D_RECT_UV_ASPECT);
|
D_Rect(&game->draw, 0, 0, .texture = animation.id, .uv = aframe, .flags = D_RECT_UV_ASPECT);
|
||||||
|
|
||||||
|
if(game->editor.enabled) {
|
||||||
|
G_Editor editor = game->editor;
|
||||||
|
F32 tilex = floor(editor.cursor.x+TILE_SIZE/2);
|
||||||
|
F32 tiley = floor(editor.cursor.y+TILE_SIZE/2);
|
||||||
|
switch(game->editor.mode) {
|
||||||
|
case G_EDITOR_MODE_TILE: {
|
||||||
|
World_Tile asset = game->world->tileTypes[editor.currentAsset];
|
||||||
|
D_Rect(&game->draw, tilex, tiley, .texture=asset.tile, .angle=asset.rotation);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case G_EDITOR_MODE_PROP: {
|
||||||
|
World_PropType prop = game->world->propTypes[editor.currentAsset];
|
||||||
|
D_Rect(&game->draw, editor.cursor.x, editor.cursor.y, .texture=prop.assetHandle, .scale=prop.scale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case G_EDITOR_MODE_HITBOX: {
|
||||||
|
for(int i = 0; i < game->world->hitboxCount; i++) {
|
||||||
|
V2f centre = AABB_Centre(game->world->hitboxes[i]);
|
||||||
|
D_Rect(&game->draw, centre.x, centre.y, .texture=0, .dim=game->world->hitboxes[i].size, .flags=D_RECT_IGNORE_ASPECT);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case G_EDITOR_MODE_POI: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
D_End(&game->draw, frame);
|
D_End(&game->draw, frame);
|
||||||
|
|
||||||
vk.CmdEndRendering(cmd);
|
vk.CmdEndRendering(cmd);
|
||||||
|
|||||||
@@ -13,6 +13,26 @@ struct G_Camera {
|
|||||||
Mat4x4FInv proj;
|
Mat4x4FInv proj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TILE_SIZE 1.0
|
||||||
|
|
||||||
|
typedef enum G_EDITOR_MODE G_EDITOR_MODE;
|
||||||
|
enum G_EDITOR_MODE {
|
||||||
|
G_EDITOR_MODE_TILE,
|
||||||
|
G_EDITOR_MODE_PROP,
|
||||||
|
G_EDITOR_MODE_HITBOX,
|
||||||
|
G_EDITOR_MODE_POI,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct G_Editor G_Editor;
|
||||||
|
struct G_Editor {
|
||||||
|
bool enabled;
|
||||||
|
U32 currentLevel;
|
||||||
|
S32 currentAsset;
|
||||||
|
G_EDITOR_MODE mode;
|
||||||
|
V2f cursor;
|
||||||
|
V2f dragStart;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct G_State G_State;
|
typedef struct G_State G_State;
|
||||||
struct G_State {
|
struct G_State {
|
||||||
M_Arena *arena;
|
M_Arena *arena;
|
||||||
@@ -20,6 +40,7 @@ struct G_State {
|
|||||||
D_Context draw;
|
D_Context draw;
|
||||||
G_Camera camera;
|
G_Camera camera;
|
||||||
|
|
||||||
|
G_Editor editor;
|
||||||
World *world;
|
World *world;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -37,10 +37,26 @@ 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};
|
if(world->player.currentArea == WORLD_AREA_OUTSIDE) {
|
||||||
for (int i = 0; i < 4800; i++)
|
for (int i = 0; i < 4800; i++) {
|
||||||
{
|
D_Rect(
|
||||||
D_Rect(draw, (F32) (i % 96), (F32) (i / 96), .texture = tileTypes[map[i]].tile, .angle = (F32) tileTypes[map[i]].rotation);
|
draw,
|
||||||
|
(F32) (i % 96), (F32) (i / 96),
|
||||||
|
.texture = world->tileTypes[world->map[i]].tile,
|
||||||
|
.angle = (F32) world->tileTypes[world->map[i]].rotation,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < world->propCount; i++) {
|
||||||
|
if(world->props[i].area == world->player.currentArea) {
|
||||||
|
D_Rect(
|
||||||
|
draw,
|
||||||
|
world->props[i].pos.x,
|
||||||
|
world->props[i].pos.y,
|
||||||
|
.texture = world->propTypes[world->props[i].propType].assetHandle,
|
||||||
|
.scale = world->propTypes[world->props[i].propType].scale,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
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];
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
#include "world.h"
|
#include "world.h"
|
||||||
|
|
||||||
|
U32 map[] = {
|
||||||
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
|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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,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,20 +9,29 @@ 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;
|
typedef struct World_Tile World_Tile;
|
||||||
struct World_Tile
|
struct World_Tile {
|
||||||
{
|
U32 tile;
|
||||||
World_Area tile;
|
|
||||||
double rotation;
|
double rotation;
|
||||||
bool collision;
|
bool collision;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct World_PropType World_PropType;
|
||||||
|
struct World_PropType {
|
||||||
|
U32 assetHandle;
|
||||||
|
F32 scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct World_Prop World_Prop;
|
||||||
|
struct World_Prop
|
||||||
|
{
|
||||||
|
U32 propType;
|
||||||
|
World_Area area;
|
||||||
|
V2f pos;
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct World World;
|
typedef struct World World;
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "npc.h"
|
#include "npc.h"
|
||||||
@@ -35,6 +44,14 @@ struct World {
|
|||||||
NavMesh *navMesh;
|
NavMesh *navMesh;
|
||||||
Random random;
|
Random random;
|
||||||
V2f mouseProjected;
|
V2f mouseProjected;
|
||||||
|
World_Tile tileTypes[64];
|
||||||
|
U32 map[4800];
|
||||||
|
|
||||||
|
World_PropType propTypes[64];
|
||||||
|
U32 propCount;
|
||||||
|
World_Prop props[256];
|
||||||
|
U32 hitboxCount;
|
||||||
|
AABB hitboxes[4096];
|
||||||
|
|
||||||
//// Player
|
//// Player
|
||||||
Player player;
|
Player player;
|
||||||
|
|||||||