source: trunk/monsterz/piece.cpp @ 226

Last change on this file since 226 was 226, checked in by sam, 11 years ago

New class for board pieces.

File size: 1.2 KB
Line 
1//
2// Monsterz
3//
4// Copyright: (c) 2005-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 <cstdio>
16#include <cmath>
17
18#include "core.h"
19#include "piece.h"
20#include "monsterz.h"
21
22/*
23 * Piece implementation class
24 */
25
26class PieceData
27{
28    friend class Piece;
29
30private:
31    Game *game;
32    int tiler;
33    int x, y;
34};
35
36/*
37 * Public Piece class
38 */
39
40Piece::Piece(Game *game)
41{
42    data = new PieceData();
43    data->game = game;
44    Ticker::Ref(game);
45    data->tiler = Tiler::Register(PNG_TILES, 48, 48, 1.0f);
46}
47
48void Piece::TickGame(float deltams)
49{
50    Entity::TickGame(deltams);
51}
52
53void Piece::TickDraw(float deltams)
54{
55    Entity::TickDraw(deltams);
56
57    int id = 25;
58    data->game->GetScene()->AddTile((data->tiler << 16) | id,
59                                    data->x + 24, data->y + 177, 2, 0);
60}
61
62Piece::~Piece()
63{
64    Ticker::Unref(data->game);
65    Tiler::Deregister(data->tiler);
66    delete data;
67}
68
Note: See TracBrowser for help on using the repository browser.