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
30 #include "screen/drawing_context.h"
33 class InteractiveObject;
53 /** This class holds a sector (a part of a level) and all the game objects
54 * (badguys, player, background, tilemap, ...)
62 /// read sector from lisp file
63 void parse(LispReader& reader);
64 void parse_old_format(LispReader& reader);
65 /// write sector to lisp file
66 void write(LispWriter& writer);
68 /// activates this sector (change music, intialize player class, ...)
69 void activate(const std::string& spawnpoint = "main");
71 void action(float elapsed_time);
72 void draw(DrawingContext& context);
75 void add_object(GameObject* object);
77 const std::string& get_name() const
80 void play_music(int musictype);
83 /** Checks for all possible collisions. And calls the
84 collision_handlers, which the collision_objects provide for this
86 void collision_handler();
88 void add_score(const Vector& pos, int s);
89 void add_bouncy_distro(const Vector& pos);
90 void add_broken_brick(const Vector& pos, Tile* tile);
91 void add_broken_brick_piece(const Vector& pos,
92 const Vector& movement, Tile* tile);
93 void add_bouncy_brick(const Vector& pos);
95 BadGuy* add_bad_guy(float x, float y, BadGuyKind kind);
97 void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind);
98 bool add_bullet(const Vector& pos, float xm, Direction dir);
100 /** Try to grab the coin at the given coordinates */
101 void trygrabdistro(const Vector& pos, int bounciness);
103 /** Try to break the brick at the given coordinates */
104 bool trybreakbrick(const Vector& pos, bool small);
106 /** Try to get the content out of a bonus box, thus emptying it */
107 void tryemptybox(const Vector& pos, Direction col_side);
109 /** Try to bumb a badguy that might we walking above Tux, thus shaking
110 the tile which the badguy is walking on an killing him this way */
111 void trybumpbadguy(const Vector& pos);
114 static Sector* current()
120 static Sector* _current;
125 MusicRef level_song_fast;
128 std::string song_title;
131 // some special objects, where we need direct access
134 Background* background;
138 typedef std::vector<BadGuy*> BadGuys;
140 typedef std::vector<Trampoline*> Trampolines;
141 Trampolines trampolines;
142 typedef std::vector<FlyingPlatform*> FlyingPlatforms;
143 FlyingPlatforms flying_platforms;
145 std::vector<Upgrade*> upgrades;
146 std::vector<Bullet*> bullets;
149 typedef std::vector<InteractiveObject*> InteractiveObjects;
150 InteractiveObjects interactive_objects;
151 typedef std::vector<GameObject*> GameObjects;
152 GameObjects gameobjects;
153 GameObjects gameobjects_new; // For newly created objects
156 typedef std::vector<SpawnPoint*> SpawnPoints;
157 SpawnPoints spawnpoints;
160 bool counting_distros;