3 // SuperTux - A Jump'n Run
4 // Copyright (C) 2004 Matthias Braun <matze@braunis.de
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef SUPERTUX_SECTOR_H
21 #define SUPERTUX_SECTOR_H
26 #include "math/vector.h"
29 #include "audio/musicref.h"
30 #include "video/drawing_context.h"
32 using namespace SuperTux;
39 class InteractiveObject;
64 /** This class holds a sector (a part of a level) and all the game objects
65 * (badguys, player, background, tilemap, ...)
73 /// read sector from lisp file
74 void parse(LispReader& reader);
75 void parse_old_format(LispReader& reader);
76 /// write sector to lisp file
77 void write(LispWriter& writer);
79 /// activates this sector (change music, intialize player class, ...)
80 void activate(const std::string& spawnpoint = "main");
81 /// get best spawn point
82 Vector get_best_spawn_point(Vector pos);
84 void action(float elapsed_time);
85 void update_game_objects();
87 void draw(DrawingContext& context);
90 void add_object(GameObject* object);
92 const std::string& get_name() const
95 void play_music(int musictype);
98 /** Checks for all possible collisions. And calls the
99 collision_handlers, which the collision_objects provide for this
101 void collision_handler();
103 void add_score(const Vector& pos, int s);
104 void add_bouncy_distro(const Vector& pos);
105 void add_broken_brick(const Vector& pos, Tile* tile);
106 void add_broken_brick_piece(const Vector& pos,
107 const Vector& movement, Tile* tile);
108 void add_bouncy_brick(const Vector& pos);
110 BadGuy* add_bad_guy(float x, float y, BadGuyKind kind);
112 void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
113 bool add_bullet(const Vector& pos, float xm, Direction dir);
114 bool add_smoke_cloud(const Vector& pos);
115 bool add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time);
117 /** Try to grab the coin at the given coordinates */
118 void trygrabdistro(const Vector& pos, int bounciness);
120 /** Try to break the brick at the given coordinates */
121 bool trybreakbrick(const Vector& pos, bool small);
123 /** Try to get the content out of a bonus box, thus emptying it */
124 void tryemptybox(const Vector& pos, Direction col_side);
126 /** Try to bumb a badguy that might we walking above Tux, thus shaking
127 the tile which the badguy is walking on an killing him this way */
128 void trybumpbadguy(const Vector& pos);
130 /** Flip the all the sector vertically. The purpose of this is to let
131 player to play the same level in a different way :) */
132 void do_vertical_flip();
134 /** Get end sequence animation */
135 int end_sequence_animation()
136 { return end_sequence_animation_type; }
139 static Sector* current()
142 /** Get total number of some stuff */
143 int get_total_badguys();
148 static Sector* _current;
153 MusicRef level_song_fast;
155 int end_sequence_animation_type;
158 std::string song_title;
161 // some special objects, where we need direct access
164 Background* background;
168 typedef std::vector<BadGuy*> BadGuys;
170 typedef std::vector<Trampoline*> Trampolines;
171 Trampolines trampolines;
172 typedef std::vector<FlyingPlatform*> FlyingPlatforms;
173 FlyingPlatforms flying_platforms;
175 std::vector<Upgrade*> upgrades;
176 std::vector<Bullet*> bullets;
177 std::vector<SmokeCloud*> smoke_clouds;
178 std::vector<Particles*> particles;
181 typedef std::vector<InteractiveObject*> InteractiveObjects;
182 InteractiveObjects interactive_objects;
183 typedef std::vector<GameObject*> GameObjects;
184 GameObjects gameobjects;
185 GameObjects gameobjects_new; // For newly created objects
188 typedef std::vector<SpawnPoint*> SpawnPoints;
189 SpawnPoints spawnpoints;
192 bool counting_distros;