(initial-delay 0)
(fire-delay 2)
(ammo -1)
+ (direction "left")
(x 2484)
(y 2554.679)
- (direction "left")
)
(door
(sector "main")
(platform
(name "final_lift")
(running #f)
- (x 6464)
- (y 384)
(sprite "images/objects/platforms/small.sprite")
(path
(node
(platform
(name "blocker1")
(running #f)
- (x 2912)
- (y 2144)
(sprite "images/objects/platforms/vertical-wood.sprite")
(path
(node
(platform
(name "blocker2")
(running #f)
- (x 2944)
- (y 2144)
(sprite "images/objects/platforms/vertical-wood.sprite")
(path
(node
(platform
(name "blocker4")
(running #f)
- (x 3008)
- (y 2144)
(sprite "images/objects/platforms/vertical-wood.sprite")
(path
(node
(platform
(name "blocker5")
(running #f)
- (x 3040)
- (y 2144)
(sprite "images/objects/platforms/vertical-wood.sprite")
(path
(node
(platform
(name "blocker6")
(running #f)
- (x 3072)
- (y 2144)
(sprite "images/objects/platforms/vertical-wood.sprite")
(path
(node
(platform
(name "blocker3")
(running #f)
- (x 2976)
- (y 2144)
(sprite "images/objects/platforms/vertical-wood.sprite")
(path
(node
(y 800)
)
(mrbomb
+ (direction "left")
(x 1184)
(y 2464)
- (direction "left")
)
(mrbomb
(x 4128)
(y 2144)
)
(poisonivy
+ (direction "right")
(x 4512)
(y 2368)
- (direction "right")
)
(poisonivy
(x 4706)
Tux.do_cheer();
end_level();
")
+ (sprite "images/objects/keys/key_air.sprite")
(x 6608)
(y 80)
- (sprite "images/objects/keys/key_air.sprite")
)
(powerup
+ (sprite "images/powerups/fireflower/fireflower.sprite")
(x 3008)
(y 544)
- (sprite "images/powerups/fireflower/fireflower.sprite")
)
(scripttrigger
(script "final_lift.goto_node(0);")
(y 480)
)
(sspiky
+ (direction "left")
(x 4576)
(y 704)
- (direction "left")
)
(snail
(x 3456)
Tux.activate();
this.door_opened <- true;
}")
+ (sprite "images/objects/switch/right.sprite")
(x 2688)
(y 2464)
- (sprite "images/objects/switch/right.sprite")
)
(tilemap
(solid #f)
(y 2270)
)
(walkingleaf
+ (direction "right")
(x 4706)
(y 2400)
- (direction "right")
)
(walkingleaf
(x 5090)
#include "badguy/badguy.hpp"
-#include <math.h>
-
#include "audio/sound_manager.hpp"
#include "object/bullet.hpp"
#include "object/player.hpp"
#include "supertux/tile.hpp"
#include "util/reader.hpp"
+#include <math.h>
+#include <sstream>
+
static const float SQUISH_TIME = 2;
static const float X_OFFSCREEN_DISTANCE = 1600;
#include "supertux/sector.hpp"
#include "util/reader.hpp"
+#include <stdexcept>
+
Dispenser::Dispenser(const Reader& reader) :
BadGuy(reader, "images/creatures/dispenser/dispenser.sprite"),
cycle(),
if(state == BT_SHOW_INFO)
{
Vector offset;
- if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > SCREEN_HEIGHT - 20)
+ if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > SCREEN_SIZE.height - 20)
offset = Vector(size.x, - 10);
else if(pos.x + tanslation.x < 100)
offset = Vector(size.x, 0);
if(mouse_left_button)
{
- pos.x += int(event.motion.xrel * float(SCREEN_WIDTH)/g_screen->w);
- pos.y += int(event.motion.yrel * float(SCREEN_HEIGHT)/g_screen->h);
+ pos.x += int(event.motion.xrel * float(SCREEN_SIZE.width)/g_screen->w);
+ pos.y += int(event.motion.yrel * float(SCREEN_SIZE.height)/g_screen->h);
caught_event = true;
}
if(event.button.x > pos.x-12 && event.button.x < pos.x+16 + buttons_box.x*buttons_size.x &&
#include "gui/menu.hpp"
#include <math.h>
+#include <stdexcept>
#include "control/joystickkeyboardcontroller.hpp"
#include "gui/menu_item.hpp"
Menu::Menu() :
hit_item(),
- pos_x(),
- pos_y(),
+ pos(),
menuaction(),
delete_character(),
mn_input_char(),
delete_character = 0;
mn_input_char = '\0';
- pos_x = SCREEN_WIDTH/2;
- pos_y = SCREEN_HEIGHT/2;
+ pos = SCREEN_SIZE/2.0f;
arrange_left = 0;
active_item = -1;
}
void
-Menu::set_pos(float x, float y, float rw, float rh)
+Menu::set_pos(Vector loc, Vector r)
{
- pos_x = x + get_width() * rw;
- pos_y = y + get_height() * rh;
+ pos = loc + get_size() * r;
}
/* Add an item to a menu */
#include <memory>
#include <SDL.h>
+#include "math/sizef.hpp"
#include "video/color.hpp"
#include "video/surface_ptr.hpp"
void set_active_item(int id);
void draw(DrawingContext& context);
- void set_pos(float x, float y, float rw = 0, float rh = 0);
+ void set_pos(Vector loc, Vector r = Vector(0,0));
void event(const SDL_Event& event);
protected:
void additem(MenuItem* pmenu_item);
- float get_width() const;
- float get_height() const;
+ Sizef get_size() const;
private:
void check_controlfield_change_event(const SDL_Event& event);
int hit_item;
// position of the menu (ie. center of the menu, not top/left)
- float pos_x;
- float pos_y;
+ Vector pos;
/** input event for the menu (up, down, left, right, etc.) */
MenuAction menuaction;
#include <iosfwd>
-class Sizef;
+#include "math/vector.hpp"
class Size
{
lhs.height / divisor);
}
+inline Vector operator/(const Size& lhs, float divisor)
+{
+ return Vector(lhs.width / divisor,
+ lhs.height / divisor);
+}
+
inline Size operator+(const Size& lhs, const Size& rhs)
{
return Size(lhs.width + rhs.width,
#include <iosfwd>
+#include "math/vector.hpp"
+
class Size;
class Sizef
lhs.height + rhs.height);
}
+inline Vector operator+(const Vector& lhs, const Sizef& rhs) const
+{
+ return Vector(lhs.x + rhs.width,
+ lhs.y + rhs.height);
+}
+
+inline Vector operator*(const Vector& lhs, const Sizef& rhs) const
+{
+ return Vector(lhs.x * rhs.width,
+ lhs.y * rhs.height);
+}
+
+inline Vector operator*(const Sizefr& lhs, const Vector& rhs) const
+{
+ return Vector(lhs.width * rhs.x,
+ lhs.height * rhs.y);
+}
+
inline Sizef operator-(const Sizef& lhs, const Sizef& rhs)
{
return Sizef(lhs.width - rhs.width,
#include "util/log.hpp"
#include "util/reader.hpp"
+#include <stdexcept>
+
Background::Background() :
alignment(NO_ALIGNMENT),
layer(LAYER_BACKGROUND0),
#include "supertux/object_factory.hpp"
#include "supertux/sector.hpp"
+#include <stdexcept>
+
BonusBlock::BonusBlock(const Vector& pos, int data) :
Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
contents(),
#include "supertux/object_factory.hpp"
#include "util/reader.hpp"
+#include <stdexcept>
+
Gradient::Gradient() :
layer(LAYER_BACKGROUND0),
gradient_top(),
#include "supertux/tile.hpp"
#include "util/reader.hpp"
+#include <sstream>
+
Ispy::Ispy(const Reader& reader) :
MovingSprite(reader, "images/objects/ispy/ispy.sprite", LAYER_TILES+5, COLGROUP_DISABLED),
state(ISPYSTATE_IDLE),
#include "sprite/sprite_manager.hpp"
#include "util/reader.hpp"
+#include <stdexcept>
+
MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name,
int layer, CollisionGroup collision_group) :
sprite_name(sprite_name),
#include "supertux/sector.hpp"
#include "util/reader.hpp"
+#include <sstream>
+
PowerUp::PowerUp(const Reader& lisp) :
MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING),
physic(),
#include "supertux/sector.hpp"
#include "util/reader.hpp"
+#include <sstream>
+#include <stdexcept>
+
namespace {
const std::string BUTTON_SOUND = "sounds/switch.ogg";
//14 -> 8
#include "supertux/globals.hpp"
#include "supertux/sector.hpp"
+#include <stdexcept>
+
SpriteParticle::SpriteParticle(std::string sprite_name, std::string action,
Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration,
int drawing_layer) :
void
TileMap::draw(DrawingContext& context)
{
- // skip draw if current opacity is set to 0.0
+ // skip draw if current opacity is 0.0
if (current_alpha == 0.0) return;
context.push_transform();
if(drawing_effect != 0) context.set_drawing_effect(drawing_effect);
if(current_alpha != 1.0) context.set_alpha(current_alpha);
- float trans_x = roundf(context.get_translation().x);
- float trans_y = roundf(context.get_translation().y);
- context.set_translation(Vector(int(trans_x * speed_x),
- int(trans_y * speed_y)));
+ if(!solid) {
+ float trans_x = roundf(context.get_translation().x);
+ float trans_y = roundf(context.get_translation().y);
+ context.set_translation(Vector(int(trans_x * speed_x),
+ int(trans_y * speed_y)));
+ }
- /** if we don't round here, we'll have a 1 pixel gap on screen sometimes.
- * I have no idea why */
- float start_x = int((roundf(context.get_translation().x) - roundf(x_offset)) / 32) * 32 + roundf(x_offset);
- float start_y = int((roundf(context.get_translation().y) - roundf(y_offset)) / 32) * 32 + roundf(y_offset);
- float end_x = std::min(start_x + SCREEN_WIDTH + 32, float(width * 32 + roundf(x_offset)));
- float end_y = std::min(start_y + SCREEN_HEIGHT + 32, float(height * 32 + roundf(y_offset)));
- int tsx = int((start_x - roundf(x_offset)) / 32); // tilestartindex x
- int tsy = int((start_y - roundf(y_offset)) / 32); // tilestartindex y
+ float start_x = context.get_translation().x;
+ float start_y = context.get_translation().y;
+ float end_x = start_x + SCREEN_WIDTH + 32;
+ float end_y = start_y + SCREEN_HEIGHT + 32;
+ int tsx = std::max(int((start_x - x_offset) / 32), 0); // tilestartindex x
+ int tsy = std::max(int((start_y - y_offset) / 32), 0); // tilestartindex y
Vector pos;
int tx, ty;
- for(pos.x = start_x, tx = tsx; pos.x < end_x; pos.x += 32, ++tx) {
- for(pos.y = start_y, ty = tsy; pos.y < end_y; pos.y += 32, ++ty) {
- if ((tx < 0) || (ty < 0) || (tiles[ty*width + tx] == 0)) continue;
+ for(pos.x = start_x, tx = tsx; (pos.x < end_x) && (tx < width); pos.x += 32, ++tx) {
+ for(pos.y = start_y, ty = tsy; (pos.y < end_y) && (ty < height); pos.y += 32, ++ty) {
+ if (tiles[ty*width + tx] == 0) continue;
const Tile* tile = tileset->get(tiles[ty*width + tx]);
assert(tile != 0);
tile->draw(context, pos, z_pos);
#include "util/file_system.hpp"
#include "util/reader.hpp"
+#include <sstream>
+#include <stdexcept>
+
+
SpriteManager::SpriteManager() :
sprites()
{
class JoystickKeyboardController;
class PlayerStatus;
class ScreenManager;
+class Size;
class SoundManager;
class SpriteManager;
class TextureManager;
class TileManager;
class TileSet;
-/** The width of the display (this is a logical value, not the
+/** The width/height of the display (this is a logical value, not the
physical value, since aspect_ration and projection_area might
shrink or scale things) */
-extern int SCREEN_WIDTH;
-
-/** The width of the display (this is a logical value, not the
- physical value, since aspect_ration and projection_area might
- shrink or scale things) */
-extern int SCREEN_HEIGHT;
+extern Size SCREEN_SIZE;
// global variables
extern JoystickKeyboardController* g_main_controller;
#include "supertux/tile_set.hpp"
#include "trigger/secretarea_trigger.hpp"
+#include <sstream>
+#include <stdexcept>
+
using namespace std;
Level::Level() :
#include "supertux/resources.hpp"
#include "util/gettext.hpp"
+#include <sstream>
+
LevelIntro::LevelIntro(const Level* level, const Statistics* best_level_statistics) :
level(level),
best_level_statistics(best_level_statistics),
#include "supertux/menu/options_menu.hpp"
-#include <algorithm>
-
#include "audio/sound_manager.hpp"
#include "gui/menu_manager.hpp"
#include "supertux/gameconfig.hpp"
#include "util/string_util.hpp"
#include "video/renderer.hpp"
+#include <algorithm>
+#include <sstream>
+
enum OptionsMenuIDs {
MNID_FULLSCREEN,
MNID_FULLSCREEN_RESOLUTION,
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <math.h>
+#include <sstream>
#include "audio/sound_manager.hpp"
#include "util/writer.hpp"
#include "util/reader.hpp"
#include "video/drawing_context.hpp"
+#include <sstream>
+#include <stdexcept>
+
static const float DEFAULT_SPEED = 20;
static const float LEFT_BORDER = 50;
static const float SCROLL = 60;
#include "util/reader.hpp"
#include "video/drawing_context.hpp"
+#include <sstream>
#include <version.h>
TitleScreen::TitleScreen(PlayerStatus* player_status) :
#include "supertux/sector.hpp"
#include "trigger/switch.hpp"
+#include <sstream>
+
namespace {
const std::string SWITCH_SOUND = "sounds/switch.ogg";
}
#include <config.h>
+#include <sstream>
#include <stdlib.h>
#include <string.h>
#include <stdexcept>
#include "video/sdl/sdl_renderer.hpp"
-#include <iomanip>
-#include <iostream>
-#include <physfs.h>
-
#include "video/drawing_request.hpp"
#include "video/sdl/sdl_surface_data.hpp"
#include "video/sdl/sdl_texture.hpp"
+#include <iomanip>
+#include <iostream>
+#include <physfs.h>
+#include <sstream>
+#include <stdexcept>
+
namespace {
SDL_Surface *apply_alpha(SDL_Surface *src, float alpha_factor)
#include <SDL_image.h>
#include <assert.h>
#include <iostream>
+#include <sstream>
+#include <stdexcept>
#include "math/rect.hpp"
#include "physfs/physfs_sdl.hpp"
#include "util/file_system.hpp"
#include "util/log.hpp"
-#include "video/gl/gl_texture.hpp"
#include "video/sdl_surface_ptr.hpp"
+#include "video/texture.hpp"
#include "video/video_systems.hpp"
+#ifdef HAVE_OPENGL
+#include "video/gl/gl_texture.hpp"
+#endif
+
TextureManager::TextureManager() :
image_textures()
#ifdef HAVE_OPENGL
#include <config.h>
#include "supertux/gameconfig.hpp"
-#include "video/gl/gl_lightmap.hpp"
-#include "video/gl/gl_renderer.hpp"
-#include "video/gl/gl_surface_data.hpp"
-#include "video/gl/gl_texture.hpp"
#include "video/lightmap.hpp"
#include "video/renderer.hpp"
#include "video/sdl/sdl_lightmap.hpp"
#include "video/texture.hpp"
#include "video/video_systems.hpp"
+#ifdef HAVE_OPENGL
+#include "video/gl/gl_lightmap.hpp"
+#include "video/gl/gl_renderer.hpp"
+#include "video/gl/gl_surface_data.hpp"
+#include "video/gl/gl_texture.hpp"
+#endif
+
Renderer*
VideoSystem::new_renderer()
{
{
case AUTO_VIDEO:
#ifdef HAVE_OPENGL
- log_info << "new GL renderer\n";
- return new GLRenderer();
-#else
- log_warning << "new SDL renderer\n";
- return new SDLRenderer();
+ try {
+ log_info << "new GL renderer\n";
+ return new GLRenderer();
+ } catch(std::runtime_error& e) {
+ log_warning << "Error creating GL renderer: " << e.what() << std::endl;
#endif
+ log_warning << "new SDL renderer\n";
+ return new SDLRenderer();
#ifdef HAVE_OPENGL
+ }
case OPENGL:
log_info << "new GL renderer\n";
return new GLRenderer();
#endif
case PURE_SDL:
- log_warning << "new SDL renderer\n";
+ log_info << "new SDL renderer\n";
return new SDLRenderer();
default:
assert(0 && "invalid video system in config");