Преглед на файлове

core: start working on the Emcee class.

legacy
Sam Hocevar sam преди 13 години
родител
ревизия
3d3ec36548
променени са 9 файла, в които са добавени 158 реда и са изтрити 2 реда
  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 Целия файл

@@ -11,7 +11,7 @@ liblol_a_SOURCES = \
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 \
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 \
\


+ 2
- 0
src/application/application.cpp Целия файл

@@ -59,6 +59,7 @@ class ApplicationData

Application::Application(char const *name, ivec2 resolution, float framerate)
{
Emcee::Setup();
data = new ApplicationData(name, resolution, framerate);
}

@@ -75,6 +76,7 @@ void Application::Run()
Application::~Application()
{
delete data;
Emcee::Shutdown();
}

} /* namespace lol */


+ 1
- 0
src/core.h Целия файл

@@ -103,6 +103,7 @@ static inline int isnan(float f)
#include "application/application.h"

// Managers
#include "emcee.h"
#include "ticker.h"
#include "forge.h"
#include "tiler.h"


+ 82
- 0
src/emcee.cpp Целия файл

@@ -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 Целия файл

@@ -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 Целия файл

@@ -68,5 +68,16 @@ void Entity::TickDraw(float deltams)
#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 */


+ 13
- 0
src/entity.h Целия файл

@@ -77,6 +77,19 @@ protected:
state;
#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:
Entity *gamenext, *drawnext, *autonext;
int ref, autorelease, destroy;


+ 0
- 1
src/thread/threadbase.h Целия файл

@@ -17,7 +17,6 @@
#define __LOL_THREADBASE_H__

#if defined __linux__ || defined __native_client__
# include <cstring>
# include <pthread.h>
#elif defined _WIN32
# include <windows.h>


+ 7
- 0
test/debug/sandbox.cpp Целия файл

@@ -18,6 +18,13 @@

#include "core.h"

class Moo
{
Moo() {}

virtual int SetState(int state) { return state; }
};

using namespace std;
using namespace lol;



Зареждане…
Отказ
Запис