feat: initial bandit and more npc tweaks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
18
code/game/impl/world.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user