Ver código fonte

Change the way the Scene object works.

legacy
Sam Hocevar sam 14 anos atrás
pai
commit
4c278a0895
7 arquivos alterados com 32 adições e 9 exclusões
  1. +2
    -1
      src/layer.cpp
  2. +1
    -3
      src/layer.h
  3. +2
    -2
      src/map.cpp
  4. +1
    -3
      src/map.h
  5. +18
    -0
      src/scene.cpp
  6. +3
    -0
      src/scene.h
  7. +5
    -0
      src/ticker.cpp

+ 2
- 1
src/layer.cpp Ver arquivo

@@ -40,8 +40,9 @@ Layer::~Layer()
free(data);
}

void Layer::Render(Scene *scene, int x, int y, int z)
void Layer::Render(int x, int y, int z)
{
Scene *scene = Scene::GetDefault();
for (int j = 0; j < height; j++)
for (int i = 0; i < width; i++)
if (data[j * width + i])


+ 1
- 3
src/layer.h Ver arquivo

@@ -19,8 +19,6 @@

#include <stdint.h>

#include "scene.h"

class Layer
{
public:
@@ -29,7 +27,7 @@ public:

int GetZ();

void Render(Scene *scene, int x, int y, int z);
void Render(int x, int y, int z);

private:
int width, height, altitude, orientation;


+ 2
- 2
src/map.cpp Ver arquivo

@@ -160,10 +160,10 @@ Map::~Map()
delete data;
}

void Map::Render(Scene *scene, int x, int y, int z)
void Map::Render(int x, int y, int z)
{
for (int i = 0; i < data->nlayers; i++)
data->layers[i]->Render(scene, x, y, z);
data->layers[i]->Render(x, y, z);
}

int Map::GetWidth()


+ 1
- 3
src/map.h Ver arquivo

@@ -18,8 +18,6 @@
#if !defined __DH_MAP_H__
#define __DH_MAP_H__

#include "scene.h"

class MapData;

class Map
@@ -28,7 +26,7 @@ public:
Map(char const *path);
~Map();

void Render(Scene *scene, int x, int y, int z);
void Render(int x, int y, int z);
int GetWidth();
int GetHeight();



+ 18
- 0
src/scene.cpp Ver arquivo

@@ -54,8 +54,12 @@ private:
Tile *tiles;
int ntiles;
float angle;

static Scene *scene;
};

Scene *SceneData::scene = NULL;

/*
* Public Scene class
*/
@@ -73,6 +77,20 @@ Scene::~Scene()
delete data;
}

Scene *Scene::GetDefault()
{
if (!SceneData::scene)
SceneData::scene = new Scene(0.0f);
return SceneData::scene;
}

void Scene::Reset()
{
if (SceneData::scene)
delete SceneData::scene;
SceneData::scene = NULL;
}

void Scene::AddTile(uint32_t code, int x, int y, int z, int o)
{
if ((data->ntiles % 1024) == 0)


+ 3
- 0
src/scene.h Ver arquivo

@@ -26,6 +26,9 @@ public:
Scene(float angle);
~Scene();

static Scene *GetDefault();
static void Reset();

void AddTile(uint32_t code, int x, int y, int z, int o);
void Render();



+ 5
- 0
src/ticker.cpp Ver arquivo

@@ -224,12 +224,15 @@ void Ticker::TickDraw()
{
Profiler::Start(Profiler::STAT_TICK_DRAW);

Scene::GetDefault();

/* Tick objects for the draw loop */
for (int i = Entity::DRAWGROUP_BEGIN; i < Entity::DRAWGROUP_END; i++)
{
switch (i)
{
case Entity::DRAWGROUP_HUD:
Scene::GetDefault()->Render();
Video::SetDepth(false);
break;
default:
@@ -254,6 +257,8 @@ void Ticker::TickDraw()
}
}

Scene::Reset();

Profiler::Stop(Profiler::STAT_TICK_DRAW);
Profiler::Start(Profiler::STAT_TICK_BLIT);
}


Carregando…
Cancelar
Salvar