@@ -11,7 +11,7 @@ liblol_a_SOURCES = \ | |||||
text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \ | text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \ | ||||
worldentity.cpp worldentity.h gradient.cpp gradient.h half.cpp half.h \ | worldentity.cpp worldentity.h gradient.cpp gradient.h half.cpp half.h \ | ||||
platform.cpp platform.h sprite.cpp sprite.h trig.cpp trig.h \ | platform.cpp platform.h sprite.cpp sprite.h trig.cpp trig.h \ | ||||
real.cpp real.h \ | |||||
real.cpp real.h emcee.cpp emcee.h \ | |||||
\ | \ | ||||
lol/unit.h \ | lol/unit.h \ | ||||
\ | \ | ||||
@@ -59,6 +59,7 @@ class ApplicationData | |||||
Application::Application(char const *name, ivec2 resolution, float framerate) | Application::Application(char const *name, ivec2 resolution, float framerate) | ||||
{ | { | ||||
Emcee::Setup(); | |||||
data = new ApplicationData(name, resolution, framerate); | data = new ApplicationData(name, resolution, framerate); | ||||
} | } | ||||
@@ -75,6 +76,7 @@ void Application::Run() | |||||
Application::~Application() | Application::~Application() | ||||
{ | { | ||||
delete data; | delete data; | ||||
Emcee::Shutdown(); | |||||
} | } | ||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -103,6 +103,7 @@ static inline int isnan(float f) | |||||
#include "application/application.h" | #include "application/application.h" | ||||
// Managers | // Managers | ||||
#include "emcee.h" | |||||
#include "ticker.h" | #include "ticker.h" | ||||
#include "forge.h" | #include "forge.h" | ||||
#include "tiler.h" | #include "tiler.h" | ||||
@@ -0,0 +1,82 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
#if defined HAVE_CONFIG_H | |||||
# include "config.h" | |||||
#endif | |||||
#include <cstdlib> | |||||
#include <stdint.h> | |||||
#include "core.h" | |||||
namespace lol | |||||
{ | |||||
/* | |||||
* Emcee implementation class | |||||
*/ | |||||
static Thread *GameThread, *DrawThread; | |||||
static Queue gametick, drawtick; | |||||
static void *GameThreadMain(void *data) | |||||
{ | |||||
while (!Ticker::Finished()) | |||||
for (;;) | |||||
{ | |||||
int tick = gametick.Pop(); | |||||
if (!tick) | |||||
break; | |||||
Ticker::TickGame(); | |||||
drawtick.Push(1); | |||||
} | |||||
drawtick.Push(0); | |||||
} | |||||
static void *DrawThreadMain(void *data) | |||||
{ | |||||
for (;;) | |||||
{ | |||||
int tick = drawtick.Pop(); | |||||
if (!tick) | |||||
break; | |||||
Ticker::TickDraw(); | |||||
} | |||||
} | |||||
void Emcee::Setup() | |||||
{ | |||||
GameThread = new Thread(GameThreadMain, NULL); | |||||
DrawThread = new Thread(DrawThreadMain, NULL); | |||||
} | |||||
void Emcee::Shutdown() | |||||
{ | |||||
} | |||||
void Emcee::SetState(Entity *entity, uint32_t state) | |||||
{ | |||||
} | |||||
void Emcee::SetStateWhenMatch(Entity *entity, uint32_t state, | |||||
Entity *other_entity, uint32_t other_state) | |||||
{ | |||||
} | |||||
} /* namespace lol */ | |||||
@@ -0,0 +1,41 @@ | |||||
// | |||||
// Lol Engine | |||||
// | |||||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||||
// This program is free software; you can redistribute it and/or | |||||
// modify it under the terms of the Do What The Fuck You Want To | |||||
// Public License, Version 2, as published by Sam Hocevar. See | |||||
// http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||||
// | |||||
// | |||||
// The Emcee class | |||||
// --------------- | |||||
// The Emcee manages tasks and their dependencies | |||||
// | |||||
#if !defined __LOL_EMCEE_H__ | |||||
#define __LOL_EMCEE_H__ | |||||
#include <stdint.h> | |||||
#include "entity.h" | |||||
namespace lol | |||||
{ | |||||
class Emcee | |||||
{ | |||||
public: | |||||
static void Setup(); | |||||
static void Shutdown(); | |||||
static void SetState(Entity *entity, uint32_t state); | |||||
static void SetStateWhenMatch(Entity *entity, uint32_t state, | |||||
Entity *other_entity, uint32_t other_state); | |||||
}; | |||||
} /* namespace lol */ | |||||
#endif // __LOL_EMCEE_H__ | |||||
@@ -68,5 +68,16 @@ void Entity::TickDraw(float deltams) | |||||
#endif | #endif | ||||
} | } | ||||
void Entity::SetState(uint32_t state) | |||||
{ | |||||
Emcee::SetState(this, state); | |||||
} | |||||
void Entity::SetStateWhenMatch(uint32_t state, | |||||
Entity *other_entity, uint32_t other_state) | |||||
{ | |||||
Emcee::SetStateWhenMatch(this, state, other_entity, other_state); | |||||
} | |||||
} /* namespace lol */ | } /* namespace lol */ | ||||
@@ -77,6 +77,19 @@ protected: | |||||
state; | state; | ||||
#endif | #endif | ||||
// Emcee begin | |||||
private: | |||||
void SetState(uint32_t newstate); | |||||
void SetStateWhenMatch(uint32_t newstate, | |||||
Entity *other_entity, uint32_t other_state); | |||||
virtual uint32_t OnStateChanged(uint32_t newstate) | |||||
{ | |||||
return m_state = newstate; | |||||
} | |||||
uint32_t m_state; | |||||
// Emcee end | |||||
private: | private: | ||||
Entity *gamenext, *drawnext, *autonext; | Entity *gamenext, *drawnext, *autonext; | ||||
int ref, autorelease, destroy; | int ref, autorelease, destroy; | ||||
@@ -17,7 +17,6 @@ | |||||
#define __LOL_THREADBASE_H__ | #define __LOL_THREADBASE_H__ | ||||
#if defined __linux__ || defined __native_client__ | #if defined __linux__ || defined __native_client__ | ||||
# include <cstring> | |||||
# include <pthread.h> | # include <pthread.h> | ||||
#elif defined _WIN32 | #elif defined _WIN32 | ||||
# include <windows.h> | # include <windows.h> | ||||
@@ -18,6 +18,13 @@ | |||||
#include "core.h" | #include "core.h" | ||||
class Moo | |||||
{ | |||||
Moo() {} | |||||
virtual int SetState(int state) { return state; } | |||||
}; | |||||
using namespace std; | using namespace std; | ||||
using namespace lol; | using namespace lol; | ||||