supertux
sprite_data.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_SPRITE_SPRITE_DATA_HPP
18 #define HEADER_SUPERTUX_SPRITE_SPRITE_DATA_HPP
19 
20 #include <map>
21 #include <string>
22 #include <vector>
23 
24 #include "video/surface_ptr.hpp"
25 
26 class ReaderMapping;
27 
28 class SpriteData final
29 {
30 public:
32  SpriteData(const ReaderMapping& cur);
33 
34  const std::string& get_name() const
35  {
36  return name;
37  }
38 
39 private:
40  friend class Sprite;
41 
42  struct Action
43  {
44  Action();
45 
46  std::string name;
47 
49  float x_offset;
50  float y_offset;
51 
53  float hitbox_w;
54 
56  float hitbox_h;
57 
59  float fps;
60 
62  int loops;
63 
66  bool has_custom_loops;
67 
68  std::vector<SurfacePtr> surfaces;
69  };
70 
71  typedef std::map <std::string, std::unique_ptr<Action> > Actions;
72 
73  void parse_action(const ReaderMapping& mapping);
75  const Action* get_action(const std::string& act) const;
76 
77  Actions actions;
78  std::string name;
79 };
80 
81 #endif
82 
83 /* EOF */
Definition: sprite_data.hpp:28
Definition: sprite.hpp:25
SpriteData(const ReaderMapping &cur)
cur has to be a pointer to data in the form of ((hitbox 5 10 0 0) ...)
Definition: sprite_data.cpp:44
Definition: reader_mapping.hpp:31