CXX = g++
ifeq ($(TARGET_OS),linux)
- LIBS = -Llib -lgif -lpthread -lGL -lGLEW -lfreetype \
+ LIBS = -Llib -lgif -lentityx -lpthread -lGL -lGLEW -lfreetype \
-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2main
endif
ifeq ($(TARGET_OS),win32)
@mkdir out/components
$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
- @echo " CXX entityx"
- @g++ -I. -std=c++11 -c entityx/help/Pool.cc -o out/Pool.o
- @g++ -I. -std=c++11 -c entityx/help/Timer.cc -o out/Timer.o
- @g++ -I. -std=c++11 -c entityx/Event.cc -o out/Event.o
- @g++ -I. -std=c++11 -c entityx/Entity.cc -o out/Entity.o
- @g++ -I. -std=c++11 -c entityx/System.cc -o out/System.o
-
@echo " CXX/LD main"
@$(CXX) $(SPECIAL) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/components/*.o out/systems/*.o out/*.o $(LIBS)
@rm -rf xml/*.dat
};
-typedef Simple::Signal<void (const void*)> EventSignal;
+typedef Simple::Signal<bool (const void*)> EventSignal;
typedef std::shared_ptr<EventSignal> EventSignalPtr;
typedef std::weak_ptr<EventSignal> EventSignalWeakPtr;
*/
template <typename E, typename Receiver>
void subscribe(Receiver &receiver) {
- void (Receiver::*receive)(const E &) = &Receiver::receive;
+ bool (Receiver::*receive)(const E &) = &Receiver::receive;
auto sig = signal_for(Event<E>::family());
auto wrapper = EventCallbackWrapper<E>(std::bind(receive, &receiver, std::placeholders::_1));
auto connection = sig->connect(wrapper);
// Functor used as an event signal callback that casts to E.
template <typename E>
struct EventCallbackWrapper {
- explicit EventCallbackWrapper(std::function<void(const E &)> callback) : callback(callback) {}
- void operator()(const void *event) { callback(*(static_cast<const E*>(event))); }
- std::function<void(const E &)> callback;
+ explicit EventCallbackWrapper(std::function<bool(const E &)> callback) : callback(callback) {}
+ bool operator()(const void *event) { return callback(*(static_cast<const E*>(event))); }
+ std::function<bool(const E &)> callback;
};
std::vector<EventSignalPtr> handlers_;
+# gamedev CHANGE - changed output of libentityx to ../lib/
+
INC = -I..
FLG = -std=gnu++11
g++ $(INC) $(FLG) -c Event.cc -o out/Event.o
g++ $(INC) $(FLG) -c Entity.cc -o out/Entity.o
g++ $(INC) $(FLG) -c System.cc -o out/System.o
- ar rvs libentityx.a out/*.o
-# g++ out/*.o -shared -o ../entityx.so
\ No newline at end of file
+ ar rvs ../lib/libentityx.a out/*.o
+# g++ out/*.o -shared -o ../entityx.so
+ rm -rf out
ev.subscribe<AttackEvent>(*this);
}
- void receive(const AttackEvent& ae);
+ bool receive(const AttackEvent& ae);
void update(entityx::EntityManager& en, entityx::EventManager& ev, entityx::TimeDelta dt) override;
static void render(void);
};
*/
unsigned int millis(void);
-/*namespace std {
+namespace std {
template<class T>
constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
return (v > hi) ? hi : ((v > lo) ? v : lo);
}
-}*/
+}
#endif // COMMON_HPP_
* A handler for the game ending event.
* @param gee game end event data
*/
- inline void receive(const GameEndEvent &gee) {
+ inline bool receive(const GameEndEvent &gee) {
shouldRun = !(gee.really);
+ return false;
}
};
void configure(entityx::EventManager &ev);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
- void receive(const KeyDownEvent &kde);
- void receive(const MouseClickEvent &mce);
- void receive(const MouseReleaseEvent &mce);
+ bool receive(const KeyDownEvent &kde);
+ bool receive(const MouseClickEvent &mce);
+ bool receive(const MouseReleaseEvent &mce);
static void render(void);
* Handles key up events for the player.
* @param kue key up event data
*/
- void receive(const KeyUpEvent&);
+ bool receive(const KeyUpEvent&);
/**
* Handles key down events for the player.
* @param kde key down event data
*/
- void receive(const KeyDownEvent&);
+ bool receive(const KeyDownEvent&);
- void receive(const UseItemEvent&);
+ bool receive(const UseItemEvent&);
/**
* Gets the player's position.
class DialogSystem : public entityx::System<DialogSystem>, public entityx::Receiver<DialogSystem> {
public:
void configure(entityx::EventManager&);
- void receive(const MouseClickEvent&);
+ bool receive(const MouseClickEvent&);
void update(entityx::EntityManager&, entityx::EventManager&, entityx::TimeDelta) override;
};
ev.subscribe<MainSDLEvent>(*this);
}
- void receive(const MainSDLEvent& event);
+ bool receive(const MainSDLEvent& event);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
};
void configure(entityx::EventManager& ev)
{ ev.subscribe<MainSDLEvent>(*this); }
- void receive(const MainSDLEvent& mse);
+ bool receive(const MainSDLEvent& mse);
void update(entityx::EntityManager& en, entityx::EventManager& ev, entityx::TimeDelta dt) override
{ (void)en, (void)ev, (void)dt; }
};
static void render(void);
- void receive(const WindowResizeEvent&);
- void receive(const ScreenshotEvent&);
+ bool receive(const WindowResizeEvent&);
+ bool receive(const ScreenshotEvent&);
};
#endif // WINDOW_HPP_
static float isAboveGround(const vec2& p); //const;
- void receive(const BGMToggleEvent &bte);
+ bool receive(const BGMToggleEvent &bte);
void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
static void render(void);
std::vector<AttackSystem::AttackAnimation> AttackSystem::effects;
-void AttackSystem::receive(const AttackEvent& ae)
+bool AttackSystem::receive(const AttackEvent& ae)
{
attacks.emplace_front(ae);
+ return true;
}
void AttackSystem::update(entityx::EntityManager& en, entityx::EventManager& ev, entityx::TimeDelta dt)
Render::textShader.unuse();
}
-void InventorySystem::receive(const MouseClickEvent &mce)
+bool InventorySystem::receive(const MouseClickEvent &mce)
{
if (mce.button == SDL_BUTTON_RIGHT) {
game::entities.each<ItemDrop>([&](entityx::Entity e, ItemDrop& id) {
game::events.emit<UseItemEvent>(mce.position, items[0].item, &attack->second);
}
}
+ return true;
}
-void InventorySystem::receive(const MouseReleaseEvent &mre)
+bool InventorySystem::receive(const MouseReleaseEvent &mre)
{
if (movingItem != -1) {
int end = fullInventory ? items.size() : hotbarSize;
}
movingItem = -1;
- return;
+ return true;
}
}
items[movingItem].count = 0;
movingItem = -1;
}
+ return true;
}
void InventorySystem::makeDrop(const vec2& p, InventoryEntry& ie)
e.assign<Physics>();
}
-void InventorySystem::receive(const KeyDownEvent &kde)
+bool InventorySystem::receive(const KeyDownEvent &kde)
{
- if (kde.keycode == SDLK_e) {
+ if (kde.keycode == SDLK_e)
fullInventory ^= true;
- }
+ return true;
}
void InventorySystem::add(const std::string& name, int count)
vel.x /= 2.0f;
}
-void PlayerSystem::receive(const KeyUpEvent &kue)
+bool PlayerSystem::receive(const KeyUpEvent &kue)
{
auto kc = kue.keycode;
} else if (kc == getControl(5)) {
// TODO ...?
}
+ return true;
}
-void PlayerSystem::receive(const KeyDownEvent &kde)
+bool PlayerSystem::receive(const KeyDownEvent &kde)
{
auto kc = kde.keycode;
auto& loc = *player.component<Position>().get();
} else if (kc == SDLK_t) {
game::time::tick(50);
}
+ return true;
}
vec2 PlayerSystem::getPosition(void)
return width;
}
-void PlayerSystem::receive(const UseItemEvent& uie)
+bool PlayerSystem::receive(const UseItemEvent& uie)
{
static std::atomic_bool cool (true);
cool.store(true);
}, uie.item->cooldown).detach();
}
+ return true;
}
ev.subscribe<MouseClickEvent>(*this);
}
-void DialogSystem::receive(const MouseClickEvent &mce)
+bool DialogSystem::receive(const MouseClickEvent &mce)
{
game::entities.each<Position, Solid, Dialog, Name>(
[&](entityx::Entity e, Position &pos, Solid &dim, Dialog &d, Name &name) {
}
}
});
+ return true;
}
void DialogSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
--output;\r
*output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
input >>= 6;\r
- [[fallthrough]];\r
+ //[[fallthrough]];\r
case 3:\r
--output;\r
*output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
input >>= 6;\r
- [[fallthrough]];\r
+ //[[fallthrough]];\r
case 2:\r
--output;\r
*output = (char)((input | BYTE_MARK) & BYTE_MASK);\r
input >>= 6;\r
- [[fallthrough]];\r
+ //[[fallthrough]];\r
case 1:\r
--output;\r
*output = (char)(input | FIRST_BYTE_MARK[*length]);\r
using namespace ui;
-void InputSystem::receive(const MainSDLEvent& event)
+bool InputSystem::receive(const MainSDLEvent& event)
{
const auto& e = event.event;
auto& ev = game::events;
break;
}
+ return true;
}
void InputSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
static Menu* currentMenu = nullptr;
-void SDLReceiver::receive(const MainSDLEvent& mse)
+bool SDLReceiver::receive(const MainSDLEvent& mse)
{
switch (mse.event.type) {
case SDL_QUIT:
game::endGame();
- return;
+ return true;
break;
case SDL_MOUSEMOTION:
//ui::premouse.x = e.motion.x;
default:
break;
}
+ return true;
}
bool SDLReceiver::clicked = false;
}
-void WindowSystem::receive(const WindowResizeEvent &wre)
+bool WindowSystem::receive(const WindowResizeEvent &wre)
{
game::SCREEN_WIDTH = wre.x;
game::SCREEN_HEIGHT = wre.y;
glViewport(0, 0, wre.x, wre.y);
SDL_SetWindowSize(window, wre.x, wre.y);
+ return true;
}
#include <ui.hpp>
static std::atomic_bool doScreenshot;
-void WindowSystem::receive(const ScreenshotEvent &scr)
+bool WindowSystem::receive(const ScreenshotEvent &scr)
{
(void)scr;
doScreenshot.store(true);
+ return true;
}
void WindowSystem::render(void)
waitToSwap = false;
}
-void WorldSystem::receive(const BGMToggleEvent &bte)
+bool WorldSystem::receive(const BGMToggleEvent &bte)
{
if (bte.world == nullptr || world.bgm != bte.file) {
if (bgmCurrent == world.bgm)
- return;
+ return true;
Mix_FadeOutMusic(800);
bgmObj = Mix_LoadMUS(world.bgm.c_str());
Mix_PlayMusic(bgmObj, -1);
}
+ return true;
}
void WorldSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
<?xml version="1.0"?>
<World>
- <style bgm="assets/music/embark.wav" folder="assets/style/classic/">
+ <style bgm="assets/music/ozone.ogg" folder="assets/style/classic/">
<layer path="bg/bg.png"/>
<layer path="bg/bgFarMountain.png"/>
<layer path="bg/forestTileFar.png"/>
<layer path="bg/dirt.png"/>
<layer path="bg/grass.png"/>
</style>
- <generation width="600"/>
+ <generation width="1000"/>
<time>6000</time>
<link left="!town.xml"/>
</World>