// make sure it looks like an infoFile
static const std::string infoExt = ".nfo";
if (potentialInfoFileName.length() <= infoExt.length())
- continue;
+ continue;
if (potentialInfoFileName.compare(potentialInfoFileName.length()-infoExt.length(), infoExt.length(), infoExt) != 0)
- continue;
+ continue;
// make sure it's in the current archive
std::string infoFileDir = PHYSFS_getRealDir(potentialInfoFileName.c_str());
if(!file) {
log_warning << "Couldn't open '" << filename << "': " << PHYSFS_getLastError() << ", using dummy sound file." << std::endl;
file = PHYSFS_openRead("sounds/empty.wav");
- if (!file) {
+ if (!file) {
std::stringstream msg;
- msg << "Couldn't open dummy sound file '" << filename << "': " << PHYSFS_getLastError();
- throw std::runtime_error(msg.str());
- }
+ msg << "Couldn't open dummy sound file '" << filename << "': " << PHYSFS_getLastError();
+ throw std::runtime_error(msg.str());
+ }
}
try {
SoundManager::remove_from_update( StreamSoundSource* sss ){
if( sss != NULL ){
StreamSoundSources::iterator i = update_list.begin();
- while( i != update_list.end() ){
+ while( i != update_list.end() ){
if( *i == sss ){
i = update_list.erase(i);
} else {
bool is_sound_enabled() { return sound_enabled; }
bool is_audio_enabled() {
- return device != 0 && context != 0;
+ return device != 0 && context != 0;
}
void update();
static const float RECOVER_TIME = .5;
AngryStone::AngryStone(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"), state(IDLE)
+ : BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"), state(IDLE)
{
physic.set_velocity_x(0);
physic.set_velocity_y(0);
// hit from above?
if (badguy->get_bbox().p2.y < (bbox.p1.y + 16)) {
if(collision_squished(*badguy)) {
- return ABORT_MOVE;
+ return ABORT_MOVE;
}
}
// hit from above?
if (player->get_bbox().p2.y < (bbox.p1.y + 16)) {
if(collision_squished(*player)) {
- return ABORT_MOVE;
+ return ABORT_MOVE;
}
}
#include "object/explosion.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 = STATE_TICKING;
set_action(dir == LEFT ? "ticking-left" : "ticking-right", 1);
}
Bomb::Bomb(const Bomb& other)
- : BadGuy(other), state(other.state)
+ : BadGuy(other), state(other.state)
{
if (state == STATE_TICKING) {
ticking.reset(sound_manager->create_sound_source("sounds/fizz.wav"));
static const float WALKSPEED = 80;
BouncingSnowball::BouncingSnowball(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/bouncing_snowball/bouncing_snowball.sprite")
+ : BadGuy(reader, "images/creatures/bouncing_snowball/bouncing_snowball.sprite")
{
}
static const std::string SOUNDFILE = "sounds/flame.wav";
Dart::Dart(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/dart/dart.sprite"), parent(0)
+ : BadGuy(reader, "images/creatures/dart/dart.sprite"), parent(0)
{
physic.enable_gravity(false);
countMe = false;
}
Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent = 0)
- : BadGuy(pos, d, "images/creatures/dart/dart.sprite"), parent(parent)
+ : BadGuy(pos, d, "images/creatures/dart/dart.sprite"), parent(parent)
{
physic.enable_gravity(false);
countMe = false;
}
Dart::Dart(const Dart& other)
- : BadGuy(other), parent(other.parent)
+ : BadGuy(other), parent(other.parent)
{
sound_manager->preload(SOUNDFILE);
sound_manager->preload("sounds/darthit.wav");
}
DartTrap::DartTrap(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/darttrap/darttrap.sprite", LAYER_TILES-1), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
+ : BadGuy(reader, "images/creatures/darttrap/darttrap.sprite", LAYER_TILES-1), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
{
reader.get("initial-delay", initial_delay);
reader.get("fire-delay", fire_delay);
#include "random_generator.hpp"
Dispenser::Dispenser(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/dispenser/dispenser.sprite")
+ : BadGuy(reader, "images/creatures/dispenser/dispenser.sprite")
{
set_colgroup_active(COLGROUP_MOVING_STATIC);
sound_manager->preload("sounds/squish.wav");
static const float FISH_WAIT_TIME = 1;
Fish::Fish(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
+ : BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
{
physic.enable_gravity(true);
}
Fish::Fish(const Vector& pos)
- : BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
+ : BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
{
physic.enable_gravity(true);
}
}
FlyingSnowBall::FlyingSnowBall(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/flying_snowball/flying_snowball.sprite")
+ : BadGuy(reader, "images/creatures/flying_snowball/flying_snowball.sprite")
{
physic.enable_gravity(true);
}
FlyingSnowBall::FlyingSnowBall(const Vector& pos)
- : BadGuy(pos, "images/creatures/flying_snowball/flying_snowball.sprite")
+ : BadGuy(pos, "images/creatures/flying_snowball/flying_snowball.sprite")
{
physic.enable_gravity(true);
}
Color col;
switch(treecolor) {
- case 0: col = Color(1, 0, 0); break;
- case 1: col = Color(0, 1, 0); break;
- case 2: col = Color(0, 0, 1); break;
- case 3: col = Color(1, 1, 0); break;
- case 4: col = Color(1, 0, 1); break;
- case 5: col = Color(0, 1, 1); break;
- default: assert(false);
+ case 0: col = Color(1, 0, 0); break;
+ case 1: col = Color(0, 1, 0); break;
+ case 2: col = Color(0, 0, 1); break;
+ case 3: col = Color(1, 1, 0); break;
+ case 4: col = Color(1, 0, 1); break;
+ case 5: col = Color(0, 1, 1); break;
+ default: assert(false);
}
glow_sprite->set_color(col);
}
sound_manager->play("sounds/tree_suck.ogg", get_pos());
std::vector<TreeWillOWisp*>::iterator iter;
for(iter = willowisps.begin(); iter != willowisps.end(); ++iter) {
- TreeWillOWisp *willo = *iter;
- if(willo->get_color() == col) {
- willo->start_sucking(get_bbox().get_middle() + SUCK_TARGET_OFFSET + Vector(systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD), systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD)));
- }
+ TreeWillOWisp *willo = *iter;
+ if(willo->get_color() == col) {
+ willo->start_sucking(get_bbox().get_middle() + SUCK_TARGET_OFFSET + Vector(systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD), systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD)));
+ }
}
mystate = STATE_SUCKING;
}
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
- = new TreeWillOWisp(this, pos, 200 + willo_radius, willo_speed);
+ Vector pos = Vector(bbox.get_width() / 2, bbox.get_height() / 2 + willo_spawn_y + WILLOWISP_TOP_OFFSET);
+ TreeWillOWisp *willowisp
+ = new TreeWillOWisp(this, pos, 200 + willo_radius, willo_speed);
- Sector::current()->add_object(willowisp);
- willowisps.push_back(willowisp);
+ Sector::current()->add_object(willowisp);
+ willowisps.push_back(willowisp);
- willo_spawn_y -= 40;
- if(willo_spawn_y < -160)
- willo_spawn_y = 0;
+ willo_spawn_y -= 40;
+ if(willo_spawn_y < -160)
+ willo_spawn_y = 0;
- willo_radius += 20;
- if(willo_radius > 120)
- willo_radius = 0;
+ willo_radius += 20;
+ if(willo_radius > 120)
+ willo_radius = 0;
- if(willo_speed == 1.8f) {
- willo_speed = 1.5f;
- } else {
- willo_speed = 1.8f;
- }
+ if(willo_speed == 1.8f) {
+ willo_speed = 1.5f;
+ } else {
+ willo_speed = 1.8f;
+ }
- do {
- willo_color = (willo_color + 1) % 3;
- } while(willo_color == treecolor);
+ do {
+ willo_color = (willo_color + 1) % 3;
+ } while(willo_color == treecolor);
- switch(willo_color) {
- case 0: willowisp->set_color(Color(1, 0, 0)); break;
- case 1: willowisp->set_color(Color(0, 1, 0)); break;
- case 2: willowisp->set_color(Color(0, 0, 1)); break;
- case 3: willowisp->set_color(Color(1, 1, 0)); break;
- case 4: willowisp->set_color(Color(1, 0, 1)); break;
- case 5: willowisp->set_color(Color(0, 1, 1)); break;
- default: assert(false);
- }
+ switch(willo_color) {
+ case 0: willowisp->set_color(Color(1, 0, 0)); break;
+ case 1: willowisp->set_color(Color(0, 1, 0)); break;
+ case 2: willowisp->set_color(Color(0, 0, 1)); break;
+ case 3: willowisp->set_color(Color(1, 1, 0)); break;
+ case 4: willowisp->set_color(Color(1, 0, 1)); break;
+ case 5: willowisp->set_color(Color(0, 1, 1)); break;
+ default: assert(false);
+ }
}
}
}
KamikazeSnowball::KamikazeSnowball(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
+ : BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
{
sound_manager->preload(SPLAT_SOUND);
}
KamikazeSnowball::KamikazeSnowball(const Vector& pos, Direction d)
- : BadGuy(pos, d, "images/creatures/snowball/kamikaze-snowball.sprite")
+ : BadGuy(pos, d, "images/creatures/snowball/kamikaze-snowball.sprite")
{
sound_manager->preload(SPLAT_SOUND);
}
static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */
Mole::Mole(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1), state(PRE_THROWING)
+ : BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1), state(PRE_THROWING)
{
physic.enable_gravity(false);
sound_manager->preload("sounds/fall.wav");
}
Mole::Mole(const Vector& pos)
- : BadGuy(pos, "images/creatures/mole/mole.sprite", LAYER_TILES-1), state(PRE_THROWING)
+ : BadGuy(pos, "images/creatures/mole/mole.sprite", LAYER_TILES-1), state(PRE_THROWING)
{
physic.enable_gravity(false);
sound_manager->preload("sounds/fall.wav");
switch (state) {
case PRE_THROWING:
if (timer.check()) {
- set_state(THROWING);
+ set_state(THROWING);
}
break;
case THROWING:
if (throw_timer.check()) {
throw_rock();
- throw_timer.start(THROW_INTERVAL);
+ throw_timer.start(THROW_INTERVAL);
}
if (timer.check()) {
- set_state(POST_THROWING);
+ set_state(POST_THROWING);
}
break;
case POST_THROWING:
if (timer.check()) {
- set_state(PEEKING);
+ set_state(PEEKING);
}
break;
case PEEKING:
if (sprite->animation_done()) {
- set_state(PRE_THROWING);
+ set_state(PRE_THROWING);
}
break;
case DEAD:
#include "mole_rock.hpp"
MoleRock::MoleRock(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(0), initial_velocity(Vector(0, -400))
+ : BadGuy(reader, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(0), initial_velocity(Vector(0, -400))
{
physic.enable_gravity(true);
countMe = false;
}
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), initial_velocity(velocity)
+ : BadGuy(pos, LEFT, "images/creatures/mole/mole_rock.sprite", LAYER_TILES - 2), parent(parent), initial_velocity(velocity)
{
physic.enable_gravity(true);
countMe = false;
}
MoleRock::MoleRock(const MoleRock& other)
- : BadGuy(other), parent(other.parent), initial_velocity(Vector(0, -400))
+ : BadGuy(other), parent(other.parent), initial_velocity(Vector(0, -400))
{
sound_manager->preload("sounds/fall.wav");
sound_manager->preload("sounds/stomp.wav");
#include "audio/sound_manager.hpp"
MrBomb::MrBomb(const lisp::Lisp& reader)
- : WalkingBadguy(reader, "images/creatures/mr_bomb/mr_bomb.sprite", "left", "right")
+ : WalkingBadguy(reader, "images/creatures/mr_bomb/mr_bomb.sprite", "left", "right")
{
walk_speed = 80;
max_drop_height = 16;
/* MrBomb created by a dispenser always gets default sprite atm.*/
MrBomb::MrBomb(const Vector& pos, Direction d)
- : WalkingBadguy(pos, d, "images/creatures/mr_bomb/mr_bomb.sprite", "left", "right")
+ : WalkingBadguy(pos, d, "images/creatures/mr_bomb/mr_bomb.sprite", "left", "right")
{
walk_speed = 80;
max_drop_height = 16;
case ICESTATE_KICKED:
case ICESTATE_NORMAL:
{
- Player* player = dynamic_cast<Player*>(&object);
+ Player* player = dynamic_cast<Player*>(&object);
squishcount++;
if ((squishcount >= MAXSQUISHES) || (player && player->does_buttjump)) {
kill_fall();
break;
case ICESTATE_FLAT:
{
- MovingObject* movingobject = dynamic_cast<MovingObject*>(&object);
- if (movingobject && (movingobject->get_pos().x < get_pos().x)) {
- dir = RIGHT;
- } else {
- dir = LEFT;
- }
+ MovingObject* movingobject = dynamic_cast<MovingObject*>(&object);
+ if (movingobject && (movingobject->get_pos().x < get_pos().x)) {
+ dir = RIGHT;
+ } else {
+ dir = LEFT;
+ }
}
if (nokick_timer.check()) set_state(ICESTATE_KICKED);
break;
static const float SPEED = 200;
MrRocket::MrRocket(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/mr_rocket/mr_rocket.sprite")
+ : BadGuy(reader, "images/creatures/mr_rocket/mr_rocket.sprite")
{
}
MrRocket::MrRocket(const Vector& pos, Direction d)
- : BadGuy(pos, d, "images/creatures/mr_rocket/mr_rocket.sprite")
+ : BadGuy(pos, d, "images/creatures/mr_rocket/mr_rocket.sprite")
{
}
static const float WAKE_TIME = .5;
Plant::Plant(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/plant/plant.sprite")
+ : BadGuy(reader, "images/creatures/plant/plant.sprite")
{
state = PLANT_SLEEPING;
}
#include "object/sprite_particle.hpp"
PoisonIvy::PoisonIvy(const lisp::Lisp& reader)
- : WalkingBadguy(reader, "images/creatures/poison_ivy/poison_ivy.sprite", "left", "right")
+ : WalkingBadguy(reader, "images/creatures/poison_ivy/poison_ivy.sprite", "left", "right")
{
walk_speed = 80;
}
PoisonIvy::PoisonIvy(const Vector& pos, Direction d)
- : WalkingBadguy(pos, d, "images/creatures/poison_ivy/poison_ivy.sprite", "left", "right")
+ : WalkingBadguy(pos, d, "images/creatures/poison_ivy/poison_ivy.sprite", "left", "right")
{
walk_speed = 80;
}
}
SkullyHop::SkullyHop(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/skullyhop/skullyhop.sprite")
+ : BadGuy(reader, "images/creatures/skullyhop/skullyhop.sprite")
{
sound_manager->preload( HOP_SOUND );
}
SkullyHop::SkullyHop(const Vector& pos, Direction d)
- : BadGuy(pos, d, "images/creatures/skullyhop/skullyhop.sprite")
+ : BadGuy(pos, d, "images/creatures/skullyhop/skullyhop.sprite")
{
sound_manager->preload( HOP_SOUND );
}
#include "smartball.hpp"
SmartBall::SmartBall(const lisp::Lisp& reader)
- : WalkingBadguy(reader, "images/creatures/snowball/smart-snowball.sprite", "left", "right")
+ : WalkingBadguy(reader, "images/creatures/snowball/smart-snowball.sprite", "left", "right")
{
walk_speed = 80;
max_drop_height = 16;
}
SmartBall::SmartBall(const Vector& pos, Direction d)
- : WalkingBadguy(pos, d, "images/creatures/snowball/smart-snowball.sprite", "left", "right")
+ : WalkingBadguy(pos, d, "images/creatures/snowball/smart-snowball.sprite", "left", "right")
{
walk_speed = 80;
max_drop_height = 16;
case STATE_FLAT:
if (flat_timer.started()) {
- sprite->set_fps(64 - 15 * flat_timer.get_timegone());
+ sprite->set_fps(64 - 15 * flat_timer.get_timegone());
}
if (flat_timer.check()) {
- be_normal();
+ be_normal();
}
BadGuy::active_update(elapsed_time);
break;
case STATE_KICKED_DELAY:
if (kicked_delay_timer.check()) {
- physic.set_velocity_x(dir == LEFT ? -KICKSPEED : KICKSPEED);
- physic.set_velocity_y(KICKSPEED_Y);
- state = STATE_KICKED;
+ physic.set_velocity_x(dir == LEFT ? -KICKSPEED : KICKSPEED);
+ physic.set_velocity_y(KICKSPEED_Y);
+ state = STATE_KICKED;
}
BadGuy::active_update(elapsed_time);
break;
break;
case STATE_FLAT:
if(hit.top || hit.bottom) {
- physic.set_velocity_y(0);
+ physic.set_velocity_y(0);
}
if(hit.left || hit.right) {
}
break;
case STATE_KICKED_DELAY:
if(hit.top || hit.bottom) {
- physic.set_velocity_y(0);
+ physic.set_velocity_y(0);
}
if(hit.left || hit.right) {
- physic.set_velocity_x(0);
+ physic.set_velocity_x(0);
}
break;
case STATE_KICKED:
if(hit.top || hit.bottom) {
- physic.set_velocity_y(0);
+ physic.set_velocity_y(0);
}
if(hit.left || hit.right) {
- sound_manager->play("sounds/iceblock_bump.wav", get_pos());
+ sound_manager->play("sounds/iceblock_bump.wav", get_pos());
- if( ( dir == LEFT && hit.left ) || ( dir == RIGHT && hit.right) ){
- dir = (dir == LEFT) ? RIGHT : LEFT;
- sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
+ if( ( dir == LEFT && hit.left ) || ( dir == RIGHT && hit.right) ){
+ dir = (dir == LEFT) ? RIGHT : LEFT;
+ sprite->set_action(dir == LEFT ? "flat-left" : "flat-right");
- physic.set_velocity_x(-physic.get_velocity_x()*0.75);
- if (fabsf(physic.get_velocity_x()) < walk_speed) be_normal();
- }
+ physic.set_velocity_x(-physic.get_velocity_x()*0.75);
+ if (fabsf(physic.get_velocity_x()) < walk_speed) be_normal();
+ }
}
break;
case STATE_KICKED:
case STATE_NORMAL:
{
- Player* player = dynamic_cast<Player*>(&object);
+ Player* player = dynamic_cast<Player*>(&object);
squishcount++;
if ((squishcount >= MAXSQUISHES) || (player && player->does_buttjump)) {
kill_fall();
case STATE_FLAT:
sound_manager->play("sounds/kick.wav", get_pos());
{
- MovingObject* movingobject = dynamic_cast<MovingObject*>(&object);
- if (movingobject && (movingobject->get_pos().x < get_pos().x)) {
- dir = RIGHT;
- } else {
- dir = LEFT;
- }
+ MovingObject* movingobject = dynamic_cast<MovingObject*>(&object);
+ if (movingobject && (movingobject->get_pos().x < get_pos().x)) {
+ dir = RIGHT;
+ } else {
+ dir = LEFT;
+ }
}
be_kicked();
break;
static const float FLYSPEED = -100.0f;
SpiderMite::SpiderMite(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite")
+ : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite")
{
physic.enable_gravity(false);
}
SpiderMite::SpiderMite(const Vector& pos)
- : BadGuy(pos, "images/creatures/spidermite/spidermite.sprite")
+ : BadGuy(pos, "images/creatures/spidermite/spidermite.sprite")
{
physic.enable_gravity(false);
}
#include "spiky.hpp"
Spiky::Spiky(const lisp::Lisp& reader)
- : WalkingBadguy(reader, "images/creatures/spiky/spiky.sprite", "left", "right")
+ : WalkingBadguy(reader, "images/creatures/spiky/spiky.sprite", "left", "right")
{
walk_speed = 80;
max_drop_height = 600;
static const float WALKSPEED = 80;
SSpiky::SSpiky(const lisp::Lisp& reader)
- : WalkingBadguy(reader, "images/creatures/spiky/sleepingspiky.sprite", "left", "right"), state(SSPIKY_SLEEPING)
+ : WalkingBadguy(reader, "images/creatures/spiky/sleepingspiky.sprite", "left", "right"), state(SSPIKY_SLEEPING)
{
walk_speed = WALKSPEED;
max_drop_height = -1;
static const float SHAKE_RANGE_Y = 400;
Stalactite::Stalactite(const lisp::Lisp& lisp)
- : BadGuy(lisp, "images/creatures/stalactite/stalactite.sprite", LAYER_TILES - 1), state(STALACTITE_HANGING)
+ : BadGuy(lisp, "images/creatures/stalactite/stalactite.sprite", LAYER_TILES - 1), state(STALACTITE_HANGING)
{
countMe = false;
}
if(player->get_bbox().p2.x > bbox.p1.x - SHAKE_RANGE_X
&& player->get_bbox().p1.x < bbox.p2.x + SHAKE_RANGE_X
&& player->get_bbox().p2.y > bbox.p1.y
- && player->get_bbox().p1.y < bbox.p2.y + SHAKE_RANGE_Y) {
+ && player->get_bbox().p1.y < bbox.p2.y + SHAKE_RANGE_Y) {
timer.start(SHAKE_TIME);
state = STALACTITE_SHAKING;
}
switch (mystate) {
case STATE_INVINCIBLE:
if (invincible_timer.check()) {
- mystate = STATE_NORMAL;
+ mystate = STATE_NORMAL;
WalkingBadguy::initialize();
}
BadGuy::active_update(elapsed_time);
switch (mystate) {
case STATE_INVINCIBLE:
if(hit.top || hit.bottom) {
- physic.set_velocity_y(0);
+ physic.set_velocity_y(0);
}
if(hit.left || hit.right) {
- physic.set_velocity_x(0);
+ physic.set_velocity_x(0);
}
return CONTINUE;
break;
}
Toad::Toad(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/toad/toad.sprite")
+ : BadGuy(reader, "images/creatures/toad/toad.sprite")
{
sound_manager->preload(HOP_SOUND);
}
Toad::Toad(const Vector& pos, Direction d)
- : BadGuy(pos, d, "images/creatures/toad/toad.sprite")
+ : BadGuy(pos, d, "images/creatures/toad/toad.sprite")
{
sound_manager->preload(HOP_SOUND);
}
static const std::string LAND_ON_TOTEM_SOUND = "sounds/totem.ogg";
Totem::Totem(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/totem/totem.sprite")
+ : BadGuy(reader, "images/creatures/totem/totem.sprite")
{
carrying = 0;
carried_by = 0;
}
Totem::Totem(const Totem& other)
- : BadGuy(other), carrying(other.carrying), carried_by(other.carried_by)
+ : BadGuy(other), carrying(other.carrying), carried_by(other.carried_by)
{
sound_manager->preload( LAND_ON_TOTEM_SOUND );
}
if (s) {
// jump a bit if we find a suitable totem
for (std::vector<MovingObject*>::iterator i = s->moving_objects.begin(); i != s->moving_objects.end(); i++) {
- Totem* t = dynamic_cast<Totem*>(*i);
- if (!t) continue;
+ Totem* t = dynamic_cast<Totem*>(*i);
+ if (!t) continue;
- // skip if we are not approaching each other
- if (!((this->dir == LEFT) && (t->dir == RIGHT))) continue;
+ // skip if we are not approaching each other
+ if (!((this->dir == LEFT) && (t->dir == RIGHT))) continue;
- Vector p1 = this->get_pos();
- Vector p2 = t->get_pos();
+ Vector p1 = this->get_pos();
+ Vector p2 = t->get_pos();
- // skip if not on same height
- float dy = (p1.y - p2.y);
- if (fabsf(dy - 0) > 2) continue;
+ // skip if not on same height
+ float dy = (p1.y - p2.y);
+ if (fabsf(dy - 0) > 2) continue;
- // skip if too far away
- float dx = (p1.x - p2.x);
- if (fabsf(dx - 128) > 2) continue;
+ // skip if too far away
+ float dx = (p1.x - p2.x);
+ if (fabsf(dx - 128) > 2) continue;
- physic.set_velocity_y(JUMP_ON_SPEED_Y);
- p1.y -= 1;
- this->set_pos(p1);
- break;
+ physic.set_velocity_y(JUMP_ON_SPEED_Y);
+ p1.y -= 1;
+ this->set_pos(p1);
+ break;
}
}
}
#include "timer.hpp"
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), max_drop_height(-1)
+ : BadGuy(pos, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
{
}
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), max_drop_height(-1)
+ : 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)
{
}
WalkingBadguy::WalkingBadguy(const lisp::Lisp& 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), max_drop_height(-1)
+ : BadGuy(reader, sprite_name, layer), walk_left_action(walk_left_action), walk_right_action(walk_right_action), walk_speed(80), max_drop_height(-1)
{
}
#include "object/sprite_particle.hpp"
WalkingLeaf::WalkingLeaf(const lisp::Lisp& reader)
- : WalkingBadguy(reader, "images/creatures/walkingleaf/walkingleaf.sprite", "left", "right")
+ : WalkingBadguy(reader, "images/creatures/walkingleaf/walkingleaf.sprite", "left", "right")
{
walk_speed = 60;
max_drop_height = 16;
}
WalkingLeaf::WalkingLeaf(const Vector& pos, Direction d)
- : WalkingBadguy(pos, d, "images/creatures/walkingleaf/walkingleaf.sprite", "left", "right")
+ : WalkingBadguy(pos, d, "images/creatures/walkingleaf/walkingleaf.sprite", "left", "right")
{
walk_speed = 60;
max_drop_height = 16;
} else {
std::ostringstream msg;
msg << "Can't set unknown willowisp state '" << new_state << "', should "
- "be stopped, move_path, move_path_track or normal";
+ "be stopped, move_path, move_path_track or normal";
throw new std::runtime_error(msg.str());
}
}
}
Yeti::Yeti(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/yeti/yeti.sprite")
+ : BadGuy(reader, "images/creatures/yeti/yeti.sprite")
{
hit_points = INITIAL_HITPOINTS;
countMe = false;
physic.set_velocity_y(0);
switch (state) {
case JUMP_DOWN:
- run();
- break;
+ run();
+ break;
case RUN:
- break;
+ break;
case JUMP_UP:
- break;
+ break;
case BE_ANGRY:
- // we just landed
- if(!state_timer.started()) {
- sprite->set_action((dir==RIGHT)?"stand-right":"stand-left");
- stomp_count++;
- drop_stalactite();
-
- // go to other side after 3 jumps
- if(stomp_count == 3) {
- jump_down();
- } else {
- // jump again
- state_timer.start(STOMP_WAIT);
- }
- }
- break;
+ // we just landed
+ if(!state_timer.started()) {
+ sprite->set_action((dir==RIGHT)?"stand-right":"stand-left");
+ stomp_count++;
+ drop_stalactite();
+
+ // go to other side after 3 jumps
+ if(stomp_count == 3) {
+ jump_down();
+ } else {
+ // jump again
+ state_timer.start(STOMP_WAIT);
+ }
+ }
+ break;
case SQUISHED:
break;
}
#include "random_generator.hpp"
Zeekling::Zeekling(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/zeekling/zeekling.sprite"), last_player(0)
+ : BadGuy(reader, "images/creatures/zeekling/zeekling.sprite"), last_player(0)
{
state = FLYING;
speed = systemRandom.rand(130, 171);
}
Zeekling::Zeekling(const Vector& pos, Direction d)
- : BadGuy(pos, d, "images/creatures/zeekling/zeekling.sprite"), last_player(0)
+ : BadGuy(pos, d, "images/creatures/zeekling/zeekling.sprite"), last_player(0)
{
state = FLYING;
speed = systemRandom.rand(130, 171);
key_string+=".";
if (search_prefix.substr(0, key_string.length()) == key_string) {
sq_getclass(vm, -1);
- sq_insert_commands(cmds, vm, key_string, search_prefix);
+ sq_insert_commands(cmds, vm, key_string, search_prefix);
sq_pop(vm, 1);
}
break;
case OT_CLASS:
key_string+=".";
if (search_prefix.substr(0, key_string.length()) == key_string) {
- sq_insert_commands(cmds, vm, key_string, search_prefix);
+ sq_insert_commands(cmds, vm, key_string, search_prefix);
}
break;
case OT_CLOSURE:
default:
int c = event.key.keysym.unicode;
if ((c >= 32) && (c <= 126)) {
- Console::instance->input((char)c);
+ Console::instance->input((char)c);
}
break;
}
current_ = this;
if(currentsector != Sector::current()) {
- currentsector->activate(currentsector->player->get_pos());
+ currentsector->activate(currentsector->player->get_pos());
}
currentsector->play_music(LEVEL_MUSIC);
// abort if a sequence is already playing
if (end_sequence)
- return;
+ return;
if (sequencename == "endsequence") {
if (currentsector->get_players()[0]->physic.get_velocity_x() < 0) {
// Stop all clocks.
for(std::vector<GameObject*>::iterator i = currentsector->gameobjects.begin();
- i != currentsector->gameobjects.end(); ++i)
+ i != currentsector->gameobjects.end(); ++i)
{
GameObject* obj = *i;
state = BT_SELECTED;
}
break;
- case SDL_KEYDOWN: // key pressed
+ case SDL_KEYDOWN: // key pressed
if(event.key.keysym.sym == binding)
state = BT_SELECTED;
break;
MenuItem*
Menu::add_controlfield(int id, const std::string& text,
- const std::string& mapping)
+ const std::string& mapping)
{
MenuItem* item = new MenuItem(MN_CONTROLFIELD, id);
item->change_text(text);
- item->change_input(mapping);
+ item->change_input(mapping);
additem(item);
return item;
}
{
int i = items[active_item]->input.size();
- while(delete_character > 0) /* remove characters */
+ while(delete_character > 0) /* remove characters */
{
items[active_item]->input.resize(i-1);
delete_character--;
{
std::stringstream emsg;
emsg << "Parse Error at '" << filename << "' line " << lexer->getLineNumber()
- << ": " << msg;
+ << ": " << msg;
throw std::runtime_error(emsg.str());
}
Lisp* result;
switch(token) {
case Lexer::TOKEN_EOF: {
- parse_error("Unexpected EOF.");
+ parse_error("Unexpected EOF.");
}
case Lexer::TOKEN_CLOSE_PAREN: {
parse_error("Unexpected ')'.");
// evaluate translation function (_ str) in place here
token = lexer->getNextToken();
if(token != Lexer::TOKEN_STRING)
- parse_error("Expected string after '(_'");
+ parse_error("Expected string after '(_'");
result = new(obst) Lisp(Lisp::TYPE_STRING);
if(dictionary) {
}
token = lexer->getNextToken();
if(token != Lexer::TOKEN_CLOSE_PAREN)
- parse_error("Expected ')' after '(_ string'");
+ parse_error("Expected ')' after '(_ string'");
break;
}
// set default silence_distance
if (distance_factor == 0)
- silence_distance = std::numeric_limits<float>::max();
+ silence_distance = std::numeric_limits<float>::max();
else
silence_distance = 1/distance_factor;
// set default silence_distance
if (distance_factor == 0)
- silence_distance = std::numeric_limits<float>::max();
+ silence_distance = std::numeric_limits<float>::max();
else
silence_distance = 1/distance_factor;
sound_source->set_gain(currentvolume*maximumvolume);
if (sqrdistance>=silence_distance && currentvolume<1e-3)
- stop_playing();
+ stop_playing();
latency=0;
} else {
if (sqrdistance<silence_distance) {
- start_playing();
- latency=0;
+ start_playing();
+ latency=0;
}
else // set a reasonable latency
- latency=(int)(0.001/distance_factor);
+ latency=(int)(0.001/distance_factor);
//(int)(10*((sqrdistance-silence_distance)/silence_distance));
}
}
#include "object/portable.hpp"
BicyclePlatform::BicyclePlatform(const lisp::Lisp& reader)
- : MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
- master(0), slave(0), radius(128), angle(0), angular_speed(0), momentum(0)
+ : MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
+ master(0), slave(0), radius(128), angle(0), angular_speed(0), momentum(0)
{
center = get_pos();
}
BicyclePlatform::BicyclePlatform(BicyclePlatform* master)
- : MovingSprite(*master),
- master(master), slave(this), center(master->center), radius(master->radius), angle(master->angle + M_PI), angular_speed(0), momentum(0)
+ : MovingSprite(*master),
+ master(master), slave(this), center(master->center), radius(master->radius), angle(master->angle + M_PI), angular_speed(0), momentum(0)
{
set_pos(get_pos() + Vector(master->get_bbox().get_width(), 0));
master->master = master;
#include "random_generator.hpp"
Candle::Candle(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED), burning(true),
- candle_light_1("images/objects/candle/candle-light-1.png"),
- candle_light_2("images/objects/candle/candle-light-2.png")
+ : MovingSprite(lisp, "images/objects/candle/candle.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_DISABLED), burning(true),
+ candle_light_1("images/objects/candle/candle-light-1.png"),
+ candle_light_2("images/objects/candle/candle-light-2.png")
{
lisp.get("name", name);
lisp.get("burning", burning);
#include "timer.hpp"
Coin::Coin(const Vector& pos)
- : MovingSprite(pos, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE)
+ : MovingSprite(pos, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE)
{
sound_manager->preload("sounds/coin.wav");
}
Coin::Coin(const lisp::Lisp& reader)
- : MovingSprite(reader, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE)
+ : MovingSprite(reader, "images/objects/coin/coin.sprite", LAYER_TILES, COLGROUP_TOUCHABLE)
{
sound_manager->preload("sounds/coin.wav");
}
{
switch ((pitch_one - tile) % 7) {
case -6:
- pitch = 1.0/2;
- break;
+ pitch = 1.0/2;
+ break;
case -5:
- pitch = 5.0/8;
- break;
+ pitch = 5.0/8;
+ break;
case -4:
- pitch = 4.0/6;
- break;
+ pitch = 4.0/6;
+ break;
case -3:
- pitch = 3.0/4;
- break;
+ pitch = 3.0/4;
+ break;
case -2:
- pitch = 5.0/6;
- break;
+ pitch = 5.0/6;
+ break;
case -1:
- pitch = 9.0/10;
- break;
+ pitch = 9.0/10;
+ break;
case 0:
- pitch = 1.0;
- break;
+ pitch = 1.0;
+ break;
case 1:
- pitch = 9.0/8;
- break;
+ pitch = 9.0/8;
+ break;
case 2:
- pitch = 5.0/4;
- break;
+ pitch = 5.0/4;
+ break;
case 3:
- pitch = 4.0/3;
- break;
+ pitch = 4.0/3;
+ break;
case 4:
- pitch = 3.0/2;
- break;
+ pitch = 3.0/2;
+ break;
case 5:
- pitch = 5.0/3;
- break;
+ pitch = 5.0/3;
+ break;
case 6:
- pitch = 9.0/5;
- break;
+ pitch = 9.0/5;
+ break;
}
last_pitch = pitch;
}
#include "random_generator.hpp"
Explosion::Explosion(const Vector& pos)
- : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
+ : MovingSprite(pos, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
{
sound_manager->preload("sounds/explosion.wav");
set_pos(get_pos() - (get_bbox().get_middle() - get_pos()));
}
Explosion::Explosion(const lisp::Lisp& reader)
- : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
+ : MovingSprite(reader, "images/objects/explosion/explosion.sprite", LAYER_OBJECTS+40, COLGROUP_TOUCHABLE), state(STATE_WAITING)
{
sound_manager->preload("sounds/explosion.wav");
}
break;
case STATE_EXPLODING:
if(sprite->animation_done()) {
- remove_me();
+ remove_me();
}
break;
}
activated = true;
// spawn some particles
// TODO: provide convenience function in MovingSprite or MovingObject?
- for (int i = 0; i < 5; i++) {
- Vector ppos = bbox.get_middle();
- float angle = systemRandom.randf(-M_PI_2, M_PI_2);
- float velocity = systemRandom.randf(450, 900);
- float vx = sin(angle)*velocity;
- float vy = -cos(angle)*velocity;
- Vector pspeed = Vector(vx, vy);
- Vector paccel = Vector(0, 1000);
- Sector::current()->add_object(new SpriteParticle("images/objects/particles/reset.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1));
- }
+ for (int i = 0; i < 5; i++) {
+ Vector ppos = bbox.get_middle();
+ float angle = systemRandom.randf(-M_PI_2, M_PI_2);
+ float velocity = systemRandom.randf(450, 900);
+ float vx = sin(angle)*velocity;
+ float vy = -cos(angle)*velocity;
+ Vector pspeed = Vector(vx, vy);
+ Vector paccel = Vector(0, 1000);
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/reset.sprite", "default", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS-1));
+ }
// TODO play sound
sprite->set_action("ringing");
GameSession::current()->set_reset_point(Sector::current()->get_name(),
#include "audio/sound_manager.hpp"
GrowUp::GrowUp(Direction direction)
- : MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
+ : MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
{
physic.enable_gravity(true);
physic.set_velocity_x((direction == LEFT)?-100:100);
#include "object_factory.hpp"
HurtingPlatform::HurtingPlatform(const lisp::Lisp& reader)
- : Platform(reader)
+ : Platform(reader)
{
set_group(COLGROUP_TOUCHABLE);
}
}
IceCrusher::IceCrusher(const lisp::Lisp& reader)
- : MovingSprite(reader, "images/creatures/icecrusher/icecrusher.sprite", LAYER_OBJECTS, COLGROUP_STATIC),
- state(IDLE), speed(Vector(0,0))
+ : MovingSprite(reader, "images/creatures/icecrusher/icecrusher.sprite", LAYER_OBJECTS, COLGROUP_STATIC),
+ state(IDLE), speed(Vector(0,0))
{
start_position = get_bbox().p1;
set_state(state, true);
}
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);
#include "sprite/sprite.hpp"
InvisibleWall::InvisibleWall(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/invisible/invisible.sprite", LAYER_TILES, COLGROUP_STATIC), width(32), height(32)
+ : MovingSprite(lisp, "images/objects/invisible/invisible.sprite", LAYER_TILES, COLGROUP_STATIC), width(32), height(32)
{
- lisp.get("width", width);
- lisp.get("height", height);
- bbox.set_size(width, height);
+ lisp.get("width", width);
+ lisp.get("height", height);
+ bbox.set_size(width, height);
}
HitResponse
for (float test_y = lsy; test_y <= ley; test_y += 16) {
for(std::list<TileMap*>::const_iterator i = solid_tilemaps.begin(); i != solid_tilemaps.end(); i++) {
TileMap* solids = *i;
- const Tile* tile = solids->get_tile_at(Vector(test_x, test_y));
- if(!tile) continue;
+ const Tile* tile = solids->get_tile_at(Vector(test_x, test_y));
+ if(!tile) continue;
// FIXME: check collision with slope tiles
- if((tile->getAttributes() & Tile::SOLID)) return false;
+ if((tile->getAttributes() & Tile::SOLID)) return false;
}
}
}
}
MagicBlock::MagicBlock(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/magicblock/magicblock.sprite"),
+ : MovingSprite(lisp, "images/objects/magicblock/magicblock.sprite"),
is_solid(false), solid_time(0), switch_delay(0), light(1.0f,1.0f,1.0f)
{
set_group(COLGROUP_STATIC);
#include "timer.hpp"
MovingSprite::MovingSprite(const Vector& pos, const std::string& sprite_name, int layer, CollisionGroup collision_group)
- : sprite_name(sprite_name), layer(layer)
+ : sprite_name(sprite_name), layer(layer)
{
bbox.set_pos(pos);
sprite = sprite_manager->create(sprite_name);
}
MovingSprite::MovingSprite(const lisp::Lisp& reader, const Vector& pos, int layer, CollisionGroup collision_group)
- : layer(layer)
+ : layer(layer)
{
bbox.set_pos(pos);
if (!reader.get("sprite", sprite_name))
}
MovingSprite::MovingSprite(const lisp::Lisp& reader, const std::string& sprite_name, int layer, CollisionGroup collision_group)
- : sprite_name(sprite_name), layer(layer)
+ : sprite_name(sprite_name), layer(layer)
{
if (!reader.get("x", bbox.p1.x))
throw std::runtime_error("no x position set");
}
MovingSprite::MovingSprite(const lisp::Lisp& reader, int layer, CollisionGroup collision_group)
- : layer(layer)
+ : layer(layer)
{
if (!reader.get("x", bbox.p1.x))
throw std::runtime_error("no x position set");
}
MovingSprite::MovingSprite(const MovingSprite& other)
- : MovingObject(other), layer(other.layer)
+ : MovingObject(other), layer(other.layer)
{
sprite = new Sprite(*other.sprite);
}
#include "video/drawing_context.hpp"
OneUp::OneUp(const Vector& pos, Direction direction)
- : MovingSprite(pos, "images/powerups/1up/1up.sprite", LAYER_FLOATINGOBJECTS, COLGROUP_TOUCHABLE)
+ : MovingSprite(pos, "images/powerups/1up/1up.sprite", LAYER_FLOATINGOBJECTS, COLGROUP_TOUCHABLE)
{
physic.set_velocity((direction == LEFT)?-100:100, -400);
}
#include "random_generator.hpp"
ParticleSystem::ParticleSystem(float max_particle_size)
- : max_particle_size(max_particle_size)
+ : max_particle_size(max_particle_size)
{
virtual_width = SCREEN_WIDTH + max_particle_size * 2;
virtual_height = SCREEN_HEIGHT + max_particle_size *2;
}
CloudParticleSystem::CloudParticleSystem()
- : ParticleSystem(128)
+ : ParticleSystem(128)
{
cloudimage = new Surface("images/objects/particles/cloud.png");
{
public:
float speed;
- float wobble;
- float anchorx;
- float drift_speed;
+ float wobble;
+ float anchorx;
+ float drift_speed;
};
Surface* snowimages[3];
TileMap* solids = *i;
for(int x = starttilex; x*32 < max_x; ++x) {
for(int y = starttiley; y*32 < max_y; ++y) {
- const Tile* tile = solids->get_tile(x, y);
- if(!tile)
- continue;
- // skip non-solid tiles, except water
- if(! (tile->getAttributes() & (Tile::WATER | Tile::SOLID)))
- continue;
-
- if(tile->getAttributes() & Tile::SLOPE) { // slope tile
- AATriangle triangle;
- Vector p1(x*32, y*32);
- Vector p2((x+1)*32, (y+1)*32);
- triangle = AATriangle(p1, p2, tile->getData());
-
- if(rectangle_aatriangle(&constraints, dest, triangle)) {
- if(tile->getAttributes() & Tile::WATER)
- water = true;
- }
- } else { // normal rectangular tile
- Rect rect(x*32, y*32, (x+1)*32, (y+1)*32);
- if(intersects(dest, rect)) {
- if(tile->getAttributes() & Tile::WATER)
- water = true;
- set_rectangle_rectangle_constraints(&constraints, dest, rect);
- }
- }
+ const Tile* tile = solids->get_tile(x, y);
+ if(!tile)
+ continue;
+ // skip non-solid tiles, except water
+ if(! (tile->getAttributes() & (Tile::WATER | Tile::SOLID)))
+ continue;
+
+ if(tile->getAttributes() & Tile::SLOPE) { // slope tile
+ AATriangle triangle;
+ Vector p1(x*32, y*32);
+ Vector p2((x+1)*32, (y+1)*32);
+ triangle = AATriangle(p1, p2, tile->getData());
+
+ if(rectangle_aatriangle(&constraints, dest, triangle)) {
+ if(tile->getAttributes() & Tile::WATER)
+ water = true;
+ }
+ } else { // normal rectangular tile
+ Rect rect(x*32, y*32, (x+1)*32, (y+1)*32);
+ if(intersects(dest, rect)) {
+ if(tile->getAttributes() & Tile::WATER)
+ water = true;
+ set_rectangle_rectangle_constraints(&constraints, dest, rect);
+ }
+ }
}
}
}
#include "sector.hpp"
Platform::Platform(const lisp::Lisp& reader)
- : MovingSprite(reader, Vector(0,0), LAYER_OBJECTS, COLGROUP_STATIC),
- speed(Vector(0,0)),
- automatic(false), player_contact(false), last_player_contact(false)
+ : MovingSprite(reader, Vector(0,0), LAYER_OBJECTS, COLGROUP_STATIC),
+ speed(Vector(0,0)),
+ automatic(false), player_contact(false), last_player_contact(false)
{
bool running = true;
reader.get("name", name);
}
Platform::Platform(const Platform& other)
- : MovingSprite(other), ScriptInterface(other),
- speed(other.speed),
- automatic(other.automatic), player_contact(false), last_player_contact(false)
+ : MovingSprite(other), ScriptInterface(other),
+ speed(other.speed),
+ automatic(other.automatic), player_contact(false), last_player_contact(false)
{
name = other.name;
path.reset(new Path(*other.path));
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;
+ player = *playerIter;
}
if (player) {
- int nearest_node_id = path->get_nearest_node_no(player->get_bbox().p2);
- if (nearest_node_id != -1) {
- goto_node(nearest_node_id);
- }
+ int nearest_node_id = path->get_nearest_node_no(player->get_bbox().p2);
+ if (nearest_node_id != -1) {
+ goto_node(nearest_node_id);
+ }
}
}
// Travel to node farthest from current position
int farthest_node_id = path->get_farthest_node_no(get_pos());
if (farthest_node_id != -1) {
- goto_node(farthest_node_id);
+ goto_node(farthest_node_id);
}
}
Vector paccel = Vector(0, 0);
// draw bright sparkle when there is lots of time left, dark sparkle when invincibility is about to end
if (invincible_timer.get_timeleft() > TUX_INVINCIBLE_TIME_WARNING) {
- // make every other a longer sparkle to make trail a bit fuzzy
- if (size_t(game_time*20)%2) {
- Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "small", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
- } else {
- Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "medium", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
- }
+ // make every other a longer sparkle to make trail a bit fuzzy
+ if (size_t(game_time*20)%2) {
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "small", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+ } else {
+ Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "medium", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
+ }
} else {
Sector::current()->add_object(new SpriteParticle("images/objects/particles/sparkle.sprite", "dark", ppos, ANCHOR_MIDDLE, pspeed, paccel, LAYER_OBJECTS+1+5));
}
#include "object/portable.hpp"
PneumaticPlatform::PneumaticPlatform(const lisp::Lisp& reader)
- : MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
- master(0), slave(0), start_y(0), offset_y(0), speed_y(0)
+ : MovingSprite(reader, LAYER_OBJECTS, COLGROUP_STATIC),
+ master(0), slave(0), start_y(0), offset_y(0), speed_y(0)
{
start_y = get_pos().y;
}
PneumaticPlatform::PneumaticPlatform(PneumaticPlatform* master)
- : MovingSprite(*master),
- master(master), slave(this), start_y(master->start_y), offset_y(-master->offset_y), speed_y(0)
+ : MovingSprite(*master),
+ master(master), slave(this), start_y(master->start_y), offset_y(-master->offset_y), speed_y(0)
{
set_pos(get_pos() + Vector(master->get_bbox().get_width(), 0));
master->master = master;
#include "random_generator.hpp"
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), t(0)
+ : Light(center, color), min_alpha(min_alpha), max_alpha(max_alpha), cycle_len(cycle_len), t(0)
{
assert(cycle_len > 0);
}
PushButton::PushButton(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING), state(OFF)
+ : MovingSprite(lisp, "images/objects/pushbutton/pushbutton.sprite", LAYER_BACKGROUNDTILES+1, COLGROUP_MOVING), state(OFF)
{
sound_manager->preload(BUTTON_SOUND);
set_action("off", -1);
static const float FALLTIME = 0.8f;
SkullTile::SkullTile(const lisp::Lisp& lisp)
- : MovingSprite(lisp, "images/objects/skull_tile/skull_tile.sprite", LAYER_TILES, COLGROUP_STATIC), hit(false), falling(false)
+ : MovingSprite(lisp, "images/objects/skull_tile/skull_tile.sprite", LAYER_TILES, COLGROUP_STATIC), hit(false), falling(false)
{
}
#include "log.hpp"
SpriteParticle::SpriteParticle(std::string sprite_name, std::string action, Vector position, AnchorPoint anchor, Vector velocity, Vector acceleration, int drawing_layer)
- : position(position), velocity(velocity), acceleration(acceleration), drawing_layer(drawing_layer)
+ : position(position), velocity(velocity), acceleration(acceleration), drawing_layer(drawing_layer)
{
sprite = sprite_manager->create(sprite_name);
if (!sprite) throw std::runtime_error("Could not load sprite "+sprite_name);
static const float JUMPSPEED = -300;
Star::Star(const Vector& pos, Direction direction)
- : MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
+ : MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
{
physic.set_velocity((direction == LEFT) ? -SPEED : SPEED, INITIALJUMP);
}
#include "log.hpp"
namespace {
- const float LIGHTNING_DELAY = 2.0f;
- const float FLASH_DISPLAY_TIME = 0.1f;
+ const float LIGHTNING_DELAY = 2.0f;
+ const float FLASH_DISPLAY_TIME = 0.1f;
}
Thunderstorm::Thunderstorm(const lisp::Lisp& reader)
}
Trampoline::Trampoline(const lisp::Lisp& lisp)
- : Rock(lisp, "images/objects/trampoline/trampoline.sprite")
+ : Rock(lisp, "images/objects/trampoline/trampoline.sprite")
{
sound_manager->preload(TRAMPOLINE_SOUND);
float vy = player->physic.get_velocity_y();
//player is falling down on trampoline
if(hit.top && vy >= 0) {
- if(player->get_controller()->hold(Controller::JUMP)) {
- vy = VY_MIN;
- } else {
- vy = VY_INITIAL;
- }
- player->physic.set_velocity_y(vy);
- sound_manager->play(TRAMPOLINE_SOUND);
- sprite->set_action("swinging", 1);
- return FORCE_MOVE;
+ if(player->get_controller()->hold(Controller::JUMP)) {
+ vy = VY_MIN;
+ } else {
+ vy = VY_INITIAL;
+ }
+ player->physic.set_velocity_y(vy);
+ sound_manager->play(TRAMPOLINE_SOUND);
+ sprite->set_action("swinging", 1);
+ return FORCE_MOVE;
}
}
WalkingBadguy* walking_badguy = dynamic_cast<WalkingBadguy*> (&other);
float vy = walking_badguy->get_velocity_y();
//walking_badguy is falling down on trampoline
if(hit.top && vy >= 0) {
- vy = VY_INITIAL;
- walking_badguy->set_velocity_y(vy);
- sound_manager->play(TRAMPOLINE_SOUND);
- sprite->set_action("swinging", 1);
- return FORCE_MOVE;
+ vy = VY_INITIAL;
+ walking_badguy->set_velocity_y(vy);
+ sound_manager->play(TRAMPOLINE_SOUND);
+ sprite->set_action("swinging", 1);
+ return FORCE_MOVE;
}
}
}
case STATE_DISINTEGRATING:
movement = physic.get_movement(elapsed_time);
if (sprite->animation_done()) {
- remove_me();
- return;
+ remove_me();
+ return;
}
break;
}
SDL_RWops* get_physfs_SDLRWops(const std::string& filename)
{
- // check this as PHYSFS seems to be buggy and still returns a
- // valid pointer in this case
- if(filename == "") {
- throw std::runtime_error("Couldn't open file: empty filename");
- }
+ // check this as PHYSFS seems to be buggy and still returns a
+ // valid pointer in this case
+ if(filename == "") {
+ throw std::runtime_error("Couldn't open file: empty filename");
+ }
PHYSFS_file* file = (PHYSFS_file*) PHYSFS_openRead(filename.c_str());
if(!file) {
IFileStreambuf::IFileStreambuf(const std::string& filename)
{
- // check this as PHYSFS seems to be buggy and still returns a
- // valid pointer in this case
- if(filename == "") {
- throw std::runtime_error("Couldn't open file: empty filename");
- }
+ // check this as PHYSFS seems to be buggy and still returns a
+ // valid pointer in this case
+ if(filename == "") {
+ throw std::runtime_error("Couldn't open file: empty filename");
+ }
file = PHYSFS_openRead(filename.c_str());
if(file == 0) {
std::stringstream msg;
double RandomGenerator::randf(double v) {
float rv;
do {
- rv = ((double)RandomGenerator::random())/RandomGenerator::rand_max * v;
- } while (rv >= v); // rounding might cause rv==v
+ rv = ((double)RandomGenerator::random())/RandomGenerator::rand_max * v;
+ } while (rv >= v); // rounding might cause rv==v
if (debug > 0)
printf("==== rand(): %f =====\n", rv);
if (Sector::current() == 0)
{
log_info << "No current sector." << std::endl;
- return false;
+ return false;
}
if (Sector::current()->player == 0)
{
log_info << "No player." << std::endl;
- return false;
+ return false;
}
return true;
}
{
Thunderstorm::Thunderstorm(::Thunderstorm* thunderstorm)
- : thunderstorm(thunderstorm)
+ : thunderstorm(thunderstorm)
{
}
TileMap* solids = *i;
for(size_t x=0; x < solids->get_width(); ++x) {
for(size_t y=0; y < solids->get_height(); ++y) {
- uint32_t id = solids->get_tile_id(x, y);
- const Tile *tile = solids->get_tile(x, y);
- Vector pos(solids->get_x_offset() + x*32, solids->get_y_offset() + y*32);
-
- if(id == 112) {
- add_object(new InvisibleBlock(pos));
- solids->change(x, y, 0);
- } else if(tile->getAttributes() & Tile::COIN) {
- add_object(new Coin(pos));
- solids->change(x, y, 0);
- } else if(tile->getAttributes() & Tile::FULLBOX) {
- add_object(new BonusBlock(pos, tile->getData()));
- solids->change(x, y, 0);
- } else if(tile->getAttributes() & Tile::BRICK) {
- add_object(new Brick(pos, tile->getData()));
- solids->change(x, y, 0);
- } else if(tile->getAttributes() & Tile::GOAL) {
- std::string sequence = tile->getData() == 0 ? "endsequence" : "stoptux";
- add_object(new SequenceTrigger(pos, sequence));
- solids->change(x, y, 0);
- }
+ uint32_t id = solids->get_tile_id(x, y);
+ const Tile *tile = solids->get_tile(x, y);
+ Vector pos(solids->get_x_offset() + x*32, solids->get_y_offset() + y*32);
+
+ if(id == 112) {
+ add_object(new InvisibleBlock(pos));
+ solids->change(x, y, 0);
+ } else if(tile->getAttributes() & Tile::COIN) {
+ add_object(new Coin(pos));
+ solids->change(x, y, 0);
+ } else if(tile->getAttributes() & Tile::FULLBOX) {
+ add_object(new BonusBlock(pos, tile->getData()));
+ solids->change(x, y, 0);
+ } else if(tile->getAttributes() & Tile::BRICK) {
+ add_object(new Brick(pos, tile->getData()));
+ solids->change(x, y, 0);
+ } else if(tile->getAttributes() & Tile::GOAL) {
+ std::string sequence = tile->getData() == 0 ? "endsequence" : "stoptux";
+ add_object(new SequenceTrigger(pos, sequence));
+ solids->change(x, y, 0);
+ }
}
}
}
for(size_t x=0; x < tm->get_width(); ++x) {
for(size_t y=0; y < tm->get_height(); ++y) {
uint32_t id = tm->get_tile_id(x, y);
- Vector pos(tm->get_x_offset() + x*32, tm->get_y_offset() + y*32);
- Vector center(pos.x + 16, pos.y + 16);
-
- // torch
- if (id == 1517) {
- float pseudo_rnd = (float)((int)pos.x % 10) / 10;
- add_object(new PulsingLight(center, 1.0f + pseudo_rnd, 0.9f, 1.0f, Color(1.0f, 1.0f, 0.6f, 1.0f)));
- }
- // lava or lavaflow
- if ((id == 173) || (id == 1700) || (id == 1705) || (id == 1706)) {
- // space lights a bit
- if ((((tm->get_tile_id(x-1, y)) != tm->get_tile_id(x,y))
- && (tm->get_tile_id(x, y-1) != tm->get_tile_id(x,y)))
- || ((x % 3 == 0) && (y % 3 == 0))) {
- float pseudo_rnd = (float)((int)pos.x % 10) / 10;
- add_object(new PulsingLight(center, 1.0f + pseudo_rnd, 0.8f, 1.0f, Color(1.0f, 0.3f, 0.0f, 1.0f)));
- }
- }
+ Vector pos(tm->get_x_offset() + x*32, tm->get_y_offset() + y*32);
+ Vector center(pos.x + 16, pos.y + 16);
+
+ // torch
+ if (id == 1517) {
+ float pseudo_rnd = (float)((int)pos.x % 10) / 10;
+ add_object(new PulsingLight(center, 1.0f + pseudo_rnd, 0.9f, 1.0f, Color(1.0f, 1.0f, 0.6f, 1.0f)));
+ }
+ // lava or lavaflow
+ if ((id == 173) || (id == 1700) || (id == 1705) || (id == 1706)) {
+ // space lights a bit
+ if ((((tm->get_tile_id(x-1, y)) != tm->get_tile_id(x,y))
+ && (tm->get_tile_id(x, y-1) != tm->get_tile_id(x,y)))
+ || ((x % 3 == 0) && (y % 3 == 0))) {
+ float pseudo_rnd = (float)((int)pos.x % 10) / 10;
+ add_object(new PulsingLight(center, 1.0f + pseudo_rnd, 0.8f, 1.0f, Color(1.0f, 0.3f, 0.0f, 1.0f)));
+ }
+ }
}
}
for(int x = starttilex; x*32 < max_x; ++x) {
for(int y = starttiley; y*32 < max_y; ++y) {
- const Tile* tile = solids->get_tile(x, y);
- if(!tile)
- continue;
- // skip non-solid tiles
- if((tile->getAttributes() & Tile::SOLID) == 0)
- continue;
- // only handle unisolid when the player is falling down and when he was
- // above the tile before
- if(tile->getAttributes() & Tile::UNISOLID) {
- if(movement.y <= 0 || dest.get_bottom() - movement.y - SHIFT_DELTA > y*32)
- continue;
- }
-
- if(tile->getAttributes() & Tile::SLOPE) { // slope tile
- AATriangle triangle;
- Vector p1(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset());
- Vector p2((x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
- triangle = AATriangle(p1, p2, tile->getData());
-
- collision::rectangle_aatriangle(constraints, dest, triangle, solids->get_movement());
- } else { // normal rectangular tile
- Rect rect(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset(), (x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
- check_collisions(constraints, movement, dest, rect, NULL, NULL, solids->get_movement());
- }
+ const Tile* tile = solids->get_tile(x, y);
+ if(!tile)
+ continue;
+ // skip non-solid tiles
+ if((tile->getAttributes() & Tile::SOLID) == 0)
+ continue;
+ // only handle unisolid when the player is falling down and when he was
+ // above the tile before
+ if(tile->getAttributes() & Tile::UNISOLID) {
+ if(movement.y <= 0 || dest.get_bottom() - movement.y - SHIFT_DELTA > y*32)
+ continue;
+ }
+
+ if(tile->getAttributes() & Tile::SLOPE) { // slope tile
+ AATriangle triangle;
+ Vector p1(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset());
+ Vector p2((x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
+ triangle = AATriangle(p1, p2, tile->getData());
+
+ collision::rectangle_aatriangle(constraints, dest, triangle, solids->get_movement());
+ } else { // normal rectangular tile
+ Rect rect(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset(), (x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
+ check_collisions(constraints, movement, dest, rect, NULL, NULL, solids->get_movement());
+ }
}
}
}
for(int x = starttilex; x*32 < max_x; ++x) {
for(int y = starttiley; y*32 < max_y; ++y) {
- const Tile* tile = solids->get_tile(x, y);
- if(!tile)
- continue;
- result |= tile->getAttributes();
+ const Tile* tile = solids->get_tile(x, y);
+ if(!tile)
+ continue;
+ result |= tile->getAttributes();
}
}
}
for(int x = starttilex; x*32 <= max_x; ++x) {
for(int y = starttiley; y*32 <= max_y; ++y) {
- const Tile* tile = solids->get_tile(x, y);
- if(!tile) continue;
- if(tile->getAttributes() & Tile::SLOPE) {
- AATriangle triangle;
- Vector p1(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset());
- Vector p2((x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
- triangle = AATriangle(p1, p2, tile->getData());
- Constraints constraints;
- return collision::rectangle_aatriangle(&constraints, rect, triangle);
- }
- if((tile->getAttributes() & Tile::SOLID) && !ignoreUnisolid) return false;
- if((tile->getAttributes() & Tile::SOLID) && !(tile->getAttributes() & Tile::UNISOLID)) return false;
+ const Tile* tile = solids->get_tile(x, y);
+ if(!tile) continue;
+ if(tile->getAttributes() & Tile::SLOPE) {
+ AATriangle triangle;
+ Vector p1(x*32 + solids->get_x_offset(), y*32 + solids->get_y_offset());
+ Vector p2((x+1)*32 + solids->get_x_offset(), (y+1)*32 + solids->get_y_offset());
+ triangle = AATriangle(p1, p2, tile->getData());
+ Constraints constraints;
+ return collision::rectangle_aatriangle(&constraints, rect, triangle);
+ }
+ if((tile->getAttributes() & Tile::SOLID) && !ignoreUnisolid) return false;
+ if((tile->getAttributes() & Tile::SOLID) && !(tile->getAttributes() & Tile::UNISOLID)) return false;
}
}
}
switch (stat_no)
{
case 0:
- caption_buf = _("Max coins collected:");
- stat_buf = coins_to_string(coins, total_coins);
- break;
+ caption_buf = _("Max coins collected:");
+ stat_buf = coins_to_string(coins, total_coins);
+ break;
case 1:
- caption_buf = _("Max fragging:");
- stat_buf = frags_to_string(badguys, total_badguys);
- break;
+ caption_buf = _("Max fragging:");
+ stat_buf = frags_to_string(badguys, total_badguys);
+ break;
case 2:
- caption_buf = _("Min time needed:");
- stat_buf = time_to_string(time);
- break;
+ caption_buf = _("Min time needed:");
+ stat_buf = time_to_string(time);
+ break;
case 3:
- caption_buf = _("Max secrets found:");
- stat_buf = secrets_to_string(secrets, total_secrets);
- break;
+ caption_buf = _("Max secrets found:");
+ stat_buf = secrets_to_string(secrets, total_secrets);
+ break;
default:
- log_debug << "Invalid stat requested to be drawn" << std::endl;
- break;
+ log_debug << "Invalid stat requested to be drawn" << std::endl;
+ break;
}
context.draw_text(white_small_text, caption_buf, Vector(WMAP_INFO_LEFT_X, posy), ALIGN_LEFT, LAYER_GUI);
WORLDMAP_SOUTH = 0x0002,
WORLDMAP_EAST = 0x0004,
WORLDMAP_WEST = 0x0008,
- WORLDMAP_DIR_MASK = 0x000f,
+ WORLDMAP_DIR_MASK = 0x000f,
WORLDMAP_STOP = 0x0010,
Tile *tile = tileset->tiles[id];
if(tile == NULL)
- continue;
+ continue;
if(tiles[dest_id] != NULL) {
log_warning << "tileset merge resulted in multiple definitions for id "
*filename != 0; filename++) {
// check if filename matches requested language
- std::string fname = std::string(*filename);
- std::string load_from_file = "";
+ std::string fname = std::string(*filename);
+ std::string load_from_file = "";
if(fname == lang + ".po") {
- load_from_file = fname;
- } else {
+ load_from_file = fname;
+ } else {
std::string::size_type s = lang.find("_");
if(s != std::string::npos) {
std::string lang_short = std::string(lang, 0, s);
- if (fname == lang_short + ".po") {
- load_from_file = lang_short;
- }
+ if (fname == lang_short + ".po") {
+ load_from_file = lang_short;
+ }
}
- }
+ }
- // if it matched, load dictionary
- if (load_from_file != "") {
+ // if it matched, load dictionary
+ if (load_from_file != "") {
//log_debug << "Loading dictionary for language \"" << lang << "\" from \"" << filename << "\"" << std::endl;
std::string pofile = *p + "/" + *filename;
try {
level->get("name", name);
return name;
} catch(std::exception& e) {
- log_warning << "Problem getting name of '" << filename << "': "
+ log_warning << "Problem getting name of '" << filename << "': "
<< e.what() << std::endl;
return "";
}
case MNID_QUITMAINMENU:
main_loop->quit(new FadeOut(0.25));
- sound_manager->stop_music(0.25);
+ sound_manager->stop_music(0.25);
break;
}
} else if(menu == contrib_menu.get()) {
#include "audio/sound_manager.hpp"
Door::Door(const lisp::Lisp& reader)
- : state(CLOSED)
+ : state(CLOSED)
{
reader.get("x", bbox.p1.x);
reader.get("y", bbox.p1.y);
}
Door::Door(int x, int y, std::string sector, std::string spawnpoint)
- : state(CLOSED)
+ : state(CLOSED)
{
bbox.set_pos(Vector(x, y));
target_sector = sector;
case OPENING:
// if door has finished opening, start timer and keep door open
if(sprite->animation_done()) {
- state = OPEN;
- sprite->set_action("open");
+ state = OPEN;
+ sprite->set_action("open");
stay_open_timer.start(1.0);
}
break;
case OPEN:
// if door was open long enough, start closing it
if (stay_open_timer.check()) {
- state = CLOSING;
- sprite->set_action("closing", 1);
+ state = CLOSING;
+ sprite->set_action("closing", 1);
}
break;
case CLOSING:
// if door has finished closing, keep it shut
if(sprite->animation_done()) {
- state = CLOSED;
- sprite->set_action("closed");
+ state = CLOSED;
+ sprite->set_action("closed");
}
break;
}
case CLOSED:
// if door was activated, start opening it
if (type == EVENT_ACTIVATE) {
- state = OPENING;
+ state = OPENING;
sound_manager->play("sounds/door.wav");
- sprite->set_action("opening", 1);
+ sprite->set_action("opening", 1);
}
break;
case OPENING:
case OPEN:
{
// if door is open and was touched by a player, teleport the player
- Player* player = dynamic_cast<Player*> (&other);
- if (player) {
- state = CLOSING;
- sprite->set_action("closing", 1);
- GameSession::current()->respawn(target_sector, target_spawnpoint);
- }
+ Player* player = dynamic_cast<Player*> (&other);
+ if (player) {
+ state = CLOSING;
+ sprite->set_action("closing", 1);
+ GameSession::current()->respawn(target_sector, target_spawnpoint);
+ }
}
break;
case CLOSING:
static const float MESSAGE_TIME=3.5;
SecretAreaTrigger::SecretAreaTrigger(const lisp::Lisp& reader)
- : fade_tilemap("")
+ : fade_tilemap("")
{
reader.get("x", bbox.p1.x);
reader.get("y", bbox.p1.y);
}
SecretAreaTrigger::SecretAreaTrigger(const Rect& area, std::string fade_tilemap)
- : fade_tilemap(fade_tilemap)
+ : fade_tilemap(fade_tilemap)
{
bbox = area;
message_displayed = false;
Sector::current()->get_level()->stats.secrets++;
if (fade_tilemap != "") {
- // fade away tilemaps
- Sector& sector = *Sector::current();
- for(Sector::GameObjects::iterator i = sector.gameobjects.begin(); i != sector.gameobjects.end(); ++i) {
- TileMap* tm = dynamic_cast<TileMap*>(*i);
- if (!tm) continue;
- if (tm->get_name() != fade_tilemap) continue;
- tm->fade(0.0, 1.0);
- }
+ // fade away tilemaps
+ Sector& sector = *Sector::current();
+ for(Sector::GameObjects::iterator i = sector.gameobjects.begin(); i != sector.gameobjects.end(); ++i) {
+ TileMap* tm = dynamic_cast<TileMap*>(*i);
+ if (!tm) continue;
+ if (tm->get_name() != fade_tilemap) continue;
+ tm->fade(0.0, 1.0);
+ }
}
}
}
Switch::Switch(const lisp::Lisp& reader)
- : state(OFF)
+ : state(OFF)
{
if (!reader.get("x", bbox.p1.x)) throw std::runtime_error("no x position set");
if (!reader.get("y", bbox.p1.y)) throw std::runtime_error("no y position set");
break;
case TURN_ON:
if(sprite->animation_done()) {
- std::istringstream stream(script);
- Sector::current()->run_script(stream, "Switch");
+ std::istringstream stream(script);
+ Sector::current()->run_script(stream, "Switch");
- sprite->set_action("on", 1);
- state = ON;
+ sprite->set_action("on", 1);
+ state = ON;
}
break;
case ON:
if(sprite->animation_done()) {
- sprite->set_action("turnoff", 1);
- state = TURN_OFF;
+ sprite->set_action("turnoff", 1);
+ state = TURN_OFF;
}
break;
case TURN_OFF:
if(sprite->animation_done()) {
- sprite->set_action("off");
- state = OFF;
+ sprite->set_action("off");
+ state = OFF;
}
break;
}
switch (state) {
case OFF:
- sprite->set_action("turnon", 1);
+ sprite->set_action("turnon", 1);
sound_manager->play( SWITCH_SOUND );
- state = TURN_ON;
+ state = TURN_ON;
break;
case TURN_ON:
break;
bottom -= center_y;
float vertices[] = {
- left*ca - top*sa + center_x, left*sa + top*ca + center_y,
- right*ca - top*sa + center_x, right*sa + top*ca + center_y,
- right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
- left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
- };
+ left*ca - top*sa + center_x, left*sa + top*ca + center_y,
+ right*ca - top*sa + center_x, right*sa + top*ca + center_y,
+ right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
+ left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
+ };
glVertexPointer(2, GL_FLOAT, 0, vertices);
float uvs[] = {
bottom -= center_y;
float vertices[] = {
- left*ca - top*sa + center_x, left*sa + top*ca + center_y,
- right*ca - top*sa + center_x, right*sa + top*ca + center_y,
- right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
- left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
- };
+ left*ca - top*sa + center_x, left*sa + top*ca + center_y,
+ right*ca - top*sa + center_x, right*sa + top*ca + center_y,
+ right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
+ left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
+ };
glVertexPointer(2, GL_FLOAT, 0, vertices);
float uvs[] = {
if (transform == 0) {
std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
return;
- }
+ }
SDL_Rect *src_rect = surface_data->get_src_rect(effect);
int dstx = (int) request.pos.x * numerator / denominator;
if (transform == 0) {
std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
return;
- }
+ }
int ox, oy;
if (effect == HORIZONTAL_FLIP)
if (transform == 0) {
std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
return;
- }
+ }
SDL_Rect *src_rect = surface_data->get_src_rect(effect);
SDL_Rect dst_rect;
if (transform == 0) {
std::cerr << "Warning: Tried to draw NULL surface, skipped draw" << std::endl;
return;
- }
+ }
int ox, oy;
if (effect == HORIZONTAL_FLIP)
picture_cached = true;
std::string fname = FileSystem::strip_extension(basedir + name)+".jpg";
if (!PHYSFS_exists(fname.c_str())) {
- return 0;
+ return 0;
}
picture = new Surface(fname);
return picture;
Tux::canWalk(int tile_data, Direction dir)
{
return ((tile_data & Tile::WORLDMAP_NORTH && dir == D_NORTH) ||
- (tile_data & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) ||
- (tile_data & Tile::WORLDMAP_EAST && dir == D_EAST) ||
- (tile_data & Tile::WORLDMAP_WEST && dir == D_WEST));
+ (tile_data & Tile::WORLDMAP_SOUTH && dir == D_SOUTH) ||
+ (tile_data & Tile::WORLDMAP_EAST && dir == D_EAST) ||
+ (tile_data & Tile::WORLDMAP_WEST && dir == D_WEST));
}
void
// direction and the apply_action_ are opposites, since they "see"
// directions in a different way
if((direction == D_NORTH && special_tile->apply_action_south) ||
- (direction == D_SOUTH && special_tile->apply_action_north) ||
- (direction == D_WEST && special_tile->apply_action_east) ||
- (direction == D_EAST && special_tile->apply_action_west))
+ (direction == D_SOUTH && special_tile->apply_action_north) ||
+ (direction == D_WEST && special_tile->apply_action_east) ||
+ (direction == D_EAST && special_tile->apply_action_west))
{
if(special_tile->passive_message) {
worldmap->passive_message = special_tile->map_message;
int dirdata = available_directions_at(tux->get_tile_pos());
// first, test for crossroads
if (dirdata == Tile::WORLDMAP_CNSE ||
- dirdata == Tile::WORLDMAP_CNSW ||
- dirdata == Tile::WORLDMAP_CNEW ||
- dirdata == Tile::WORLDMAP_CSEW ||
- dirdata == Tile::WORLDMAP_CNSEW)
+ dirdata == Tile::WORLDMAP_CNSW ||
+ dirdata == Tile::WORLDMAP_CNEW ||
+ dirdata == Tile::WORLDMAP_CSEW ||
+ dirdata == Tile::WORLDMAP_CNSEW)
dir = D_NONE;
else if (dirdata & Tile::WORLDMAP_NORTH
&& tux->back_direction != D_NORTH)
|| main_controller->pressed(Controller::MENU_SELECT)) {
/* some people define UP and JUMP on the same key... */
if(!main_controller->pressed(Controller::UP))
- enter_level = true;
- }
+ enter_level = true;
+ }
if(main_controller->pressed(Controller::PAUSE_MENU))
on_escape_press();
for(LevelTiles::iterator i = levels.begin(); i != levels.end(); ++i) {
LevelTile* level = *i;
- sq_pushstring(vm, level->get_name().c_str(), -1);
- sq_newtable(vm);
+ sq_pushstring(vm, level->get_name().c_str(), -1);
+ sq_newtable(vm);
- store_bool(vm, "solved", level->solved);
- level->statistics.serialize_to_squirrel(vm);
+ store_bool(vm, "solved", level->solved);
+ level->statistics.serialize_to_squirrel(vm);
- sq_createslot(vm, -3);
+ sq_createslot(vm, -3);
}
sq_createslot(vm, -3);