source: trunk/src/sprite.cpp @ 862

Last change on this file since 862 was 862, checked in by sam, 8 years ago

core: add a Sprite class to try to factor some common logic currently
found in the game. Will be greatly improved later.

File size: 1.1 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "core.h"
16
17namespace lol
18{
19
20/*
21 * Sprite implementation class
22 */
23
24class SpriteData
25{
26    friend class Sprite;
27
28private:
29    TileSet *tileset;
30    vec3 pos;
31    int id;
32};
33
34/*
35 * Public Sprite class
36 */
37
38Sprite::Sprite(TileSet *tileset, int id)
39  : data(new SpriteData())
40{
41    data->tileset = tileset;
42    data->pos = vec3(0);
43    data->id = id;
44}
45
46void Sprite::TickGame(float deltams)
47{
48    Entity::TickGame(deltams);
49}
50
51void Sprite::TickDraw(float deltams)
52{
53    Entity::TickDraw(deltams);
54
55    vec3i pos = (vec3i)data->pos;
56
57    Scene::GetDefault()->AddTile(data->tileset, data->id, pos, 0);
58}
59
60Sprite::~Sprite()
61{
62    Tiler::Deregister(data->tileset);
63    delete data;
64}
65
66} /* namespace lol */
67
Note: See TracBrowser for help on using the repository browser.