area.cpp: fix pointer dereference
[Tsunagari.git] / src / sprite.h
blob8ebe6f72f293c99b1671a66e6483b2dc3db8f969
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** sprite.h **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #ifndef SPRITE_H
8 #define SPRITE_H
10 #include <map>
11 #include <stdint.h>
12 #include <string>
14 #include <Gosu/Gosu.hpp>
15 #include <libxml/parser.h>
17 #include "common.h"
19 class Resourcer;
21 /**
22 * Sprite is an image model for displaying 2D video game entities.
24 * Each Sprite represents one 'thing' that will be rendered to the screen.
25 * Sprite can handle animated images that cycle through their frames over time.
26 * It also has the capacity to switch between a couple different images on
27 * demand.
29 * For example, you might have a Sprite for a player character with animated
30 * models for walking in each possible movement direction (up, down, left,
31 * right) along with static standing-still images for each direction. This
32 * would all be handled by one Sprite.
34 class Sprite
36 public:
37 //! Sprite Constructor
38 Sprite(Resourcer* rc, const std::string descriptor);
40 //! Sprite Destructor
41 ~Sprite();
43 //! Sprite Initializer
44 bool init();
46 //! Gosu Callback
47 void draw() const;
49 coord_t getCoordsByPixel();
50 coord_t getCoordsByTile();
52 //! Gosu Callback
53 void moveByPixel(coord_t deltac);
54 void moveByTile(coord_t deltac);
55 void setCoordsByPixel(coord_t c);
56 void setCoordsByTile(coord_t c);
58 private:
59 bool processDescriptor();
60 bool processPhases(xmlNode* phases);
61 bool processPhase(xmlNode* phase);
63 Resourcer* rc;
64 const Gosu::Image* img;
65 coord_t c;
67 const std::string descriptor;
69 //! SpriteValues XML Storage Struct
70 /*!
71 Main XML storage struct for Sprite.
73 struct SpriteValues {
74 std::string sheet;
75 coord_t tilesize; // z-coord not used
76 std::map<std::string, uint32_t> phases;
77 } xml;
80 #endif