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

core: add a Sprite class to try to factor some common logic currently

found in the game. Will be greatly improved later.
legacy
Sam Hocevar sam преди 14 години
родител
ревизия
f79a3c52b5
променени са 4 файла, в които са добавени 113 реда и са изтрити 1 реда
  1. +1
    -1
      src/Makefile.am
  2. +1
    -0
      src/core.h
  3. +67
    -0
      src/sprite.cpp
  4. +44
    -0
      src/sprite.h

+ 1
- 1
src/Makefile.am Целия файл

@@ -10,7 +10,7 @@ liblol_a_SOURCES = \
world.cpp world.h sample.cpp sample.h sampler.cpp sampler.h \
text.cpp text.h emitter.cpp emitter.h numeric.h hash.cpp hash.h \
worldentity.cpp worldentity.h image.cpp image.h gradient.cpp gradient.h \
platform.cpp platform.h \
platform.cpp platform.h sprite.cpp sprite.h \
\
sdlapp.cpp sdlapp.h sdlinput.cpp sdlinput.h \
\


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

@@ -38,6 +38,7 @@
#include "font.h"
#include "gradient.h"
#include "sample.h"
#include "sprite.h"
#include "text.h"
#include "tileset.h"
#include "world.h"


+ 67
- 0
src/sprite.cpp Целия файл

@@ -0,0 +1,67 @@
//
// 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 "core.h"

namespace lol
{

/*
* Sprite implementation class
*/

class SpriteData
{
friend class Sprite;

private:
TileSet *tileset;
vec3 pos;
int id;
};

/*
* Public Sprite class
*/

Sprite::Sprite(TileSet *tileset, int id)
: data(new SpriteData())
{
data->tileset = tileset;
data->pos = vec3(0);
data->id = id;
}

void Sprite::TickGame(float deltams)
{
Entity::TickGame(deltams);
}

void Sprite::TickDraw(float deltams)
{
Entity::TickDraw(deltams);

vec3i pos = (vec3i)data->pos;

Scene::GetDefault()->AddTile(data->tileset, data->id, pos, 0);
}

Sprite::~Sprite()
{
Tiler::Deregister(data->tileset);
delete data;
}

} /* namespace lol */


+ 44
- 0
src/sprite.h Целия файл

@@ -0,0 +1,44 @@
//
// 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 Sprite class
// ----------------
//

#if !defined __LOL_SPRITE_H__
#define __LOL_SPRITE_H__

#include "worldentity.h"
#include "tileset.h"

namespace lol
{

class SpriteData;

class Sprite : public WorldEntity
{
public:
Sprite(TileSet *tileset, int id);
virtual ~Sprite();

protected:
virtual void TickGame(float deltams);
virtual void TickDraw(float deltams);

private:
SpriteData *data;
};

} /* namespace lol */

#endif // __LOL_SPRITE_H__


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