Addon::parse(const Reader& lisp)
{
try {
- lisp.get("kind", kind);
+ lisp.get("kind", kind);
lisp.get("title", title);
lisp.get("author", author);
lisp.get("license", license);
Addon::write(lisp::Writer& writer) const
{
writer.start_list("supertux-addoninfo");
- if (kind != "") writer.write("kind", kind);
+ if (kind != "") writer.write("kind", kind);
if (title != "") writer.write("title", title);
if (author != "") writer.write("author", author);
if (license != "") writer.write("license", license);
writer.end_list("supertux-addoninfo");
}
-void
+void
Addon::write(std::string fname) const
{
lisp::Writer writer(fname);
write(writer);
}
-bool
+bool
Addon::operator==(Addon addon2) const
{
std::string s1 = this->get_md5();
if (this->title != addon2.title) return false;
if (this->author != addon2.author) return false;
if (this->kind != addon2.kind) return false;
- return true;
+ return true;
}
/* EOF */
void write(std::string fname) const;
/**
- * Checks if Add-on is the same as given one.
+ * Checks if Add-on is the same as given one.
* If available, checks MD5 sum, else relies on kind, author and title alone.
*/
bool operator==(Addon addon2) const;
author(),
license(),
http_url(),
- suggested_filename(),
- installed_physfs_filename(),
+ suggested_filename(),
+ installed_physfs_filename(),
installed_absolute_filename(),
stored_md5(),
installed(),
if(!addons_lisp) throw std::runtime_error("Downloaded file is not an Add-on list");
lisp::ListIterator iter(addons_lisp);
- while(iter.next())
+ while(iter.next())
{
const std::string& token = iter.item();
- if(token != "supertux-addoninfo")
+ if(token != "supertux-addoninfo")
{
log_warning << "Unknown token '" << token << "' in Add-on list" << std::endl;
continue;
addon->installed = false;
addon->loaded = false;
- // make sure the list of known Add-ons does not already contain this one
+ // make sure the list of known Add-ons does not already contain this one
bool exists = false;
for (std::vector<Addon*>::const_iterator i = addons.begin(); i != addons.end(); i++) {
if (**i == *addon) {
- exists = true;
- break;
+ exists = true;
+ break;
}
}
- if (exists)
+ if (exists)
{
// do nothing
}
- else if (addon->suggested_filename.find_first_not_of("match.quiz-proxy_gwenblvdjfks0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos)
+ else if (addon->suggested_filename.find_first_not_of("match.quiz-proxy_gwenblvdjfks0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != std::string::npos)
{
// make sure the Add-on's file name does not contain weird characters
log_warning << "Add-on \"" << addon->title << "\" contains unsafe file name. Skipping." << std::endl;
if (addon->get_md5() != addon->stored_md5) {
addon->installed = false;
PHYSFS_delete(fileName.c_str());
- std::string why = "MD5 checksums differ";
+ std::string why = "MD5 checksums differ";
throw std::runtime_error("Downloading Add-on failed: " + why);
}
addon->loaded = true;
addons.push_back(addon);
- // check if the Addon is disabled
+ // check if the Addon is disabled
if (std::find(ignored_addon_filenames.begin(), ignored_addon_filenames.end(), fileName) != ignored_addon_filenames.end()) {
unload(addon);
}
void
AddonManager::read(const Reader& lisp)
{
- lisp.get("disabled-addons", ignored_addon_filenames);
+ lisp.get("disabled-addons", ignored_addon_filenames);
}
void
AddonManager::write(lisp::Writer& writer)
{
- writer.write("disabled-addons", ignored_addon_filenames);
+ writer.write("disabled-addons", ignored_addon_filenames);
}
/* EOF */
// implied warranty of any kind.
//
// The translators/modifiers do not claim:
-// (1) that MD5 will do what you think it does;
-// (2) that this translation/ modification is accurate; or
+// (1) that MD5 will do what you think it does;
+// (2) that this translation/ modification is accurate; or
// (3) that this software is "merchantible."
//
// based on:
// is identified as the "RSA Data Security, Inc. MD5 Message-Digest
// Algorithm" in all material mentioning or referencing this software
// or this function.
-//
+//
// License is also granted to make and use derivative works provided
// that such works are identified as "derived from the RSA Data
// Security, Inc. MD5 Message-Digest Algorithm" in all material
// mentioning or referencing the derived work.
-//
+//
// RSA Data Security, Inc. makes no representations concerning either
// the merchantability of this software or the suitability of this
// software for any particular purpose. It is provided "as is"
// without express or implied warranty of any kind.
-//
+//
// These notices must be retained in any copies of any part of this
// documentation and/or software.
-//
+//
#include "addon/md5.hpp"
finalize ();
}
-MD5::MD5(std::istream& stream) :
+MD5::MD5(std::istream& stream) :
finalized()
{
init(); // must called by all constructors
// implied warranty of any kind.
//
// The translators/modifiers do not claim:
-// (1) that MD5 will do what you think it does;
-// (2) that this translation/ modification is accurate; or
+// (1) that MD5 will do what you think it does;
+// (2) that this translation/ modification is accurate; or
// (3) that this software is "merchantible."
//
// based on:
// is identified as the "RSA Data Security, Inc. MD5 Message-Digest
// Algorithm" in all material mentioning or referencing this software
// or this function.
-//
+//
// License is also granted to make and use derivative works provided
// that such works are identified as "derived from the RSA Data
// Security, Inc. MD5 Message-Digest Algorithm" in all material
// mentioning or referencing the derived work.
-//
+//
// RSA Data Security, Inc. makes no representations concerning either
// the merchantability of this software or the suitability of this
// software for any particular purpose. It is provided "as is"
// without express or implied warranty of any kind.
-//
+//
// These notices must be retained in any copies of any part of this
// documentation and/or software.
-//
+//
#ifndef HEADER_SUPERTUX_ADDON_MD5_HPP
#define HEADER_SUPERTUX_ADDON_MD5_HPP
#include <fstream>
#include <stdint.h>
-class MD5
+class MD5
{
public:
- MD5();
+ MD5();
MD5(uint8_t* string); /**< digest string, finalize */
MD5(std::istream& stream); /**< digest stream, finalize */
MD5(FILE *file); /**< digest file, close, finalize */
vorbis_file(),
loop_begin(),
loop_at(),
- normal_buffer_loop()
+ normal_buffer_loop()
{
this->file = file;
music->get("file", raw_music_file);
music->get("loop-begin", loop_begin);
music->get("loop-at", loop_at);
-
+
if(loop_begin < 0) {
throw SoundError("can't loop from negative value");
}
#include "util/log.hpp"
SoundManager::SoundManager() :
- device(0),
- context(0),
- sound_enabled(false),
+ device(0),
+ context(0),
+ sound_enabled(false),
buffers(),
sources(),
update_list(),
} catch(std::exception& e) {
if(context != NULL) {
alcDestroyContext(context);
- context = NULL;
+ context = NULL;
}
if(device != NULL) {
alcCloseDevice(device);
#include "util/log.hpp"
StreamSoundSource::StreamSoundSource() :
- file(0),
- fade_state(NoFading),
+ file(0),
+ fade_state(NoFading),
fade_start_time(),
fade_time(),
looping(false)
static const float RECOVER_TIME = .5;
AngryStone::AngryStone(const Reader& reader) :
- BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"),
+ BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"),
attackDirection(),
oldWallDirection(),
timer(),
/** Set the badguy to kill/falling state, which makes him falling of
the screen (his sprite is turned upside-down) */
virtual void kill_fall();
-
+
/** Call this, if you use custom kill_fall() or kill_squashed(GameObject& object) */
virtual void run_dead_script();
/** called immediately before the first call to initialize */
virtual void initialize();
-
+
/** called when the badguy has been activated. (As a side effect the
dir variable might have been changed so that it faces towards
the player. */
bool is_active();
/** changes colgroup_active. Also calls set_group when badguy is in STATE_ACTIVE */
- void set_colgroup_active(CollisionGroup group);
+ void set_colgroup_active(CollisionGroup group);
private:
void try_activate();
protected:
Physic physic;
-public:
+public:
/** Count this badguy to the statistics? This value should not be
changed during runtime. */
bool countMe;
protected:
/** true if initialize() has already been called */
- bool is_initialized;
+ bool is_initialized;
Vector start_position;
/** true if state was STATE_ACTIVE at the beginning of the last call
to update() */
- bool is_active_flag;
+ bool is_active_flag;
Timer state_timer;
/** true if we touched something solid from above and
update_on_ground_flag was called last frame */
- bool on_ground_flag;
+ bool on_ground_flag;
/** floor normal stored the last time when update_on_ground_flag was
called and we touched something solid from above */
- Vector floor_normal;
-
+ Vector floor_normal;
+
/** CollisionGroup the badguy should be in while active */
CollisionGroup colgroup_active;
#include "supertux/sector.hpp"
Bomb::Bomb(const Vector& pos, Direction dir, std::string custom_sprite /*= "images/creatures/mr_bomb/mr_bomb.sprite"*/ ) :
- BadGuy( pos, dir, custom_sprite ),
+ BadGuy( pos, dir, custom_sprite ),
state(),
- grabbed(false),
+ grabbed(false),
grabber(NULL),
ticking()
{
// Bomb class.
if (grabber != NULL) {
Player* player = dynamic_cast<Player*>(grabber);
-
+
if (player)
player->stop_grabbing();
}
#include "badguy/badguy.hpp"
#include "object/portable.hpp"
-class Bomb : public BadGuy,
+class Bomb : public BadGuy,
public Portable
{
public:
#include "supertux/sector.hpp"
namespace{
- static const float CAPTAIN_WALK_SPEED = 100;
+ static const float CAPTAIN_WALK_SPEED = 100;
static const float BOARDING_SPEED = 200;
}
x1 = bbox.p2.x + 1;
x2 = bbox.p2.x + width;
}
- return ((!Sector::current()->is_free_of_statics(Rectf(x1, y1a, x2, y2a))) &&
+ return ((!Sector::current()->is_free_of_statics(Rectf(x1, y1a, x2, y2a))) &&
(Sector::current()->is_free_of_statics(Rectf(x1, y1b, x2, y2b))));
}
static const std::string DART_SOUND = "sounds/flame.wav";
Dart::Dart(const Reader& reader) :
- BadGuy(reader, "images/creatures/dart/dart.sprite"),
+ BadGuy(reader, "images/creatures/dart/dart.sprite"),
parent(0),
sound_source()
{
}
Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent = 0) :
- BadGuy(pos, d, "images/creatures/dart/dart.sprite"),
+ BadGuy(pos, d, "images/creatures/dart/dart.sprite"),
parent(parent),
sound_source()
{
void initialize();
void activate();
void deactivate();
-
+
void active_update(float elapsed_time);
void collision_solid(const CollisionHit& hit);
DartTrap::DartTrap(const Reader& reader) :
BadGuy(reader, "images/creatures/darttrap/darttrap.sprite", LAYER_TILES-1),
- initial_delay(0),
- fire_delay(2),
- ammo(-1),
+ initial_delay(0),
+ fire_delay(2),
+ ammo(-1),
state(IDLE),
fire_timer()
{
{
if (dispense_timer.check()) {
// auto always shoots in Tux's direction
- if( autotarget ){
+ if( autotarget ){
if( sprite->animation_done()) {
sprite->set_action(dir == LEFT ? "working-left" : "working-right");
swivel = false;
Player* player = this->get_nearest_player();
if( player && !swivel ){
Direction targetdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
- if( dir != targetdir ){ // no target: swivel cannon
+ if( dir != targetdir ){ // no target: swivel cannon
swivel = true;
dir = targetdir;
sprite->set_action(dir == LEFT ? "swivel-left" : "swivel-right", 1);
Player* player = this->get_nearest_player();
if( player ){
launchdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
- }
- }
+ }
+ }
if (badguys.size() > 1) {
if (random) {
static const float FISH_WAIT_TIME = 1;
Fish::Fish(const Reader& reader) :
- BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1),
+ BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1),
waiting(),
stop_y(0)
{
}
Fish::Fish(const Vector& pos) :
- BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1),
+ BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1),
waiting(),
stop_y(0)
{
static const std::string FLAME_SOUND = "sounds/flame.wav";
Flame::Flame(const Reader& reader) :
- BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS),
- angle(0),
- radius(100),
+ BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS),
+ angle(0),
+ radius(100),
speed(2),
light(0.0f,0.0f,0.0f),
lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
sound_manager->preload(FLAME_SOUND);
set_colgroup_active(COLGROUP_TOUCHABLE);
-
+
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
lightsprite->set_color(Color(0.21f, 0.13f, 0.08f));
}
sprite->set_action("fade", 1);
Sector::current()->add_object(new SpriteParticle("images/objects/particles/smoke.sprite", "default", bbox.get_middle(), ANCHOR_MIDDLE, Vector(0, -150), Vector(0,0), LAYER_BACKGROUNDTILES+2));
set_group(COLGROUP_DISABLED);
-
+
// start dead-script
run_dead_script();
}
} else if (get_pos().y < start_position.y - 2*32) {
- // Flying too high - decreased propeller speed
+ // Flying too high - decreased propeller speed
physic.set_acceleration_y(-grav*0.8);
physic.set_velocity_y(physic.get_velocity_y() * 0.99f);
} else {
- // Flying at acceptable altitude - normal propeller speed
+ // Flying at acceptable altitude - normal propeller speed
physic.set_acceleration_y(-grav*normal_propeller_speed);
}
#include "util/reader.hpp"
Ghostflame::Ghostflame(const Reader& reader) :
- BadGuy(reader, "images/creatures/flame/ghostflame.sprite", LAYER_FLOATINGOBJECTS),
- angle(0),
- radius(100),
+ BadGuy(reader, "images/creatures/flame/ghostflame.sprite", LAYER_FLOATINGOBJECTS),
+ angle(0),
+ radius(100),
speed(2),
light(0.0f,0.0f,0.0f),
lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
countMe = false;
//TODO: get unique death sound
sound_manager->preload("sounds/fizz.wav");
-
+
set_colgroup_active(COLGROUP_TOUCHABLE);
-
+
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
lightsprite->set_color(Color(0.21f, 0.00f, 0.21f));
-
+
}
void
Vector newpos(start_position.x + cos(angle) * radius,
start_position.y + sin(angle) * radius);
movement = newpos - get_pos();
-
+
}
void
static const float SUCK_TARGET_SPREAD = 8;
GhostTree::GhostTree(const Reader& lisp) :
- BadGuy(lisp, "images/creatures/ghosttree/ghosttree.sprite", LAYER_OBJECTS - 10),
+ BadGuy(lisp, "images/creatures/ghosttree/ghosttree.sprite", LAYER_OBJECTS - 10),
mystate(STATE_IDLE),
willowisp_timer(),
willo_spawn_y(0),
- willo_radius(200),
- willo_speed(1.8f),
+ willo_radius(200),
+ willo_speed(1.8f),
willo_color(0),
glow_sprite(),
colorchange_timer(),
suck_timer(),
root_timer(),
- treecolor(0),
+ treecolor(0),
suck_lantern_color(),
suck_lantern(0),
willowisps()
GhostTree::die()
{
mystate = STATE_DYING;
- sprite->set_action("dying", 1);
- glow_sprite->set_action("dying", 1);
+ sprite->set_action("dying", 1);
+ glow_sprite->set_action("dying", 1);
std::vector<TreeWillOWisp*>::iterator iter;
for(iter = willowisps.begin(); iter != willowisps.end(); ++iter) {
if(willowisp_timer.check()) {
if(willowisps.size() < WILLOWISP_COUNT) {
Vector pos = Vector(bbox.get_width() / 2, bbox.get_height() / 2 + willo_spawn_y + WILLOWISP_TOP_OFFSET);
- TreeWillOWisp *willowisp
+ TreeWillOWisp *willowisp
= new TreeWillOWisp(this, pos, 200 + willo_radius, willo_speed);
Sector::current()->add_object(willowisp);
suck_lantern->ungrab(*this, RIGHT);
suck_lantern->remove_me();
suck_lantern = 0;
- sprite->set_action("swallow", 1);
+ sprite->set_action("swallow", 1);
} else {
pos += dir;
suck_lantern->grab(*this, pos, RIGHT);
}
}
-bool
+bool
GhostTree::is_color_deadly(Color color) const {
if (color == Color(0,0,0)) return false;
Color my_color = glow_sprite->get_color();
// GoldBomb class.
if (grabber != NULL) {
Player* player = dynamic_cast<Player*>(grabber);
-
+
if (player)
player->stop_grabbing();
}
player->bounce (*this);
return true;
}
-
+
if(WalkingBadguy::is_frozen()) {
WalkingBadguy::unfreeze();
}
grunting->set_position(get_pos());
grunting->set_looping(true);
grunting->set_reference_distance(32);
- grunting->play();
+ grunting->play();
}
time_stunned = TIME_STUNNED;
float time_until_explosion;
bool is_stunned;
float time_stunned;
-
+
std::unique_ptr<SoundSource> ticking;
std::unique_ptr<SoundSource> grunting;
};
#include "util/reader.hpp"
Iceflame::Iceflame(const Reader& reader) :
- BadGuy(reader, "images/creatures/flame/iceflame.sprite", LAYER_FLOATINGOBJECTS),
- angle(0),
- radius(100),
+ BadGuy(reader, "images/creatures/flame/iceflame.sprite", LAYER_FLOATINGOBJECTS),
+ angle(0),
+ radius(100),
speed(2),
light(0.0f,0.0f,0.0f),
lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite"))
start_position.y + sin(angle) * radius));
countMe = false;
sound_manager->preload("sounds/sizzle.ogg");
-
+
set_colgroup_active(COLGROUP_TOUCHABLE);
-
+
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
lightsprite->set_color(Color(0.00f, 0.13f, 0.18f));
-
+
}
void
Vector newpos(start_position.x + cos(angle) * radius,
start_position.y + sin(angle) * radius);
movement = newpos - get_pos();
-
+
if (sprite->get_action() == "fade" && sprite->animation_done()) remove_me();
}
} // namespace
Igel::Igel(const Reader& reader) :
- WalkingBadguy(reader, "images/creatures/igel/igel.sprite", "walking-left", "walking-right"),
+ WalkingBadguy(reader, "images/creatures/igel/igel.sprite", "walking-left", "walking-right"),
turn_recover_timer()
{
walk_speed = IGEL_SPEED;
static const float JUMPY_LOW_TOLERANCE=2;
Jumpy::Jumpy(const Reader& reader) :
- BadGuy(reader, "images/creatures/snowjumpy/snowjumpy.sprite"),
+ BadGuy(reader, "images/creatures/snowjumpy/snowjumpy.sprite"),
pos_groundhit(),
groundhit_pos_set(false)
{
#include "sprite/sprite.hpp"
#include "supertux/object_factory.hpp"
-/*
+/*
* Kamikaze Snowball will fly in one direction until he hits something.
- * On impact he is destroyed, trying to kill what he hit or hit him.
+ * On impact he is destroyed, trying to kill what he hit or hit him.
*/
namespace{
static const float KAMIKAZE_SPEED = 200;
#define RAND_SPEED 150
Kugelblitz::Kugelblitz(const Reader& reader) :
- BadGuy(reader, "images/creatures/kugelblitz/kugelblitz.sprite"),
+ BadGuy(reader, "images/creatures/kugelblitz/kugelblitz.sprite"),
pos_groundhit(),
groundhit_pos_set(false),
dying(),
sprite->set_action("falling");
physic.enable_gravity(false);
countMe = false;
-
+
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
- lightsprite->set_color(Color(0.2f, 0.1f, 0.0f));
+ lightsprite->set_color(Color(0.2f, 0.1f, 0.0f));
}
void
Kugelblitz::draw(DrawingContext& context)
{
sprite->draw(context, get_pos(), layer);
-
+
//Only draw light in dark areas
context.get_light( get_bbox().get_middle(), &light );
if (light.red + light.green < 2.0){
void active_update(float);
void kill_fall();
void explode();
-
+
virtual void draw(DrawingContext& context);
private:
WalkingBadguy(reader, "images/creatures/livefire/livefire.sprite", "left", "right"),
lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-medium.sprite")),
death_sound("sounds/fall.wav"),
- state(STATE_WALKING)
+ state(STATE_WALKING)
{
walk_speed = 80;
max_drop_height = 20;
{
public:
LiveFireDormant(const Reader& reader);
-
+
void initialize();
};
static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */
Mole::Mole(const Reader& reader) :
- BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
+ BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
state(PRE_THROWING),
timer(),
throw_timer()
}
Mole::Mole(const Vector& pos) :
- BadGuy(pos, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
+ BadGuy(pos, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
state(PRE_THROWING),
timer(),
throw_timer()
}
MoleRock::MoleRock(const Vector& pos, const Vector& velocity, const BadGuy* parent = 0) :
- BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2),
- parent(parent),
+ BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2),
+ parent(parent),
initial_velocity(velocity)
{
physic.enable_gravity(true);
#include "badguy/walking_badguy.hpp"
-class MrBomb : public WalkingBadguy,
+class MrBomb : public WalkingBadguy,
public Portable
{
public:
}
MrIceBlock::MrIceBlock(const Reader& reader) :
- WalkingBadguy(reader, "images/creatures/mr_iceblock/mr_iceblock.sprite", "left", "right"),
- ice_state(ICESTATE_NORMAL),
+ WalkingBadguy(reader, "images/creatures/mr_iceblock/mr_iceblock.sprite", "left", "right"),
+ ice_state(ICESTATE_NORMAL),
nokick_timer(),
flat_timer(),
squishcount(0)
}
MrIceBlock::MrIceBlock(const Vector& pos, Direction d) :
- WalkingBadguy(pos, d, "images/creatures/mr_iceblock/mr_iceblock.sprite", "left", "right"),
- ice_state(ICESTATE_NORMAL),
+ WalkingBadguy(pos, d, "images/creatures/mr_iceblock/mr_iceblock.sprite", "left", "right"),
+ ice_state(ICESTATE_NORMAL),
nokick_timer(),
flat_timer(),
squishcount(0)
#include "badguy/walking_badguy.hpp"
#include "object/portable.hpp"
-class MrIceBlock : public WalkingBadguy,
+class MrIceBlock : public WalkingBadguy,
public Portable
{
public:
Root::Root(const Vector& pos) :
BadGuy(pos, "images/creatures/ghosttree/root.sprite", LAYER_TILES-1),
- mystate(STATE_APPEARING),
+ mystate(STATE_APPEARING),
base_sprite(),
offset_y(0),
hatch_timer()
void
Root::active_update(float elapsed_time)
{
- if (mystate == STATE_APPEARING) {
+ if (mystate == STATE_APPEARING) {
if (base_sprite->animation_done()) {
hatch_timer.start(HATCH_TIME);
mystate = STATE_HATCHING;
offset_y = 0;
mystate = STATE_VANISHING;
base_sprite->set_action("vanishing", 2);
- base_sprite->set_animation_loops(2); // TODO: doesn't seem to work for loops=1
+ base_sprite->set_animation_loops(2); // TODO: doesn't seem to work for loops=1
}
set_pos(start_position + Vector(0, offset_y));
}
}
Snail::Snail(const Reader& reader) :
- WalkingBadguy(reader, "images/creatures/snail/snail.sprite", "left", "right"),
- state(STATE_NORMAL),
+ WalkingBadguy(reader, "images/creatures/snail/snail.sprite", "left", "right"),
+ state(STATE_NORMAL),
kicked_delay_timer(),
squishcount(0)
{
}
Snail::Snail(const Vector& pos, Direction d) :
- WalkingBadguy(pos, d, "images/creatures/snail/snail.sprite", "left", "right"),
- state(STATE_NORMAL),
+ WalkingBadguy(pos, d, "images/creatures/snail/snail.sprite", "left", "right"),
+ state(STATE_NORMAL),
kicked_delay_timer(),
squishcount(0)
{
}
SpiderMite::SpiderMite(const Vector& pos) :
- BadGuy(pos, "images/creatures/spidermite/spidermite.sprite"),
+ BadGuy(pos, "images/creatures/spidermite/spidermite.sprite"),
mode(),
timer()
{
static const float INVINCIBLE_TIME = 1;
Stumpy::Stumpy(const Reader& reader) :
- WalkingBadguy(reader, "images/creatures/mr_tree/stumpy.sprite","left","right"),
+ WalkingBadguy(reader, "images/creatures/mr_tree/stumpy.sprite","left","right"),
mystate(STATE_NORMAL),
invincible_timer()
{
}
Stumpy::Stumpy(const Vector& pos, Direction d) :
- WalkingBadguy(pos, d, "images/creatures/mr_tree/stumpy.sprite","left","right"),
+ WalkingBadguy(pos, d, "images/creatures/mr_tree/stumpy.sprite","left","right"),
mystate(STATE_INVINCIBLE),
invincible_timer()
{
TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos,
float radius, float speed) :
BadGuy(tree->get_pos() + pos, "images/creatures/willowisp/willowisp.sprite",
- LAYER_OBJECTS - 20),
- was_sucked(false),
- mystate(STATE_DEFAULT),
+ LAYER_OBJECTS - 20),
+ was_sucked(false),
+ mystate(STATE_DEFAULT),
color(),
angle(),
radius(),
return true;
if (dynamic_cast<Player*>(&other))
return true;
-
+
return false;
}
#include "sprite/sprite.hpp"
-WalkingBadguy::WalkingBadguy(const Vector& pos,
- const std::string& sprite_name,
- const std::string& walk_left_action,
- const std::string& walk_right_action,
+WalkingBadguy::WalkingBadguy(const Vector& pos,
+ const std::string& sprite_name,
+ const std::string& walk_left_action,
+ const std::string& walk_right_action,
int layer) :
- BadGuy(pos, sprite_name, layer),
- walk_left_action(walk_left_action),
- walk_right_action(walk_right_action),
- walk_speed(80),
+ BadGuy(pos, sprite_name, layer),
+ walk_left_action(walk_left_action),
+ walk_right_action(walk_right_action),
+ walk_speed(80),
max_drop_height(-1),
turn_around_timer(),
turn_around_counter()
{
}
-WalkingBadguy::WalkingBadguy(const Vector& pos,
- Direction direction,
- const std::string& sprite_name,
- const std::string& walk_left_action,
- const std::string& walk_right_action,
+WalkingBadguy::WalkingBadguy(const Vector& pos,
+ Direction direction,
+ const std::string& sprite_name,
+ const std::string& walk_left_action,
+ const std::string& walk_right_action,
int layer) :
- BadGuy(pos, direction, sprite_name, layer),
- walk_left_action(walk_left_action),
- walk_right_action(walk_right_action),
- walk_speed(80),
+ BadGuy(pos, direction, sprite_name, layer),
+ walk_left_action(walk_left_action),
+ walk_right_action(walk_right_action),
+ walk_speed(80),
max_drop_height(-1),
turn_around_timer(),
turn_around_counter()
{
}
-WalkingBadguy::WalkingBadguy(const Reader& reader,
- const std::string& sprite_name,
- const std::string& walk_left_action,
- const std::string& walk_right_action,
+WalkingBadguy::WalkingBadguy(const Reader& reader,
+ const std::string& sprite_name,
+ const std::string& walk_left_action,
+ const std::string& walk_right_action,
int layer) :
- BadGuy(reader, sprite_name, layer),
- walk_left_action(walk_left_action),
- walk_right_action(walk_right_action),
- walk_speed(80),
+ BadGuy(reader, sprite_name, layer),
+ walk_left_action(walk_left_action),
+ walk_right_action(walk_right_action),
+ walk_speed(80),
max_drop_height(-1),
turn_around_timer(),
turn_around_counter()
class WalkingBadguy : public BadGuy
{
public:
- WalkingBadguy(const Vector& pos,
- const std::string& sprite_name,
- const std::string& walk_left_action,
- const std::string& walk_right_action,
+ WalkingBadguy(const Vector& pos,
+ const std::string& sprite_name,
+ const std::string& walk_left_action,
+ const std::string& walk_right_action,
int layer = LAYER_OBJECTS);
- WalkingBadguy(const Vector& pos, Direction direction,
- const std::string& sprite_name,
- const std::string& walk_left_action,
- const std::string& walk_right_action,
+ WalkingBadguy(const Vector& pos, Direction direction,
+ const std::string& sprite_name,
+ const std::string& walk_left_action,
+ const std::string& walk_right_action,
int layer = LAYER_OBJECTS);
- WalkingBadguy(const Reader& reader,
- const std::string& sprite_name,
- const std::string& walk_left_action,
- const std::string& walk_right_action,
+ WalkingBadguy(const Reader& reader,
+ const std::string& sprite_name,
+ const std::string& walk_left_action,
+ const std::string& walk_right_action,
int layer = LAYER_OBJECTS);
void initialize();
static const std::string SOUNDFILE = "sounds/willowisp.wav";
WillOWisp::WillOWisp(const Reader& reader) :
- BadGuy(reader, "images/creatures/willowisp/willowisp.sprite", LAYER_FLOATINGOBJECTS),
- mystate(STATE_IDLE),
- target_sector("main"),
+ BadGuy(reader, "images/creatures/willowisp/willowisp.sprite", LAYER_FLOATINGOBJECTS),
+ mystate(STATE_IDLE),
+ target_sector("main"),
target_spawnpoint("main"),
hit_script(),
sound_source(),
scripting::WillOWisp* _this = static_cast<scripting::WillOWisp*> (this);
expose_object(vm, table_idx, _this, name);
}
-
+
void
WillOWisp::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
{
#include "scripting/willowisp.hpp"
#include "supertux/script_interface.hpp"
-class WillOWisp : public BadGuy,
+class WillOWisp : public BadGuy,
public scripting::WillOWisp,
public ScriptInterface
{
InputManager::read(const Reader& lisp)
{
const lisp::Lisp* keymap_lisp = lisp.get_lisp("keymap");
- if (keymap_lisp)
+ if (keymap_lisp)
{
keyboard_manager->read(keymap_lisp);
}
const lisp::Lisp* joystick_lisp = lisp.get_lisp(_("joystick"));
- if (joystick_lisp)
+ if (joystick_lisp)
{
joystick_manager->read(joystick_lisp);
}
public:
bool m_use_game_controller;
std::unique_ptr<KeyboardManager> keyboard_manager;
- std::unique_ptr<JoystickManager> joystick_manager;
+ std::unique_ptr<JoystickManager> joystick_manager;
std::unique_ptr<GameControllerManager> game_controller_manager;
private:
KeyMap::iterator key_mapping = keymap.find(event.keysym.sym);
// if console key was pressed: toggle console
- if (key_mapping != keymap.end() &&
+ if (key_mapping != keymap.end() &&
key_mapping->second == Controller::CONSOLE)
{
if (event.type == SDL_KEYDOWN)
{
Console::instance->toggle();
}
- }
- else if (Console::instance->hasFocus())
+ }
+ else if (Console::instance->hasFocus())
{
// if console is open: send key there
process_console_key_event(event);
// if menu mode: send key there
process_menu_key_event(event);
}
- else if (key_mapping == keymap.end())
+ else if (key_mapping == keymap.end())
{
// default action: update controls
//log_debug << "Key " << event.key.SDL_Keycode.sym << " is unbound" << std::endl;
}
- else
+ else
{
auto control = key_mapping->second;
bool value = (event.type == SDL_KEYDOWN);
KeyboardManager::process_menu_key_event(const SDL_KeyboardEvent& event)
{
// wait for key mode?
- if (wait_for_key >= 0)
+ if (wait_for_key >= 0)
{
if (event.type == SDL_KEYUP)
return;
- if (event.keysym.sym != SDLK_ESCAPE &&
- event.keysym.sym != SDLK_PAUSE)
+ if (event.keysym.sym != SDLK_ESCAPE &&
+ event.keysym.sym != SDLK_PAUSE)
{
bind_key(event.keysym.sym, static_cast<Controller::Control>(wait_for_key));
}
wait_for_key = -1;
return;
}
-
- if (m_parent->joystick_manager->wait_for_joystick >= 0)
+
+ if (m_parent->joystick_manager->wait_for_joystick >= 0)
{
- if (event.keysym.sym == SDLK_ESCAPE)
+ if (event.keysym.sym == SDLK_ESCAPE)
{
m_parent->reset();
MenuManager::instance().refresh();
SDL_Keycode
KeyboardManager::reversemap_key(Controller::Control c)
{
- for(KeyMap::iterator i = keymap.begin(); i != keymap.end(); ++i)
+ for(KeyMap::iterator i = keymap.begin(); i != keymap.end(); ++i)
{
if (i->second == c)
{
m_transition->update();
m_transition->draw(context);
}
- else
+ else
{
if (current())
{
MouseCursor::MouseCursor(const std::string& cursor_file,
const std::string& cursor_click_file,
const std::string& cursor_link_file) :
- m_mid_x(0),
+ m_mid_x(0),
m_mid_y(0),
m_state(MC_NORMAL),
m_cursor()
/// Set current cursor.
static void set_current(MouseCursor* pcursor)
{ current_ = pcursor; };
-
+
private:
int m_mid_x;
int m_mid_y;
namespace lisp {
Lexer::Lexer(std::istream& newstream) :
- stream(newstream),
- eof(false),
+ stream(newstream),
+ eof(false),
linenumber(0),
bufend(),
bufpos(),
ListIterator::ListIterator(const lisp::Lisp* newlisp) :
current_item(),
- current_lisp(0),
+ current_lisp(0),
cur(newlisp)
{
}
namespace lisp {
Parser::Parser(bool translate) :
- lexer(0),
+ lexer(0),
filename(),
- dictionary_manager(0),
+ dictionary_manager(0),
dictionary(0),
token(),
searchpath(),
if(translate) {
dictionary_manager = new tinygettext::DictionaryManager();
dictionary_manager->set_charset("UTF-8");
- if (g_config && (g_config->locale != ""))
+ if (g_config && (g_config->locale != ""))
dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
}
{
public:
Size() :
- width(0),
+ width(0),
height(0)
{}
Size(int width_, int height_) :
- width(width_),
- height(height_)
+ width(width_),
+ height(height_)
{}
Size(const Size& rhs) :
Size& operator+=(const Size& rhs)
{
- width += rhs.width;
- height += rhs.height;
- return *this;
+ width += rhs.width;
+ height += rhs.height;
+ return *this;
}
Size& operator-=(const Size& rhs)
- {
+ {
width -= rhs.width;
- height -= rhs.height;
- return *this;
+ height -= rhs.height;
+ return *this;
}
public:
};
inline Size operator*(const Size& lhs, int factor)
-{
- return Size(lhs.width * factor,
- lhs.height * factor);
+{
+ return Size(lhs.width * factor,
+ lhs.height * factor);
}
inline Size operator*(int factor, const Size& rhs)
-{
- return Size(rhs.width * factor,
- rhs.height * factor);
+{
+ return Size(rhs.width * factor,
+ rhs.height * factor);
}
inline Size operator/(const Size& lhs, int divisor)
-{
- return Size(lhs.width / divisor,
- lhs.height / divisor);
+{
+ return Size(lhs.width / divisor,
+ lhs.height / divisor);
}
inline Size operator+(const Size& lhs, const Size& rhs)
-{
- return Size(lhs.width + rhs.width,
- lhs.height + rhs.height);
+{
+ return Size(lhs.width + rhs.width,
+ lhs.height + rhs.height);
}
inline Size operator-(const Size& lhs, const Size& rhs)
{
- return Size(lhs.width - rhs.width,
- lhs.height - rhs.height);
+ return Size(lhs.width - rhs.width,
+ lhs.height - rhs.height);
}
inline bool operator==(const Size& lhs, const Size& rhs)
{
- return (lhs.width == rhs.width) && (lhs.height == rhs.height);
+ return (lhs.width == rhs.width) && (lhs.height == rhs.height);
}
inline bool operator!=(const Size& lhs, const Size& rhs)
-{
- return (lhs.width != rhs.width) || (lhs.height != rhs.height);
+{
+ return (lhs.width != rhs.width) || (lhs.height != rhs.height);
}
std::ostream& operator<<(std::ostream& s, const Size& size);
{}
Sizef(float width_, float height_) :
- width(width_),
- height(height_)
+ width(width_),
+ height(height_)
{}
Sizef(const Sizef& rhs) :
}
Sizef& operator+=(const Sizef& rhs)
- {
- width += rhs.width;
- height += rhs.height;
- return *this;
+ {
+ width += rhs.width;
+ height += rhs.height;
+ return *this;
}
Sizef& operator-=(const Sizef& rhs)
- {
- width -= rhs.width;
- height -= rhs.height;
- return *this;
+ {
+ width -= rhs.width;
+ height -= rhs.height;
+ return *this;
}
public:
};
inline Sizef operator*(const Sizef& lhs, float factor)
-{
- return Sizef(lhs.width * factor,
- lhs.height * factor);
+{
+ return Sizef(lhs.width * factor,
+ lhs.height * factor);
}
inline Sizef operator*(float factor, const Sizef& rhs)
-{
- return Sizef(rhs.width * factor,
- rhs.height * factor);
+{
+ return Sizef(rhs.width * factor,
+ rhs.height * factor);
}
inline Sizef operator/(const Sizef& lhs, float divisor)
-{
- return Sizef(lhs.width / divisor,
- lhs.height / divisor);
+{
+ return Sizef(lhs.width / divisor,
+ lhs.height / divisor);
}
inline Sizef operator+(const Sizef& lhs, const Sizef& rhs)
-{
- return Sizef(lhs.width + rhs.width,
- lhs.height + rhs.height);
+{
+ return Sizef(lhs.width + rhs.width,
+ lhs.height + rhs.height);
}
inline Sizef operator-(const Sizef& lhs, const Sizef& rhs)
{
- return Sizef(lhs.width - rhs.width,
- lhs.height - rhs.height);
+ return Sizef(lhs.width - rhs.width,
+ lhs.height - rhs.height);
}
inline bool operator==(const Sizef& lhs, const Sizef& rhs)
{
- return (lhs.width == rhs.width) && (rhs.height == rhs.height);
+ return (lhs.width == rhs.width) && (rhs.height == rhs.height);
}
inline bool operator!=(const Sizef& lhs, const Sizef& rhs)
-{
- return (lhs.width != rhs.width) || (lhs.height != rhs.height);
+{
+ return (lhs.width != rhs.width) || (lhs.height != rhs.height);
}
std::ostream& operator<<(std::ostream& s, const Sizef& size);
}
void
-AmbientSound::stop_playing()
+AmbientSound::stop_playing()
{
delete sound_source;
sound_source = 0;
class Player;
class SoundSource;
-class AmbientSound : public GameObject,
- public ScriptInterface,
+class AmbientSound : public GameObject,
+ public ScriptInterface,
public scripting::AmbientSound
{
public:
case TOP_ALIGNMENT:
for(int x = start_x; x < end_x; ++x)
{
- Vector p(pos.x + x * image->get_width() - image->get_width() / 2.0f,
- pos.y - parallax_image_size.height / 2.0f);
+ Vector p(pos.x + x * image->get_width() - image->get_width() / 2.0f,
+ pos.y - parallax_image_size.height / 2.0f);
context.draw_surface(image, p, layer);
}
break;
case BOTTOM_ALIGNMENT:
for(int x = start_x; x < end_x; ++x)
{
- Vector p(pos.x + x * image->get_width() - image->get_width() / 2.0f,
- pos.y - image->get_height() + parallax_image_size.height / 2.0f);
+ Vector p(pos.x + x * image->get_width() - image->get_width() / 2.0f,
+ pos.y - image->get_height() + parallax_image_size.height / 2.0f);
context.draw_surface(image, p, layer);
}
break;
for(int y = start_y; y < end_y; ++y)
for(int x = start_x; x < end_x; ++x)
{
- Vector p(pos.x + x * image->get_width() - image->get_width()/2,
+ Vector p(pos.x + x * image->get_width() - image->get_width()/2,
pos.y + y * image->get_height() - image->get_height()/2);
if (image_top.get() != NULL && (y < 0))
Sector::current()->get_height());
Sizef screen(SCREEN_WIDTH, SCREEN_HEIGHT);
Sizef translation_range = level_size - screen;
- Vector center_offset(context.get_translation().x - translation_range.width / 2.0f,
+ Vector center_offset(context.get_translation().x - translation_range.width / 2.0f,
context.get_translation().y - translation_range.height / 2.0f);
// FIXME: We are not handling 'pos'
void draw_image(DrawingContext& context, const Vector& pos);
private:
- enum Alignment {
+ enum Alignment {
NO_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
#include "supertux/sector.hpp"
BicyclePlatform::BicyclePlatform(const Reader& reader) :
- MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
+ MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
master(0),
- slave(0),
+ slave(0),
center(),
- radius(128),
- angle(0),
- angular_speed(0),
+ radius(128),
+ angle(0),
+ angular_speed(0),
contacts(),
momentum(0)
{
}
BicyclePlatform::BicyclePlatform(BicyclePlatform* master) :
- MovingSprite(*master),
- master(master),
- slave(this),
- center(master->center),
- radius(master->radius),
- angle(master->angle + M_PI),
- angular_speed(0),
+ MovingSprite(*master),
+ master(master),
+ slave(this),
+ center(master->center),
+ radius(master->radius),
+ angle(master->angle + M_PI),
+ angular_speed(0),
contacts(),
momentum(0)
{
master->slave = this;
}
-BicyclePlatform::~BicyclePlatform()
+BicyclePlatform::~BicyclePlatform()
{
if ((this == master) && (master)) {
slave->master = 0;
}
if (this == slave) {
angle = master->angle + M_PI;
- while (angle < 0) { angle += 2*M_PI; }
- while (angle > 2*M_PI) { angle -= 2*M_PI; }
+ while (angle < 0) { angle += 2*M_PI; }
+ while (angle > 2*M_PI) { angle -= 2*M_PI; }
Vector dest = center + Vector(cosf(angle), sinf(angle)) * radius - (bbox.get_size() * 0.5);
movement = dest - get_pos();
}
angular_speed += (angular_momentum * elapsed_time) * M_PI;
angular_speed *= 1 - elapsed_time * 0.2;
angle += angular_speed * elapsed_time;
- while (angle < 0) { angle += 2*M_PI; }
- while (angle > 2*M_PI) { angle -= 2*M_PI; }
+ while (angle < 0) { angle += 2*M_PI; }
+ while (angle > 2*M_PI) { angle -= 2*M_PI; }
angular_speed = std::min(std::max(angular_speed, static_cast<float>(-128*M_PI*elapsed_time)), static_cast<float>(128*M_PI*elapsed_time));
Vector dest = center + Vector(cosf(angle), sinf(angle)) * radius - (bbox.get_size() * 0.5);
movement = dest - get_pos();
static const float BUMP_ROTATION_ANGLE = 10;
Block::Block(SpritePtr newsprite) :
- sprite(newsprite),
- bouncing(false),
- breaking(false),
- bounce_dir(0),
- bounce_offset(0),
+ sprite(newsprite),
+ bouncing(false),
+ breaking(false),
+ bounce_dir(0),
+ bounce_offset(0),
original_y(-1)
{
bbox.set_size(32, 32.1f);
if(coin) {
coin->collect();
}
-
+
//Eggs get jumped
GrowUp* growup = dynamic_cast<GrowUp*> (&other);
if(growup) {
BouncyCoin::BouncyCoin(const Vector& pos, bool emerge) :
sprite(),
- position(pos),
+ position(pos),
timer(),
emerge_distance(0)
{
BrokenBrick::BrokenBrick(SpritePtr sprite,
const Vector& pos, const Vector& nmovement) :
timer(),
- sprite(sprite),
- position(pos),
+ sprite(sprite),
+ position(pos),
movement(nmovement)
{
timer.start(.2f);
Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type) :
physic(),
- life_count(3),
+ life_count(3),
sprite(),
light(0.0f,0.0f,0.0f),
lightsprite(sprite_manager->create("images/objects/lightmap_light/lightmap_light-small.sprite")),
Camera::Camera(Sector* newsector, std::string name) :
mode(NORMAL),
translation(),
- sector(newsector),
+ sector(newsector),
lookahead_mode(LOOKAHEAD_NONE),
changetime(),
lookahead_pos(),
class PathWalker;
class CameraConfig;
-class Camera : public GameObject,
+class Camera : public GameObject,
public ScriptInterface
{
public:
/// parse camera mode from lisp file
void parse(const Reader& reader);
-
+
/// reset camera position
void reset(const Vector& tuxpos);
#include "util/reader.hpp"
Candle::Candle(const Reader& lisp)
- : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED),
- burning(true),
+ : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED),
+ burning(true),
flicker(true),
lightcolor(1.0f, 1.0f, 1.0f),
candle_light_1(sprite_manager->create("images/objects/candle/candle-light-1.sprite")),
candle_light_1->set_action("white");
candle_light_2->set_action("white");
}
-
+
if (burning) {
sprite->set_action("on");
} else {
/**
* A burning candle: Simple, scriptable level decoration.
*/
-class Candle : public MovingSprite,
+class Candle : public MovingSprite,
public ScriptInterface
{
public:
virtual ~CloudParticleSystem();
void parse(const Reader& lisp);
-
+
virtual void update(float elapsed_time);
std::string type() const
#include "supertux/sector.hpp"
CoinExplode::CoinExplode(const Vector& pos) :
- position(pos)
+ position(pos)
{
}
CoinRain::CoinRain(const Vector& pos, bool emerge) :
sprite(),
- position(pos),
+ position(pos),
emerge_distance(0),
timer(),
counter(0),
static const float BORDER_SIZE = 75;
DisplayEffect::DisplayEffect(std::string name) :
- screen_fade(NO_FADE),
- screen_fadetime(0),
+ screen_fade(NO_FADE),
+ screen_fadetime(0),
screen_fading(0),
- border_fade(NO_FADE),
- border_fadetime(0),
+ border_fade(NO_FADE),
+ border_fadetime(0),
border_fading(),
- border_size(0),
+ border_size(0),
black(false),
borders(false)
{
#include "supertux/game_object.hpp"
#include "supertux/script_interface.hpp"
-class DisplayEffect : public GameObject,
+class DisplayEffect : public GameObject,
public scripting::DisplayEffect,
public ScriptInterface
{
#include "supertux/sector.hpp"
EndSequence::EndSequence() :
- isrunning(false),
- isdone(false),
+ isrunning(false),
+ isdone(false),
tux_may_walk(true),
end_sequence_controller(0)
-{
+{
}
EndSequence::~EndSequence()
set_action(hurt ? "default" : "pop", 1);
sprite->set_animation_loops(1); //TODO: this is necessary because set_action will not set "loops" when "action" is the default action
sprite->set_angle(graphicsRandom.randf(0, 360)); // a random rotation on the sprite to make explosions appear more random
- sound_manager->play(hurt ? "sounds/explosion.wav" : "sounds/firecracker.ogg", get_pos());
+ sound_manager->play(hurt ? "sounds/explosion.wav" : "sounds/firecracker.ogg", get_pos());
#if 0
// spawn some particles
} /* if (push) */
}
-void
+void
Explosion::update(float )
{
switch(state) {
#include "util/reader.hpp"
Firefly::Firefly(const Reader& lisp) :
- MovingSprite(lisp, "images/objects/resetpoints/default-resetpoint.sprite", LAYER_TILES, COLGROUP_TOUCHABLE),
+ MovingSprite(lisp, "images/objects/resetpoints/default-resetpoint.sprite", LAYER_TILES, COLGROUP_TOUCHABLE),
activated(false),
initial_position()
{
FloatingImage::FloatingImage(const std::string& spritefile) :
sprite(sprite_manager->create(spritefile)),
- layer(LAYER_FOREGROUND1 + 1),
- visible(false),
- anchor(ANCHOR_MIDDLE),
+ layer(LAYER_FOREGROUND1 + 1),
+ visible(false),
+ anchor(ANCHOR_MIDDLE),
pos(),
- fading(0),
+ fading(0),
fadetime(0)
{
}
#include "video/drawing_context.hpp"
FloatingText::FloatingText(const Vector& pos, const std::string& text_) :
- position(pos),
+ position(pos),
text(text_),
timer()
{
{
bbox.set_size(32, 32);
lightsprite->set_blend(Blend(GL_SRC_ALPHA, GL_ONE));
-
+
if(type == FIRE_BONUS) {
sprite = sprite_manager->create("images/powerups/fireflower/fireflower.sprite");
sound_manager->preload("sounds/fire-flower.wav");
Flower& operator=(const Flower&);
Color light;
SpritePtr lightsprite;
-
+
friend class FlipLevelTransformer;
};
virtual ~GhostParticleSystem();
void parse(const Reader& lisp);
-
+
virtual void update(float elapsed_time);
std::string type() const
IceCrusher::IceCrusher(const Reader& reader) :
MovingSprite(reader, "images/creatures/icecrusher/icecrusher.sprite", LAYER_OBJECTS, COLGROUP_STATIC),
- state(IDLE),
+ state(IDLE),
start_position(),
physic(),
cooldown_timer(0.0),
start_position = get_bbox().p1;
set_state(state, true);
-
+
float sprite_width = sprite->get_width ();
if (sprite_width >= 128.0)
ic_size = LARGE;
/*
IceCrusher::IceCrusher(const IceCrusher& other)
- : MovingSprite(other),
- state(other.state), speed(other.speed)
+ : MovingSprite(other),
+ state(other.state), speed(other.speed)
{
start_position = get_bbox().p1;
set_state(state, true);
}
*/
-void
-IceCrusher::set_state(IceCrusherState state, bool force)
+void
+IceCrusher::set_state(IceCrusherState state, bool force)
{
if ((this->state == state) && (!force)) return;
switch(state) {
}
return FORCE_MOVE;
}
-
-void
+
+void
IceCrusher::collision_solid(const CollisionHit& hit)
{
switch(state) {
}
InfoBlock::InfoBlock(const Reader& lisp) :
- Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite")),
+ Block(sprite_manager->create("images/objects/bonus_block/infoblock.sprite")),
message(),
- shown_pct(0),
+ shown_pct(0),
dest_pct(0),
lines(),
lines_height()
#include "supertux/constants.hpp"
InvisibleBlock::InvisibleBlock(const Vector& pos) :
- Block(sprite_manager->create("images/objects/bonus_block/invisibleblock.sprite")),
+ Block(sprite_manager->create("images/objects/bonus_block/invisibleblock.sprite")),
visible(false)
{
bbox.set_pos(pos);
// if we're not visible, only register a collision if this will make us visible
Player* player = dynamic_cast<Player*> (&other);
- if ((player)
+ if ((player)
&& (player->get_movement().y <= 0)
&& (player->get_bbox().get_top() > get_bbox().get_bottom() - SHIFT_DELTA)) {
return true;
#include "util/reader.hpp"
InvisibleWall::InvisibleWall(const Reader& lisp) :
- MovingSprite(lisp, "images/objects/invisible/invisible.sprite", LAYER_TILES, COLGROUP_STATIC),
+ MovingSprite(lisp, "images/objects/invisible/invisible.sprite", LAYER_TILES, COLGROUP_STATIC),
physic(),
- width(32),
+ width(32),
height(32)
{
lisp.get("width", width);
#include <sstream>
Ispy::Ispy(const Reader& reader) :
- MovingSprite(reader, "images/objects/ispy/ispy.sprite", LAYER_TILES+5, COLGROUP_DISABLED),
- state(ISPYSTATE_IDLE),
+ MovingSprite(reader, "images/objects/ispy/ispy.sprite", LAYER_TILES+5, COLGROUP_DISABLED),
+ state(ISPYSTATE_IDLE),
script(),
dir(AUTO)
{
float den2 = (d2-b2)*(a1-a2) + (a2-c2)*(b1-b2);
// normalize to positive numerator
- if (num < 0) {
- num = -num;
- den1 = -den1;
- den2 = -den2;
+ if (num < 0) {
+ num = -num;
+ den1 = -den1;
+ den2 = -den2;
}
// numerator is zero -> Check for parallel or coinciding lines
if (num == 0) {
if ((b1-b2)*(c1-a2) != (a1-a2)*(d1-b2)) return false;
- if (a1 == a2) {
- std::swap(a1, b1);
- std::swap(a2, b2);
- std::swap(c1, d1);
- std::swap(c2, d2);
+ if (a1 == a2) {
+ std::swap(a1, b1);
+ std::swap(a2, b2);
+ std::swap(c1, d1);
+ std::swap(c2, d2);
}
if (a1 > a2) std::swap(a1, a2);
if (c1 > c2) std::swap(c1, c2);
return true;
}
-void
+void
Ispy::update(float )
{
Rock::ungrab(object, dir);
}
-
-bool
+
+bool
Lantern::is_open()
{
return ((grabbed) && lightcolor.red == 0 && lightcolor.green == 0 && lightcolor.blue == 0);
LevelTime::LevelTime(const Reader& reader) :
time_surface(),
- running(true),
+ running(true),
time_left(0)
{
reader.get("name", name);
{
float all_width = time_surface->get_width() + Resources::normal_font->get_text_width(time_text);
context.draw_surface(time_surface, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1);
- context.draw_text(Resources::normal_font, time_text,
- Vector((SCREEN_WIDTH - all_width)/2 + time_surface->get_width(), BORDER_Y),
+ context.draw_text(Resources::normal_font, time_text,
+ Vector((SCREEN_WIDTH - all_width)/2 + time_surface->get_width(), BORDER_Y),
ALIGN_LEFT, LAYER_FOREGROUND1, LevelTime::text_color);
}
}
#include "video/color.hpp"
#include "video/surface_ptr.hpp"
-class LevelTime : public GameObject,
+class LevelTime : public GameObject,
public ScriptInterface
{
static Color text_color;
#include "sprite/sprite.hpp"
#include "sprite/sprite_manager.hpp"
-Light::Light(const Vector& center, const Color& color) :
- position(center),
+Light::Light(const Vector& center, const Color& color) :
+ position(center),
color(color),
sprite()
{
#include <stdexcept>
-MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name,
+MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name,
int layer, CollisionGroup collision_group) :
- sprite_name(sprite_name),
+ sprite_name(sprite_name),
sprite(),
layer(layer)
{
}
MovingSprite::MovingSprite(const Reader& reader, const Vector& pos, int layer, CollisionGroup collision_group) :
- sprite_name(),
+ sprite_name(),
sprite(),
layer(layer)
{
}
MovingSprite::MovingSprite(const Reader& reader, const std::string& sprite_name, int layer, CollisionGroup collision_group) :
- sprite_name(sprite_name),
+ sprite_name(sprite_name),
sprite(),
layer(layer)
{
}
MovingSprite::MovingSprite(const MovingSprite& other) :
- MovingObject(other),
+ MovingObject(other),
sprite_name(),
sprite(),
layer(other.layer)
class MovingSprite : public MovingObject
{
public:
- MovingSprite(const Vector& pos,
- const std::string& sprite_name,
- int layer = LAYER_OBJECTS,
+ MovingSprite(const Vector& pos,
+ const std::string& sprite_name,
+ int layer = LAYER_OBJECTS,
CollisionGroup collision_group = COLGROUP_MOVING);
- MovingSprite(const Reader& reader,
- const Vector& pos,
- int layer = LAYER_OBJECTS,
+ MovingSprite(const Reader& reader,
+ const Vector& pos,
+ int layer = LAYER_OBJECTS,
CollisionGroup collision_group = COLGROUP_MOVING);
- MovingSprite(const Reader& reader,
- const std::string& sprite_name,
- int layer = LAYER_OBJECTS,
+ MovingSprite(const Reader& reader,
+ const std::string& sprite_name,
+ int layer = LAYER_OBJECTS,
CollisionGroup collision_group = COLGROUP_MOVING);
- MovingSprite(const Reader& reader,
- int layer = LAYER_OBJECTS,
+ MovingSprite(const Reader& reader,
+ int layer = LAYER_OBJECTS,
CollisionGroup collision_group = COLGROUP_MOVING);
MovingSprite(const MovingSprite& moving_sprite);
//MovingSprite& operator=(const MovingSprite& moving_sprite);
Particles::Particles(const Vector& epicenter, int min_angle, int max_angle,
const Vector& initial_velocity, const Vector& acceleration, int number,
Color color_, int size_, float life_time, int drawing_layer_) :
- accel(acceleration),
+ accel(acceleration),
timer(),
live_forever(),
- color(color_),
- size(size_),
+ color(color_),
+ size(size_),
drawing_layer(drawing_layer_),
particles()
{
struct Particle {
Vector pos, vel;
- Particle() :
- pos(),
+ Particle() :
+ pos(),
vel()
{}
// float angle;
angle(),
texture()
{}
-
+
virtual ~Particle()
{}
class Particle
{
public:
- Particle() :
- pos(),
+ Particle() :
+ pos(),
texture()
{}
#include <assert.h>
PathWalker::PathWalker(const Path* path, bool running) :
- path(path),
- running(running),
- current_node_nr(0),
- next_node_nr(0),
- stop_at_node_nr(running?-1:0),
+ path(path),
+ running(running),
+ current_node_nr(0),
+ next_node_nr(0),
+ stop_at_node_nr(running?-1:0),
node_time(0),
node_mult(),
walking_speed(1.0)
bool is_moving() {
return running;
}
-
+
const Path* path;
private:
#include "util/reader.hpp"
Platform::Platform(const Reader& reader) :
- MovingSprite(reader, Vector(0,0), LAYER_OBJECTS, COLGROUP_STATIC),
+ MovingSprite(reader, Vector(0,0), LAYER_OBJECTS, COLGROUP_STATIC),
path(),
walker(),
- speed(Vector(0,0)),
- automatic(false),
- player_contact(false),
+ speed(Vector(0,0)),
+ automatic(false),
+ player_contact(false),
last_player_contact(false)
{
bool running = true;
/*
Platform::Platform(const Platform& other) :
- MovingSprite(other),
- ScriptInterface(other),
- speed(other.speed),
- automatic(other.automatic),
- player_contact(false),
+ MovingSprite(other),
+ ScriptInterface(other),
+ speed(other.speed),
+ automatic(other.automatic),
+ player_contact(false),
last_player_contact(false)
{
name = other.name;
// Travel to node nearest to nearest player
// FIXME: does not really use nearest player
- Player* player = 0;
+ Player* player = 0;
std::vector<Player*> players = Sector::current()->get_players();
for (std::vector<Player*>::iterator playerIter = players.begin(); playerIter != players.end(); ++playerIter) {
player = *playerIter;
goto_node(nearest_node_id);
}
}
- }
+ }
if (player_contact && !last_player_contact && !walker->is_moving()) {
// Player touched platform, didn't touch last frame and Platform is not moving
int farthest_node_id = path->get_farthest_node_no(get_pos());
if (farthest_node_id != -1) {
goto_node(farthest_node_id);
- }
+ }
}
// Clear player_contact flag set by collision() method
/**
* This class is the base class for platforms that tux can stand on
*/
-class Platform : public MovingSprite,
+class Platform : public MovingSprite,
public ScriptInterface
{
public:
/** acceleration in horizontal direction when walking
* (all accelerations are in pixel/s^2) */
static const float WALK_ACCELERATION_X = 300;
-/** acceleration in horizontal direction when running */
+/** acceleration in horizontal direction when running */
static const float RUN_ACCELERATION_X = 400;
/** acceleration when skidding */
static const float SKID_XM = 200;
deactivated(),
controller(),
scripting_controller(),
- player_status(_player_status),
+ player_status(_player_status),
duck(),
dead(),
dying(),
on_ground_flag(),
jumping(),
can_jump(),
- jump_button_timer(),
+ jump_button_timer(),
wants_buttjump(),
does_buttjump(),
invincible_timer(),
backflip_timer(),
physic(),
visible(),
- grabbed_object(NULL),
+ grabbed_object(NULL),
sprite(),
airarrow(),
floor_normal(),
- ghost_mode(false),
- edit_mode(false),
+ ghost_mode(false),
+ edit_mode(false),
unduck_hurt_timer(),
idle_timer(),
idle_stage(0),
}
}
-void
+void
Player::use_scripting_controller(bool use_or_release)
{
if ((use_or_release == true) && (controller != scripting_controller.get())) {
}
}
-void
+void
Player::do_scripting_controller(std::string control, bool pressed)
{
for(int i = 0; Controller::controlNames[i] != 0; ++i) {
Vector ppos = Vector(px, py);
Vector pspeed = Vector(0, 0);
Vector paccel = Vector(0, 0);
- Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite",
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite",
// draw bright sparkle when there is lots of time left, dark sparkle when invincibility is about to end
(invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING) ?
// make every other a longer sparkle to make trail a bit fuzzy
}
void
-Player::early_jump_apex()
+Player::early_jump_apex()
{
if (!jump_early_apex)
{
jump_button_timer.stop();
if (duck) {
// when running, only jump a little bit; else do a backflip
- if ((physic.get_velocity_x() != 0) ||
- (controller->hold(Controller::LEFT)) ||
- (controller->hold(Controller::RIGHT)))
+ if ((physic.get_velocity_x() != 0) ||
+ (controller->hold(Controller::LEFT)) ||
+ (controller->hold(Controller::RIGHT)))
{
do_jump(-300);
}
- else
+ else
{
do_backflip();
}
on_ground_flag = true;
floor_normal = hit.slope_normal;
- // Butt Jump landed
+ // Butt Jump landed
if (does_buttjump) {
does_buttjump = false;
physic.set_velocity_y(-300);
physic.set_velocity_y(std::max(physic.get_velocity_y() + velocity.y, end_speed.y));
}
-Vector
+Vector
Player::get_velocity()
{
return physic.get_velocity();
edit_mode = enable;
}
-void
+void
Player::start_climbing(Climbable& climbable)
{
if (climbing || !&climbable) return;
}
}
-void
+void
Player::stop_climbing(Climbable& /*climbable*/)
{
if (!climbing) return;
climbing = 0;
- if (grabbed_object) {
+ if (grabbed_object) {
grabbed_object->ungrab(*this, dir);
grabbed_object = NULL;
}
if (can_jump) {
stop_climbing(*climbing);
return;
- }
+ }
} else {
can_jump = true;
}
class Camera;
class PlayerStatus;
-class Player : public MovingObject,
- public scripting::Player,
+class Player : public MovingObject,
+ public scripting::Player,
public ScriptInterface
{
public:
* Adds velocity to the player until given end speed is reached
*/
void add_velocity(const Vector& velocity, const Vector& end_speed);
-
+
/**
* Returns the current velocity of the player
*/
* Orders the current GameSession to start a sequence
*/
void trigger_sequence(std::string sequence_name);
-
+
/**
* Requests that the player start climbing the given Climbable
*/
#include "supertux/sector.hpp"
PneumaticPlatform::PneumaticPlatform(const Reader& reader) :
- MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
- master(0),
- slave(0),
+ MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
+ master(0),
+ slave(0),
start_y(0),
- offset_y(0),
+ offset_y(0),
speed_y(0),
contacts()
{
}
PneumaticPlatform::PneumaticPlatform(PneumaticPlatform* master) :
- MovingSprite(*master),
- master(master),
- slave(this),
+ MovingSprite(*master),
+ master(master),
+ slave(this),
start_y(master->start_y),
- offset_y(-master->offset_y),
+ offset_y(-master->offset_y),
speed_y(0),
contacts()
{
master->slave = this;
}
-PneumaticPlatform::~PneumaticPlatform()
+PneumaticPlatform::~PneumaticPlatform()
{
if ((this == master) && (master)) {
slave->master = 0;
speed_y -= (offset_y * elapsed_time * 0.5f);
speed_y *= 1 - elapsed_time;
offset_y += speed_y * elapsed_time;
- if (offset_y < -256) { offset_y = -256; speed_y = 0; }
- if (offset_y > 256) { offset_y = 256; speed_y = -0; }
+ if (offset_y < -256) { offset_y = -256; speed_y = 0; }
+ if (offset_y > 256) { offset_y = 256; speed_y = -0; }
movement = Vector(0, (start_y + offset_y) - get_pos().y);
}
}
{
return true;
}
-
+
/**
* Is the object so heavy/bulky/fragile that Tux can't run while
* carrying it?
PulsingLight::PulsingLight(const Vector& center, float cycle_len, float min_alpha, float max_alpha, const Color& color) :
Light(center, color),
min_alpha(min_alpha),
- max_alpha(max_alpha),
- cycle_len(cycle_len),
+ max_alpha(max_alpha),
+ cycle_len(cycle_len),
t(0)
{
assert(cycle_len > 0);
}
PushButton::PushButton(const Reader& lisp) :
- MovingSprite(lisp, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING),
+ MovingSprite(lisp, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING),
script(),
state(OFF)
{
public:
float speed;
- RainParticle() :
+ RainParticle() :
speed()
{}
};
class Sprite;
-class Rock : public MovingSprite,
+class Rock : public MovingSprite,
public Portable
{
public:
MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING_STATIC),
physic(),
name(),
- solid(true),
- physic_enabled(true),
- visible(true),
+ solid(true),
+ physic_enabled(true),
+ visible(true),
new_vel_set(false),
new_vel()
{
#include "supertux/physic.hpp"
#include "supertux/script_interface.hpp"
-class ScriptedObject : public MovingSprite,
- public scripting::ScriptedObject,
+class ScriptedObject : public MovingSprite,
+ public scripting::ScriptedObject,
public ScriptInterface
{
public:
static const float FALLTIME = 0.8f;
SkullTile::SkullTile(const Reader& lisp) :
- MovingSprite(lisp, "images/objects/skull_tile/skull_tile.sprite", LAYER_TILES, COLGROUP_STATIC),
+ MovingSprite(lisp, "images/objects/skull_tile/skull_tile.sprite", LAYER_TILES, COLGROUP_STATIC),
physic(),
timer(),
- hit(false),
+ hit(false),
falling(false)
{
}
TextObject::TextObject(std::string name) :
font(),
text(),
- fading(0),
- fadetime(0),
- visible(false),
+ fading(0),
+ fadetime(0),
+ visible(false),
centered(),
anchor(ANCHOR_MIDDLE),
pos(0, 0)
#include "video/font_ptr.hpp"
/** A text object intended for scripts that want to tell a story */
-class TextObject : public GameObject,
+class TextObject : public GameObject,
public scripting::Text,
public ScriptInterface
{
}
void set_pos(const Vector& pos) {
- this->pos = pos;
- }
+ this->pos = pos;
+ }
void set_pos(float x, float y) {
set_pos(Vector(x, y));
}
const Vector& get_pos() const {
- return pos;
+ return pos;
}
float get_pos_x() {
return pos.x;
Thunderstorm::Thunderstorm(const Reader& reader) :
running(true),
- interval(10.0f),
+ interval(10.0f),
layer(LAYER_BACKGROUNDTILES-1),
time_to_thunder(),
time_to_lightning(),
/**
* Thunderstorm scriptable GameObject; plays thunder, lightning and electrifies water at regular interval
*/
-class Thunderstorm : public GameObject,
+class Thunderstorm : public GameObject,
public ScriptInterface
{
public:
#include "util/reader.hpp"
TileMap::TileMap(const TileSet *new_tileset) :
- tileset(new_tileset),
+ tileset(new_tileset),
tiles(),
real_solid(false),
effective_solid(false),
- speed_x(1),
- speed_y(1),
+ speed_x(1),
+ speed_y(1),
width(0),
- height(0),
- z_pos(0),
+ height(0),
+ z_pos(0),
offset(Vector(0,0)),
movement(0,0),
drawing_effect(NO_EFFECT),
- alpha(1.0),
+ alpha(1.0),
current_alpha(1.0),
remaining_fade_time(0),
path(),
tiles(),
real_solid(false),
effective_solid(false),
- speed_x(1),
- speed_y(1),
+ speed_x(1),
+ speed_y(1),
width(-1),
- height(-1),
- z_pos(0),
+ height(-1),
+ z_pos(0),
offset(Vector(0,0)),
- movement(Vector(0,0)),
+ movement(Vector(0,0)),
drawing_effect(NO_EFFECT),
- alpha(1.0),
- current_alpha(1.0),
+ alpha(1.0),
+ current_alpha(1.0),
remaining_fade_time(0),
path(),
walker(),
reader.get("speed-y", speed_y);
z_pos = reader_get_layer (reader, /* default = */ 0);
-
+
if(real_solid && ((speed_x != 1) || (speed_y != 1))) {
log_warning << "Speed of solid tilemap is not 1. fixing" << std::endl;
speed_x = 1;
TileMap::TileMap(const TileSet *new_tileset, std::string name, int z_pos,
bool solid, size_t width, size_t height) :
- tileset(new_tileset),
+ tileset(new_tileset),
tiles(),
real_solid(solid),
effective_solid(solid),
- speed_x(1),
- speed_y(1),
+ speed_x(1),
+ speed_y(1),
width(0),
- height(0),
- z_pos(z_pos),
+ height(0),
+ z_pos(z_pos),
offset(Vector(0,0)),
movement(Vector(0,0)),
- drawing_effect(NO_EFFECT),
- alpha(1.0),
+ drawing_effect(NO_EFFECT),
+ alpha(1.0),
current_alpha(1.0),
- remaining_fade_time(0),
+ remaining_fade_time(0),
path(),
walker(),
draw_target(DrawingContext::NORMAL)
this->remaining_fade_time = seconds;
}
-void
+void
TileMap::set_alpha(float alpha)
{
this->alpha = alpha;
update_effective_solid ();
}
-float
+float
TileMap::get_alpha()
{
return this->current_alpha;
}
-
+
/*
* Private methods
*/
/**
* This class is responsible for drawing the level tiles
*/
-class TileMap : public GameObject,
+class TileMap : public GameObject,
public ScriptInterface
{
public:
}
}
-Trampoline::Trampoline(const Vector& pos, bool port) :
+Trampoline::Trampoline(const Vector& pos, bool port) :
Rock(pos, "images/objects/trampoline/trampoline.sprite"),
portable(port)
{
#include "supertux/object_factory.hpp"
UnstableTile::UnstableTile(const Reader& lisp) :
- MovingSprite(lisp, LAYER_TILES, COLGROUP_STATIC),
+ MovingSprite(lisp, LAYER_TILES, COLGROUP_STATIC),
physic(),
state(STATE_NORMAL),
slowfall_timer()
} else
lightsprite->set_color(Color(0.3f, 0.2f, 0.1f));
}
-
+
if (sprite->animation_done()) {
state = STATE_DISINTEGRATING;
sprite->set_action("disintegrating", 1);
}
}
}
-
+
void
WeakBlock::startBurning()
{
#include "video/drawing_context.hpp"
Wind::Wind(const Reader& reader) :
- blowing(true),
+ blowing(true),
speed(),
- acceleration(100),
+ acceleration(100),
elapsed_time(0)
{
reader.get("name", name);
/**
* Defines an area that will gently push Players in one direction
*/
-class Wind : public MovingObject,
+class Wind : public MovingObject,
public ScriptInterface
{
public:
virtual void use_scripting_controller(bool use_or_release) = 0;
/**
- * Instructs the scriptable controller to press or release a button
+ * Instructs the scriptable controller to press or release a button
*/
virtual void do_scripting_controller(std::string control, bool pressed) = 0;
}
Sprite::Sprite(const Sprite& other) :
- data(other.data),
+ data(other.data),
frame(other.frame),
frameidx(other.frameidx),
animation_loops(other.animation_loops),
speed_top(),
speed_bottom()
{
- float infinity = (std::numeric_limits<float>::has_infinity ?
- std::numeric_limits<float>::infinity() :
+ float infinity = (std::numeric_limits<float>::has_infinity ?
+ std::numeric_limits<float>::infinity() :
std::numeric_limits<float>::max());
position_left = -infinity;
position_right = infinity;
speed_bottom = infinity;
}
- bool has_constraints() const
+ bool has_constraints() const
{
float infinity = (std::numeric_limits<float>::has_infinity ?
- std::numeric_limits<float>::infinity() :
+ std::numeric_limits<float>::infinity() :
std::numeric_limits<float>::max());
return
- position_left > -infinity ||
- position_right < infinity ||
- position_top > -infinity ||
+ position_left > -infinity ||
+ position_right < infinity ||
+ position_top > -infinity ||
position_bottom < infinity;
}
Console::Console() :
history(),
- history_position(history.end()),
+ history_position(history.end()),
lines(),
background(),
background2(),
- vm(NULL),
+ vm(NULL),
vm_object(),
backgroundOffset(0),
height(0),
- alpha(1.0),
- offset(0),
- focused(false),
+ alpha(1.0),
+ offset(0),
+ focused(false),
font(),
fontheight(),
- stayOpen(0)
+ stayOpen(0)
{
fontheight = 8;
}
}
}
-void
+void
Console::input(char c)
{
inputBuffer.insert(inputBufferPosition, 1, c);
}
}
-void
+void
Console::move_cursor(int offset)
{
if (offset == -65535) inputBufferPosition = 0;
#include "supertux/object_remove_listener.hpp"
GameObject::GameObject() :
- wants_to_die(false),
+ wants_to_die(false),
remove_listeners(NULL),
name()
{
wants_to_die(rhs.wants_to_die),
remove_listeners(NULL),
name(rhs.name)
-{
+{
}
GameObject::~GameObject()
entry = next;
}
}
-
-void
+
+void
GameObject::add_remove_listener(ObjectRemoveListener* listener)
{
RemoveListenerListEntry* entry = new RemoveListenerListEntry();
/**
* Base class for all the things that make up Levels' Sectors.
*
- * Each sector of a level will hold a list of active GameObject while the
+ * Each sector of a level will hold a list of active GameObject while the
* game is played.
*
* This class is responsible for:
* gets removed/destroyed
*/
void add_remove_listener(ObjectRemoveListener* listener);
-
- /**
+
+ /**
* unregisters a remove listener, so it will no longer be called if the object
* gets removed/destroyed
*/
end_sequence(0),
game_pause(false),
speed_before_pause(g_screen_manager->get_speed()),
- levelfile(levelfile_),
+ levelfile(levelfile_),
reset_sector(),
reset_pos(),
newsector(),
newspawnpoint(),
best_level_statistics(statistics),
player_status(player_status),
- capture_demo_stream(0),
+ capture_demo_stream(0),
capture_file(),
- playback_demo_stream(0),
+ playback_demo_stream(0),
demo_controller(0),
- play_time(0),
- edit_mode(false),
+ play_time(0),
+ edit_mode(false),
levelintro_shown(false),
coins_at_start(),
bonus_at_start(),
bool edit_mode; /**< true if GameSession runs in level editor mode */
bool levelintro_shown; /**< true if the LevelIntro screen was already shown */
-
+
int coins_at_start; /** How many coins does the player have at the start */
BonusType bonus_at_start; /** What bonuses does the player have at the start */
int max_fire_bullets_at_start; /** How many fire bullets does the player have */
config_video_lisp->get("aspect_width", aspect_size.width);
config_video_lisp->get("aspect_height", aspect_size.height);
-
+
config_video_lisp->get("magnification", magnification);
}
writer.write("aspect_width", aspect_size.width);
writer.write("aspect_height", aspect_size.height);
-
+
writer.write("magnification", magnification);
writer.end_list("video");
/** the aspect ratio */
Size aspect_size;
-
+
float magnification;
bool use_fullscreen;
} // namespace
-InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) :
+InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) :
lineType(NORMAL),
- font(Resources::normal_font),
+ font(Resources::normal_font),
color(),
- text(text),
+ text(text),
image()
{
font = get_font_by_format_char(format_char);
lineType = get_linetype_by_format_char(format_char);
color = get_color_by_format_char(format_char);
- if (lineType == IMAGE)
+ if (lineType == IMAGE)
{
image = Surface::create(text);
}
using namespace std;
Level::Level() :
- name("noname"),
- author("Mr. X"),
+ name("noname"),
+ author("Mr. X"),
contact(),
license(),
filename(),
sectors(),
stats(),
target_time(),
- tileset(NULL),
+ tileset(NULL),
free_tileset(false)
{
}
#include <boost/format.hpp>
LevelIntro::LevelIntro(const Level* level, const Statistics* best_level_statistics) :
- level(level),
- best_level_statistics(best_level_statistics),
+ level(level),
+ best_level_statistics(best_level_statistics),
player_sprite(),
- player_sprite_py(0),
+ player_sprite_py(0),
player_sprite_vy(0),
player_sprite_jump_timer()
{
player_sprite_vy = -300;
player_sprite_jump_timer.start(graphicsRandom.randf(2,3));
}
-
+
}
void
context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color);
py += static_cast<int>(Resources::normal_font->get_height());
}
-
+
{
std::stringstream ss;
ss << _("Secrets") << ": " << Statistics::secrets_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->secrets : 0, stats.total_secrets);
void quit_audio();
public:
- /** We call it run() instead of main() as main collides with
+ /** We call it run() instead of main() as main collides with
#define main SDL_main from SDL.h */
int run(int argc, char** argv);
};
// refresh list of addons
m_addons = adm.get_addons();
-
+
// sort list
std::sort(m_addons.begin(), m_addons.end(), generate_addons_menu_sorter);
//add_hl();
- for (unsigned int i = 0; i < m_addons.size(); i++)
+ for (unsigned int i = 0; i < m_addons.size(); i++)
{
const Addon& addon = *m_addons[i];
std::string text = "";
-
+
if (!addon.kind.empty())
{
std::string kind = addon.kind;
{
int index = check();
- if (index == -1)
+ if (index == -1)
{
// do nothing
}
else if (index == 0) // check if "Check Online" was chosen
{
- try
+ try
{
AddonManager::get_instance().check_online();
refresh();
set_active_item(index);
- }
+ }
catch (std::exception& e)
{
log_warning << "Check for available Add-ons failed: " << e.what() << std::endl;
else
{
// if one of the Addons listed was chosen, take appropriate action
- if ((index >= ADDON_LIST_START_ID) && (index < ADDON_LIST_START_ID) + m_addons.size())
+ if ((index >= ADDON_LIST_START_ID) && (index < ADDON_LIST_START_ID) + m_addons.size())
{
Addon& addon = *m_addons[index - ADDON_LIST_START_ID];
- if (!addon.installed)
+ if (!addon.installed)
{
- try
+ try
{
AddonManager::get_instance().install(&addon);
- }
- catch (std::exception& e)
+ }
+ catch (std::exception& e)
{
log_warning << "Installing Add-on failed: " << e.what() << std::endl;
}
set_toggled(index, addon.loaded);
- }
- else if (!addon.loaded)
+ }
+ else if (!addon.loaded)
{
- try
+ try
{
AddonManager::get_instance().enable(&addon);
- }
- catch (std::exception& e)
+ }
+ catch (std::exception& e)
{
log_warning << "Enabling Add-on failed: " << e.what() << std::endl;
}
set_toggled(index, addon.loaded);
- }
- else
+ }
+ else
{
- try
+ try
{
AddonManager::get_instance().disable(&addon);
- }
- catch (std::exception& e)
+ }
+ catch (std::exception& e)
{
log_warning << "Disabling Add-on failed: " << e.what() << std::endl;
}
public:
ContribMenu();
~ContribMenu();
-
+
void check_menu();
private:
{
int index = check();
if (index != -1) {
- if (get_item_by_id(index).kind == MN_ACTION)
+ if (get_item_by_id(index).kind == MN_ACTION)
{
sound_manager->stop_music();
GameManager::current()->start_level(std::move(m_world), index);
controller->keyboard_manager->wait_for_key = item->id;
} else if( item->id == Controller::CONTROLCOUNT) {
controller->keyboard_manager->jump_with_up_kbd = item->toggled;
- }
+ }
}
void
MNID_LANGUAGE_NEXT = 10
};
-LanguageMenu::LanguageMenu()
+LanguageMenu::LanguageMenu()
{
add_label(_("Language"));
add_hl();
int mnid = MNID_LANGUAGE_NEXT;
std::set<tinygettext::Language> languages = dictionary_manager->get_languages();
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
{
add_entry(mnid++, i->get_name());
}
}
void
-LanguageMenu::menu_action(MenuItem* item)
+LanguageMenu::menu_action(MenuItem* item)
{
if (item->id == MNID_LANGUAGE_AUTO_DETECT) // auto detect
{
int mnid = MNID_LANGUAGE_NEXT;
std::set<tinygettext::Language> languages = dictionary_manager->get_languages();
- for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
+ for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++)
{
- if (item->id == mnid++)
+ if (item->id == mnid++)
{
g_config->locale = i->str();
dictionary_manager->set_language(*i);
public:
MenuStorage();
~MenuStorage();
-
+
std::unique_ptr<Menu> create(MenuId menu_id);
-
+
private:
MenuStorage(const MenuStorage&);
MenuStorage& operator=(const MenuStorage&);
#include "supertux/globals.hpp"
#include "util/gettext.hpp"
-ProfileMenu::ProfileMenu()
+ProfileMenu::ProfileMenu()
{
add_label(_("Select Profile"));
add_hl();
}
void
-ProfileMenu::menu_action(MenuItem* item)
+ProfileMenu::menu_action(MenuItem* item)
{
g_config->profile = item->id;
MenuManager::instance().clear_menu_stack();
private:
/** this is only here for internal collision detection use (don't touch this
from outside collision detection code)
-
+
This field holds the currently anticipated destination of the object
during collision detection */
Rectf dest;
{
Factories::iterator i = factories.find(name);
- if (i == factories.end())
+ if (i == factories.end())
{
std::stringstream msg;
msg << "No factory for object '" << name << "' found.";
lisp::Parser parser;
const lisp::Lisp* lisp = parser.parse(lisptext, "create_object");
-
+
GameObject* object = create(name, *(lisp->get_car()));
return object;
}
class ConcreteObjectFactory : public AbstractObjectFactory
{
public:
- ConcreteObjectFactory() {}
+ ConcreteObjectFactory() {}
~ConcreteObjectFactory() {}
GameObject* create(const Reader& reader)
#include "supertux/sector.hpp"
Physic::Physic() :
- ax(0), ay(0),
- vx(0), vy(0),
- gravity_enabled_flag(true),
+ ax(0), ay(0),
+ vx(0), vy(0),
+ gravity_enabled_flag(true),
gravity_modifier(1.0f)
{
}
/** horizontal and vertical velocity */
float vx, vy;
-
+
/** should we respect gravity in our calculations? */
bool gravity_enabled_flag;
if (coin_surface)
{
- context.draw_surface(coin_surface,
- Vector(SCREEN_WIDTH - BORDER_X - coin_surface->get_width() - Resources::fixed_font->get_text_width(coins_text),
+ context.draw_surface(coin_surface,
+ Vector(SCREEN_WIDTH - BORDER_X - coin_surface->get_width() - Resources::fixed_font->get_text_width(coins_text),
BORDER_Y + 1 + (Resources::fixed_font->get_text_height(coins_text) + 5) * player_id),
LAYER_HUD);
}
- context.draw_text(Resources::fixed_font,
- coins_text,
+ context.draw_text(Resources::fixed_font,
+ coins_text,
Vector(SCREEN_WIDTH - BORDER_X - Resources::fixed_font->get_text_width(coins_text),
BORDER_Y + (Resources::fixed_font->get_text_height(coins_text) + 5) * player_id),
ALIGN_LEFT,
small_font.reset();
if(big_font != NULL)
big_font.reset();
-
+
/* Free tilesets */
delete tile_manager;
tile_manager = 0;
static SurfacePtr back;
static SurfacePtr arrow_left;
static SurfacePtr arrow_right;
-
+
public:
static void load_shared();
static void unload_shared();
/**
* Abstract base class for code the MainLoop runs exclusively and full-screen.
*
- * Examples of Screens are: The TitleScreen, a WorldMap, a level's
+ * Examples of Screens are: The TitleScreen, a WorldMap, a level's
* GameSession, a TextScroller, ...
*/
class Screen
class DrawingContext;
/**
- * Screen to be displayed simultaneously with another Screen.
+ * Screen to be displayed simultaneously with another Screen.
*
* This is used for Screen transition effects like a fade-out or a shrink-fade
*/
bool Sector::draw_solids_only = false;
Sector::Sector(Level* parent) :
- level(parent),
+ level(parent),
name(),
bullets(),
init_script(),
currentmusic(LEVEL_MUSIC),
sector_table(),
scripts(),
- ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ),
+ ambient_light( 1.0f, 1.0f, 1.0f, 1.0f ),
gameobjects(),
moving_objects(),
spawnpoints(),
portables(),
music(),
- gravity(10.0),
- player(0),
+ gravity(10.0),
+ player(0),
solid_tilemaps(),
- camera(0),
+ camera(0),
effect(0)
{
add_object(new Player(GameSession::current()->get_player_status(), "Tux"));
camera->update(1);
player->move(player->get_pos()+(Vector(32, 0)));
camera->update(1);
-
+
update_game_objects();
//Run default.nut just before init script
/// read sector from lisp file
void parse(const Reader& lisp);
void parse_old_format(const Reader& lisp);
-
+
/// activates this sector (change music, initialize player class, ...)
void activate(const std::string& spawnpoint);
void activate(const Vector& player_pos);
#include "video/drawing_context.hpp"
ShrinkFade::ShrinkFade(const Vector& dest, float fade_time) :
- dest(dest),
- fade_time(fade_time),
+ dest(dest),
+ fade_time(fade_time),
accum_time(0),
speedleft(),
speedright(),
{
float progress = accum_time / fade_time;
context.draw_inverse_ellipse(dest,
- Vector(2*SCREEN_WIDTH * (1.0f - progress),
+ Vector(2*SCREEN_WIDTH * (1.0f - progress),
2*SCREEN_HEIGHT * (1.0f - progress)),
Color(0, 0, 0), LAYER_GUI+1);
}
{}
SpawnPoint::SpawnPoint(const SpawnPoint& other) :
- name(other.name),
+ name(other.name),
pos(other.pos)
{}
float WMAP_INFO_TOP_Y1;
float WMAP_INFO_TOP_Y2;
-Statistics::Statistics() :
- coins(nv_coins),
- total_coins(nv_coins),
- badguys(nv_badguys),
- total_badguys(nv_badguys),
- time(nv_time),
- secrets(nv_secrets),
- total_secrets(nv_secrets),
- valid(true)
+Statistics::Statistics() :
+ coins(nv_coins),
+ total_coins(nv_coins),
+ badguys(nv_badguys),
+ total_badguys(nv_badguys),
+ time(nv_time),
+ secrets(nv_secrets),
+ total_secrets(nv_secrets),
+ valid(true)
{
WMAP_INFO_LEFT_X = SCREEN_WIDTH - 32 - 256;
WMAP_INFO_RIGHT_X = WMAP_INFO_LEFT_X + 256;
WMAP_INFO_TOP_Y1 = SCREEN_HEIGHT - 100;
WMAP_INFO_TOP_Y2 = WMAP_INFO_TOP_Y1 + 16;
}
-
- context.draw_text(Resources::small_font, std::string("- ") + _("Best Level Statistics") + " -",
- Vector((WMAP_INFO_LEFT_X + WMAP_INFO_RIGHT_X) / 2, WMAP_INFO_TOP_Y1),
+
+ context.draw_text(Resources::small_font, std::string("- ") + _("Best Level Statistics") + " -",
+ Vector((WMAP_INFO_LEFT_X + WMAP_INFO_RIGHT_X) / 2, WMAP_INFO_TOP_Y1),
ALIGN_CENTER, LAYER_HUD,Statistics::header_color);
std::string caption_buf;
bool
Statistics::completed(const Statistics& stats, const float target_time)
{
- return (stats.coins == stats.total_coins &&
- stats.badguys == stats.total_badguys &&
+ return (stats.coins == stats.total_coins &&
+ stats.badguys == stats.total_badguys &&
stats.secrets == stats.total_secrets &&
((!target_time) || (stats.time <= target_time)));
}
return os.str();
}
-std::string
+std::string
Statistics::time_to_string(float time) {
int time_csecs = std::min(static_cast<int>(time * 100), 99 * 6000 + 9999);
int mins = (time_csecs / 6000);
bool completed(const Statistics& stats, const float target_time); /* Check if stats match total stats */
void declare_invalid(); /**< marks statistics as invalid for their entire lifetime (e.g. after cheating). Invalid statistics will not be merged or drawn. */
-
+
static std::string coins_to_string(int coins, int total_coins);
static std::string frags_to_string(int badguys, int total_badguys);
static std::string time_to_string(float time);
images(),
editor_imagespecs(),
editor_images(),
- attributes(0),
- data(0),
+ attributes(0),
+ data(0),
fps(1)
{
}
-Tile::Tile(const std::vector<ImageSpec>& imagespecs_, const std::vector<ImageSpec>& editor_imagespecs_,
+Tile::Tile(const std::vector<ImageSpec>& imagespecs_, const std::vector<ImageSpec>& editor_imagespecs_,
uint32_t attributes, uint32_t data, float fps) :
imagespecs(imagespecs_),
images(),
editor_imagespecs(editor_imagespecs_),
editor_images(),
- attributes(attributes),
- data(data),
+ attributes(attributes),
+ data(data),
fps(fps)
{
correct_attributes();
if(images.size() == 0 && imagespecs.size() != 0)
{
assert(images.size() == 0);
- for(std::vector<ImageSpec>::iterator i = imagespecs.begin(); i != imagespecs.end(); ++i)
+ for(std::vector<ImageSpec>::iterator i = imagespecs.begin(); i != imagespecs.end(); ++i)
{
const ImageSpec& spec = *i;
SurfacePtr surface;
- if(spec.rect.get_width() <= 0)
+ if(spec.rect.get_width() <= 0)
{
surface = Surface::create(spec.file);
}
- else
+ else
{
surface = Surface::create(spec.file,
Rect((int) spec.rect.p1.x,
if(editor_images.size() == 0 && editor_imagespecs.size() != 0)
{
assert(editor_images.size() == 0);
- for(std::vector<ImageSpec>::iterator i = editor_imagespecs.begin(); i != editor_imagespecs.end(); ++i)
+ for(std::vector<ImageSpec>::iterator i = editor_imagespecs.begin(); i != editor_imagespecs.end(); ++i)
{
const ImageSpec& spec = *i;
SurfacePtr surface;
- if(spec.rect.get_width() <= 0)
+ if(spec.rect.get_width() <= 0)
{
surface = Surface::create(spec.file);
}
- else
+ else
{
surface = Surface::create(spec.file,
Rect((int) spec.rect.p1.x,
Tile::print_debug(int id) const
{
log_debug << " Tile: id " << id << ", data " << getData() << ", attributes " << getAttributes() << ":" << std::endl;
- for(std::vector<Tile::ImageSpec>::const_iterator im = editor_imagespecs.begin(); im != editor_imagespecs.end(); ++im)
+ for(std::vector<Tile::ImageSpec>::const_iterator im = editor_imagespecs.begin(); im != editor_imagespecs.end(); ++im)
log_debug << " Editor Imagespec: file " << im->file << "; rect " << im->rect << std::endl;
- for(std::vector<Tile::ImageSpec>::const_iterator im = imagespecs.begin(); im != imagespecs.end(); ++im)
+ for(std::vector<Tile::ImageSpec>::const_iterator im = imagespecs.begin(); im != imagespecs.end(); ++im)
log_debug << " Imagespec: file " << im->file << "; rect " << im->rect << std::endl;
}
}
const lisp::Lisp* tileset_reader = iter.lisp();
- std::string file;
+ std::string file;
if (!tileset_reader->get("file", file)) {
log_warning << "Skipping tileset import without file name" << std::endl;
continue;
m_tileset(tileset),
m_filename(filename),
m_tiles_path()
-{
+{
}
void
throw std::runtime_error("file is not a supertux tiles file.");
lisp::ListIterator iter(tiles_lisp);
- while(iter.next())
+ while(iter.next())
{
- if (iter.item() == "tile")
+ if (iter.item() == "tile")
{
parse_tile(*iter.lisp());
- }
- else if (iter.item() == "tilegroup")
+ }
+ else if (iter.item() == "tilegroup")
{
/* tilegroups are only interesting for the editor */
- }
- else if (iter.item() == "tiles")
+ }
+ else if (iter.item() == "tiles")
{
parse_tiles(*iter.lisp());
}
- else
+ else
{
log_warning << "Unknown symbol '" << iter.item() << "' in tileset file" << std::endl;
}
TileSetParser::parse_tile(const Reader& reader)
{
uint32_t id;
- if (!reader.get("id", id))
+ if (!reader.get("id", id))
{
throw std::runtime_error("Missing tile-id.");
}
float fps = 10;
reader.get("fps", fps);
- if(reader.get("slope-type", data))
+ if(reader.get("slope-type", data))
{
attributes |= Tile::SOLID | Tile::SLOPE;
}
if (id >= m_tileset.tiles.size())
m_tileset.tiles.resize(id+1, 0);
- if (m_tileset.tiles[id] != 0)
+ if (m_tileset.tiles[id] != 0)
{
log_warning << "Tile with ID " << id << " redefined" << std::endl;
- }
- else
+ }
+ else
{
m_tileset.tiles[id] = tile.release();
}
std::vector<Tile::ImageSpec> imagespecs;
const lisp::Lisp* list = &images_lisp;
- while(list)
+ while(list)
{
const lisp::Lisp* cur = list->get_car();
- if(cur->get_type() == lisp::Lisp::TYPE_STRING)
+ if(cur->get_type() == lisp::Lisp::TYPE_STRING)
{
std::string file;
cur->get(file);
}
else if(cur->get_type() == lisp::Lisp::TYPE_CONS &&
cur->get_car()->get_type() == lisp::Lisp::TYPE_SYMBOL &&
- cur->get_car()->get_symbol() == "region")
+ cur->get_car()->get_symbol() == "region")
{
const lisp::Lisp* ptr = cur->get_cdr();
ptr->get_car()->get(w); ptr = ptr->get_cdr();
ptr->get_car()->get(h);
imagespecs.push_back(Tile::ImageSpec(m_tiles_path + file, Rectf(x, y, x+w, y+h)));
- }
- else
+ }
+ else
{
log_warning << "Expected string or list in images tag" << std::endl;
}
{
throw std::runtime_error("Height is zero.");
}
- else if (fps < 0)
+ else if (fps < 0)
{
throw std::runtime_error("Negative fps.");
}
- else if (ids.size() != width*height)
+ else if (ids.size() != width*height)
{
std::ostringstream err;
err << "Number of ids (" << ids.size() << ") and "
<< ") mismatch for image '" << image_name << "', but must be equal";
throw std::runtime_error(err.str());
}
- else if (has_datas && ids.size() != datas.size())
- {
+ else if (has_datas && ids.size() != datas.size())
+ {
std::ostringstream err;
err << "Number of ids (" << ids.size() << ") and datas (" << datas.size()
<< ") mismatch for image '" << image_name << "', but must be equal";
}
else
{
- for(std::vector<uint32_t>::size_type i = 0; i < ids.size() && i < width*height; ++i)
+ for(std::vector<uint32_t>::size_type i = 0; i < ids.size() && i < width*height; ++i)
{
if (ids[i] != 0)
{
int y = 32*(i / width);
std::vector<Tile::ImageSpec> imagespecs;
- for(std::vector<std::string>::const_iterator j = images.begin(); j != images.end(); ++j)
+ for(std::vector<std::string>::const_iterator j = images.begin(); j != images.end(); ++j)
{
imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32)));
}
std::vector<Tile::ImageSpec> editor_imagespecs;
- for(std::vector<std::string>::const_iterator j = editor_images.begin(); j != editor_images.end(); ++j)
+ for(std::vector<std::string>::const_iterator j = editor_images.begin(); j != editor_images.end(); ++j)
{
editor_imagespecs.push_back(Tile::ImageSpec(m_tiles_path + *j, Rectf(x, y, x + 32, y + 32)));
}
}
}
}
- }
+ }
}
/* EOF */
TileSet& m_tileset;
std::string m_filename;
std::string m_tiles_path;
-
+
public:
TileSetParser(TileSet& tileset, const std::string& filename);
-
+
void parse();
private:
void parse_tile(const Reader& reader);
void parse_tiles(const Reader& reader);
std::vector<Tile::ImageSpec> parse_tile_images(const Reader& cur);
-
+
private:
TileSetParser(const TileSetParser&);
TileSetParser& operator=(const TileSetParser&);
#include "supertux/timer.hpp"
Timer::Timer() :
- period(0),
-cycle_start(0),
+ period(0),
+cycle_start(0),
cyclic(false)
{
}
private:
void make_tux_jump();
-
+
private:
SurfacePtr frame;
std::unique_ptr<CodeController> controller;
}
}
-void
+void
Climbable::update(float /*elapsed_time*/)
{
if (!climbed_by) return;
}
bool
-Climbable::may_climb(Player& player)
+Climbable::may_climb(Player& player)
{
if (player.get_bbox().p1.x < get_bbox().p1.x - GRACE_DX) return false;
if (player.get_bbox().p2.x > get_bbox().p2.x + GRACE_DX) return false;
private:
Timer message_timer;
bool message_displayed;
- std::string message; /**< message to display, default "You found a secret area!" */
+ std::string message; /**< message to display, default "You found a secret area!" */
std::string fade_tilemap; /**< tilemap to fade away when trigger is activated, or empty if you don't care */
std::string script; /**< optional script to run when trigger is activated */
};
TriggerBase::TriggerBase() :
sprite(),
- lasthit(false),
+ lasthit(false),
hit(false),
losetouch_listeners()
{
return ABORT_MOVE;
}
-
-void
+
+void
TriggerBase::object_removed(GameObject* object)
{
for (std::list<Player*>::iterator i = losetouch_listeners.begin(); i != losetouch_listeners.end(); i++) {
/** This class is the base class for all objects you can interact with in some
* way. There are several interaction types defined like touch and activate
*/
-class TriggerBase : public MovingObject,
+class TriggerBase : public MovingObject,
public ObjectRemoveListener
{
public:
* Receive trigger events
*/
virtual void event(Player& player, EventType type) = 0;
-
+
/**
* Called by GameObject destructor of an object in losetouch_listeners
*/
-// SuperTux
+// SuperTux
// Copyright (C) 2006 Ingo Ruhnke <grumbel@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
return (get_logging_instance ());
}
-std::ostream& log_debug_f(const char* file, int line)
+std::ostream& log_debug_f(const char* file, int line)
{
return (log_generic_f ("[DEBUG]", file, line));
}
-std::ostream& log_info_f(const char* file, int line)
+std::ostream& log_info_f(const char* file, int line)
{
return (log_generic_f ("[INFO]", file, line));
}
-std::ostream& log_warning_f(const char* file, int line)
+std::ostream& log_warning_f(const char* file, int line)
{
return (log_generic_f ("[WARNING]", file, line));
}
-std::ostream& log_fatal_f(const char* file, int line)
+std::ostream& log_fatal_f(const char* file, int line)
{
return (log_generic_f ("[FATAL]", file, line));
}
if(object)
object->unref();
}
-
+
Ref<T>& operator= (const Ref<T>& other)
{
*this = other.get();
}
}
- bool
+ bool
UTF8Iterator::done() const
{
return pos > text.size();
}
- UTF8Iterator&
+ UTF8Iterator&
UTF8Iterator::operator++() {
try {
chr = decode_utf8(text, pos);
{
public:
Color() :
- red(0),
- green(0),
- blue(0),
+ red(0),
+ green(0),
+ blue(0),
alpha(1.0f)
{}
Color(float red_, float green_, float blue_, float alpha_ = 1.0) :
red(red_),
- green(green_),
- blue(blue_),
+ green(green_),
+ blue(blue_),
alpha(alpha_)
{
assert(0 <= red && red <= 1.0);
virtual SDL_Window* get_window() const = 0;
static Renderer* instance() { assert(instance_); return instance_; }
-
+
protected:
static Renderer* instance_;
};
SDLLightmap::start_draw(const Color &ambient_color)
{
SDL_SetRenderTarget(renderer, texture);
-
+
Uint8 r = static_cast<Uint8>(ambient_color.red * 255);
Uint8 g = static_cast<Uint8>(ambient_color.green * 255);
Uint8 b = static_cast<Uint8>(ambient_color.blue * 255);
void
SDLLightmap::get_light(const DrawingRequest& request) const
{
- const GetLightRequest* getlightrequest
+ const GetLightRequest* getlightrequest
= (GetLightRequest*) request.request_data;
SDL_Rect rect;
m_surface(surface)
{}
- ~SDLSurfacePtr()
+ ~SDLSurfacePtr()
{
SDL_FreeSurface(m_surface);
}
Surface::Surface(const std::string& file) :
texture(texture_manager->get(file)),
surface_data(),
- rect(0, 0,
+ rect(0, 0,
Size(texture->get_image_width(),
texture->get_image_height())),
flipx(false)
return texture;
}
-SurfaceData*
+SurfaceData*
Surface::get_surface_data() const
{
return surface_data;
return rect.top;
}
-int
+int
Surface::get_width() const
{
return rect.get_width();
}
-int
+int
Surface::get_height() const
{
return rect.get_height();
Vector
Surface::get_position() const
{
- return Vector(get_x(), get_y());
+ return Vector(get_x(), get_y());
}
Vector
Surface::get_size() const
{
- return Vector(get_width(), get_height());
+ return Vector(get_width(), get_height());
}
/* EOF */
public:
Texture() : cache_filename() {}
- virtual ~Texture()
+ virtual ~Texture()
{
if (texture_manager && cache_filename != "")
/* The cache entry is now useless: its weak pointer to us has been
LevelTile::LevelTile(const std::string& basedir, const Reader& lisp) :
pos(),
title(),
- solved(false),
+ solved(false),
perfect(false),
- auto_play(false),
+ auto_play(false),
sprite(),
statistics(),
target_time(),
extro_script(),
- basedir(basedir),
+ basedir(basedir),
picture_cached(false),
picture(0)
{
namespace worldmap {
-SpawnPoint::SpawnPoint(const Reader& slisp) :
+SpawnPoint::SpawnPoint(const Reader& slisp) :
name(),
pos(),
auto_dir(D_NONE)
pos(),
sprite(),
map_message(),
- passive_message(false),
+ passive_message(false),
script(),
invisible(false),
- apply_action_north(true),
+ apply_action_north(true),
apply_action_east(true),
- apply_action_south(true),
+ apply_action_south(true),
apply_action_west(true)
{
lisp.get("x", pos.x);
SpriteChange::SpriteChange(const Reader& lisp) :
pos(),
- change_on_touch(false),
+ change_on_touch(false),
sprite(),
stay_action(),
stay_group(),
bool
Tux::canWalk(int tile_data, Direction dir)
{
- return ghost_mode ||
+ return ghost_mode ||
((tile_data & Tile::WORLDMAP_NORTH && dir == D_NORTH) ||
(tile_data & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) ||
(tile_data & Tile::WORLDMAP_EAST && dir == D_EAST) ||
~WorldMap();
void add_object(GameObject* object);
-
+
void try_expose(GameObject* object);
void try_unexpose(GameObject* object);
Vector get_next_tile(Vector pos, Direction direction);
/**
- * gets a bitfield of Tile::WORLDMAP_NORTH | Tile::WORLDMAP_WEST | ... values,
+ * gets a bitfield of Tile::WORLDMAP_NORTH | Tile::WORLDMAP_WEST | ... values,
* which indicates the directions Tux can move to when at the given position.
*/
int available_directions_at(Vector pos);
/**
- * returns a bitfield representing the union of all Tile::WORLDMAP_XXX values
+ * returns a bitfield representing the union of all Tile::WORLDMAP_XXX values
* of all solid tiles at the given position
*/
int tile_data_at(Vector pos);