Kaynağa Gözat

core: start working on the Emcee class.

legacy
Sam Hocevar sam 13 yıl önce
ebeveyn
işleme
3d3ec36548
9 değiştirilmiş dosya ile 158 ekleme ve 2 silme
  1. +1
    -1
      src/Makefile.am
  2. +2
    -0
      src/application/application.cpp
  3. +1
    -0
      src/core.h
  4. +82
    -0
      src/emcee.cpp
  5. +41
    -0
      src/emcee.h
  6. +11
    -0
      src/entity.cpp
  7. +13
    -0
      src/entity.h
  8. +0
    -1
      src/thread/threadbase.h
  9. +7
    -0
      test/debug/sandbox.cpp

+ 1
- 1
src/Makefile.am Dosyayı Görüntüle

@@ -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 \
\ \


+ 2
- 0
src/application/application.cpp Dosyayı Görüntüle

@@ -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 */


+ 1
- 0
src/core.h Dosyayı Görüntüle

@@ -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"


+ 82
- 0
src/emcee.cpp Dosyayı Görüntüle

@@ -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 */


+ 41
- 0
src/emcee.h Dosyayı Görüntüle

@@ -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__


+ 11
- 0
src/entity.cpp Dosyayı Görüntüle

@@ -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 */



+ 13
- 0
src/entity.h Dosyayı Görüntüle

@@ -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;


+ 0
- 1
src/thread/threadbase.h Dosyayı Görüntüle

@@ -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>


+ 7
- 0
test/debug/sandbox.cpp Dosyayı Görüntüle

@@ -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;




Yükleniyor…
İptal
Kaydet