feat: initial bandit and more npc tweaks

This commit is contained in:
2025-10-05 14:42:19 +01:00
parent 175f4da59b
commit 1f97d81133
8 changed files with 212 additions and 27 deletions

View File

@@ -41,9 +41,3 @@ void updateNPC(F32 delta, NPC *npc, World *world) {
}
}
void UpdateNPCs(F32 delta, World *world) {
for(int i = 0; i < world->npcCount; i++) {
updateNPC(delta, &world->npcs[i], world);
}
}

View File

@@ -1,22 +1,23 @@
#include "../player.h"
#include <SDL3/SDL_keycode.h>
#include <stdio.h>
void PlayerUpdate(SDL_Event *event, Player *player)
{
SDL_KeyboardEvent key = event->key;
if (key.key == SDLK_W)
{
switch(key.key) {
case SDLK_W: {
player->pos.y += 10;
}
if (key.key == SDLK_A)
{
}
case SDLK_A: {
player->pos.x -= 10;
}
if (key.key == SDLK_D)
{
}
case SDLK_D: {
player->pos.x += 10;
}
if (key.key == SDLK_S)
{
}
case SDLK_S: {
player->pos.y -= 10;
}
}
printf("Player: %f %f\n", player->pos.x, player->pos.y);
}

18
code/game/impl/world.c Normal file
View File

@@ -0,0 +1,18 @@
#include "../world.h"
#include "../npc.h"
#include "../player.h"
#include <SDL3/SDL_events.h>
void UpdateWorld(F32 delta, World *world) {
UpdateNPCs(delta, world);
}
void UpdateNPCs(F32 delta, World *world) {
for(int i = 0; i < world->npcCount; i++) {
updateNPC(delta, &world->npcs[i], world);
}
}
void ProcessEvents(SDL_Event *event, World *world) {
PlayerUpdate(event, &world->player);
}