Fixed ???
Some files have been renamed
This commit is contained in:
49
code/first.c
49
code/first.c
@@ -79,6 +79,8 @@ int main(int argc, char **argv)
|
||||
game->draw.arena = arena;
|
||||
|
||||
G_ImagesLoad(game);
|
||||
D_FontLoad(&game->draw, S("ubuntu"), 60);
|
||||
|
||||
G_PipelinesLoad(game);
|
||||
G_AudioLoad(game);
|
||||
|
||||
@@ -87,7 +89,7 @@ int main(int argc, char **argv)
|
||||
camera->x = V3F(1, 0, 0);
|
||||
camera->y = V3F(0, 1, 0);
|
||||
camera->z = V3F(0, 0, 1);
|
||||
camera->p = V3F(0, 0, 48);
|
||||
camera->p = V3F(0, 0, 16);
|
||||
|
||||
camera->fov = 60.0f;
|
||||
|
||||
@@ -129,12 +131,9 @@ int main(int argc, char **argv)
|
||||
badman->pointsOfInterest[1] = 12;
|
||||
|
||||
world->npcPOI[0] = 100;
|
||||
world->player.world = world;
|
||||
world->player.pos.x = 0;
|
||||
world->player.pos.y = 0;
|
||||
world->player.bulletsLoaded = PLAYER_BULLET_COUNT;
|
||||
world->player.reloadTimer = 0;
|
||||
world->player.currentArea = WORLD_AREA_OUTSIDE;
|
||||
|
||||
PlayerInit(game, &world->player);
|
||||
|
||||
for(int i =0; i< 4200; i++) {
|
||||
world->map[i] = map[i];
|
||||
}
|
||||
@@ -220,17 +219,8 @@ int main(int argc, char **argv)
|
||||
game->editor.mode = G_EDITOR_MODE_TILE;
|
||||
game->editor.currentLevel = WORLD_AREA_OUTSIDE;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
printf("%zu size in bytes\n", sizeof(TestNavMesh));
|
||||
|
||||
const int width = 1280;
|
||||
const int height = 720;
|
||||
|
||||
@@ -243,6 +233,13 @@ int main(int argc, char **argv)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
else if (e.type == SDL_EVENT_KEY_DOWN) {
|
||||
Player *player = &game->world->player;
|
||||
switch (e.key.key) {
|
||||
case SDLK_R: { PlayerInit(game, player); } break;
|
||||
}
|
||||
}
|
||||
|
||||
V3f projection = G_CameraUnproject(&game->camera, V2f_Clip(
|
||||
V2F(e.button.x, e.button.y),
|
||||
V2F((F32) width, (F32) height)
|
||||
@@ -257,8 +254,8 @@ int main(int argc, char **argv)
|
||||
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);
|
||||
F32 tilex = (F32) (S32)(game->editor.cursor.x+TILE_SIZE/2);
|
||||
F32 tiley = (F32) (S32)(game->editor.cursor.y+TILE_SIZE/2);
|
||||
game->world->map[(S32)tilex + (S32)tiley * 96] = game->editor.currentAsset;
|
||||
break;
|
||||
}
|
||||
@@ -275,7 +272,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
} else if(e.type==SDL_EVENT_MOUSE_BUTTON_UP && e.button.button == SDL_BUTTON_LEFT && game->editor.mode == G_EDITOR_MODE_HITBOX) {
|
||||
// Add 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(
|
||||
@@ -345,8 +342,7 @@ int main(int argc, char **argv)
|
||||
UpdateWorld(1.0f / 60.0f, game->world);
|
||||
game->camera.p.x = game->world->player.pos.x;
|
||||
game->camera.p.y = game->world->player.pos.y;
|
||||
}
|
||||
D_AnimationUpdate(&animation, 1.0f / 250.0f);
|
||||
}
|
||||
|
||||
int w, h;
|
||||
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||
@@ -386,17 +382,16 @@ int main(int argc, char **argv)
|
||||
|
||||
RenderWorld(game->world, &game->draw);
|
||||
|
||||
R2f aframe = D_AnimationFrame(&animation);
|
||||
D_Rect(&game->draw, 0, 0, .texture = animation.id, .uv = aframe, .flags = D_RECT_UV_ASPECT);
|
||||
D_Text(&game->draw, game->draw.fonts, S("Small Test"), 0, 0);
|
||||
|
||||
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);
|
||||
F32 tilex = cast(F32) floor(editor.cursor.x+TILE_SIZE/2);
|
||||
F32 tiley = cast(F32) 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);
|
||||
D_Rect(&game->draw, tilex, tiley, .texture=asset.tile, .angle=(F32) asset.rotation);
|
||||
break;
|
||||
}
|
||||
case G_EDITOR_MODE_PROP: {
|
||||
@@ -405,7 +400,7 @@ int main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
case G_EDITOR_MODE_HITBOX: {
|
||||
for(int i = 0; i < game->world->hitboxCount; i++) {
|
||||
for(U32 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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user