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;
57 /** This class holds a sector (a part of a level) and all the game objects
58 * (badguys, player, background, tilemap, ...)
66 /// read sector from lisp file
67 void parse(LispReader& reader);
68 void parse_old_format(LispReader& reader);
69 /// write sector to lisp file
70 void write(LispWriter& writer);
72 /// activates this sector (change music, intialize player class, ...)
73 void activate(const std::string& spawnpoint = "main");
75 void action(float elapsed_time);
76 void update_game_objects();
78 void draw(DrawingContext& context);
81 void add_object(GameObject* object);
83 const std::string& get_name() const
86 void play_music(int musictype);
89 /** Checks for all possible collisions. And calls the
90 collision_handlers, which the collision_objects provide for this
92 void collision_handler();
94 void add_score(const Vector& pos, int s);
95 void add_bouncy_distro(const Vector& pos);
96 void add_broken_brick(const Vector& pos, Tile* tile);
97 void add_broken_brick_piece(const Vector& pos,
98 const Vector& movement, Tile* tile);
99 void add_bouncy_brick(const Vector& pos);
101 BadGuy* add_bad_guy(float x, float y, BadGuyKind kind);
103 void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
104 bool add_bullet(const Vector& pos, float xm, Direction dir);
106 /** Try to grab the coin at the given coordinates */
107 void trygrabdistro(const Vector& pos, int bounciness);
109 /** Try to break the brick at the given coordinates */
110 bool trybreakbrick(const Vector& pos, bool small);
112 /** Try to get the content out of a bonus box, thus emptying it */
113 void tryemptybox(const Vector& pos, Direction col_side);
115 /** Try to bumb a badguy that might we walking above Tux, thus shaking
116 the tile which the badguy is walking on an killing him this way */
117 void trybumpbadguy(const Vector& pos);
119 /** Flip the all the sector vertically. The purpose of this is to let
120 player to play the same level in a different way :) */
121 void do_vertical_flip();
124 static Sector* current()
130 static Sector* _current;
135 MusicRef level_song_fast;
138 std::string song_title;
141 // some special objects, where we need direct access
144 Background* background;
148 typedef std::vector<BadGuy*> BadGuys;
150 typedef std::vector<Trampoline*> Trampolines;
151 Trampolines trampolines;
152 typedef std::vector<FlyingPlatform*> FlyingPlatforms;
153 FlyingPlatforms flying_platforms;
155 std::vector<Upgrade*> upgrades;
156 std::vector<Bullet*> bullets;
159 typedef std::vector<InteractiveObject*> InteractiveObjects;
160 InteractiveObjects interactive_objects;
161 typedef std::vector<GameObject*> GameObjects;
162 GameObjects gameobjects;
163 GameObjects gameobjects_new; // For newly created objects
166 typedef std::vector<SpawnPoint*> SpawnPoints;
167 SpawnPoints spawnpoints;
170 bool counting_distros;