Now using a simple collision map to track entities and then determine if they're near the player for attacking.

This commit is contained in:
Zed A. Shaw 2024-10-26 04:33:23 -04:00
parent 743f906bc7
commit ec1ed23c52
6 changed files with 72 additions and 48 deletions

View file

@ -22,6 +22,7 @@
#include "rand.hpp"
#include "components.hpp"
#include "systems.hpp"
#include "collider.hpp"
using std::string;
using namespace fmt;
@ -277,6 +278,9 @@ void GUI::configure_world() {
ActionLog log{{"Welcome to the game!"}};
$world.set<ActionLog>(log);
SpatialHashTable collider;
$world.set<SpatialHashTable>(collider);
$world.assign<Position>(player.entity, {$game_map.place_entity(0)});
$world.assign<Motion>(player.entity, {0, 0});
$world.assign<Combat>(player.entity, {100, 10});
@ -298,6 +302,8 @@ void GUI::configure_world() {
$world.assign<Position>(gold, {$game_map.place_entity($game_map.room_count() - 1)});
$world.assign<Treasure>(gold, {100});
$world.assign<Tile>(gold, {"$"});
System::init_positions($world);
}
void GUI::render_scene() {