)
(init-script "
import(\"levels/world2/default.nut\");
- import(\"script/default.nut\");
+ import(\"scripts/default.nut\");
level2_init();
")
(secretarea (x 673.0)
//FIXME: Does is_offscreen() work right here?
if (!is_offscreen()) {
if (badguy == "snowball")
- Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir));
+ Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir, false));
else if (badguy == "bouncingsnowball")
Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir));
else if (badguy == "mrbomb")
else if (badguy == "mriceblock")
Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir, false));
else if (badguy == "snowsnail")
- Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir));
+ Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir, false));
else if (badguy == "mrrocket") {
Sector::current()->add_object(new MrRocket(get_pos().x+(dir == LEFT ? -32 : 32), get_pos().y, dir));}
else if (badguy == "poisonivy")
- Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir));
+ Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir, false));
else if (badguy == "skullyhop")
Sector::current()->add_object(new SkullyHop(get_pos().x, get_pos().y+44, dir));
else if (badguy == "random")
{
switch (rand()%7)
{
- case 0: Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir)); break;
+ case 0: Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir, false)); break;
case 1: Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir)); break;
case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir, false)); break;
case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir, false)); break;
- case 4: Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir)); break;
- case 5: Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir)); break;
+ case 4: Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir, false)); break;
+ case 5: Sector::current()->add_object(new SnowSnail(get_pos().x, get_pos().y+32, dir, false)); break;
case 6: Sector::current()->add_object(new SkullyHop(get_pos().x, get_pos().y+44, dir)); break;
}
}
Rect leaf1_bbox = Rect(pos.x-32-1, pos.y-23+1, pos.x-32-1+32, pos.y-23+1+32);
if (Sector::current()->is_free_space(leaf1_bbox)) {
- PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1.x, leaf1_bbox.p1.y, LEFT);
+ PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1.x, leaf1_bbox.p1.y, LEFT, true);
Sector::current()->add_object(leaf1);
}
Rect leaf2_bbox = Rect(pos.x+42+1, pos.y-23+1, pos.x+32+1+32, pos.y-23+1+32);
if (Sector::current()->is_free_space(leaf2_bbox)) {
- PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1.x, leaf2_bbox.p1.y, RIGHT);
+ PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1.x, leaf2_bbox.p1.y, RIGHT, true);
Sector::current()->add_object(leaf2);
}
}
case SHOOTING:
{
- Sector::current()->add_object(new SnowSnail(get_pos().x - 64, get_pos().y, LEFT));
- Sector::current()->add_object(new SnowSnail(get_pos().x + 64, get_pos().y, RIGHT));
+ Sector::current()->add_object(new SnowSnail(get_pos().x - 64, get_pos().y, LEFT, true));
+ Sector::current()->add_object(new SnowSnail(get_pos().x + 64, get_pos().y, RIGHT, true));
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
action = WALKING;
{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
+ stay_on_platform = false;
+ reader.get("stay-on-platform", stay_on_platform);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/poison_ivy/poison_ivy.sprite");
set_direction = false;
}
-PoisonIvy::PoisonIvy(float pos_x, float pos_y, Direction d)
+PoisonIvy::PoisonIvy(float pos_x, float pos_y, Direction d, bool stay_on_plat = false)
{
start_position.x = pos_x;
start_position.y = pos_y;
+ stay_on_platform = stay_on_plat;
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/poison_ivy/poison_ivy.sprite");
set_direction = true;
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
+ if (stay_on_platform) writer.write_bool("stay-on-platform", true);
writer.end_list("poisonivy");
}
sprite->set_action(dir == LEFT ? "left" : "right");
}
+void
+PoisonIvy::active_update(float elapsed_time)
+{
+ if (stay_on_platform && may_fall_off_platform())
+ {
+ dir = (dir == LEFT ? RIGHT : LEFT);
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+}
+
bool
PoisonIvy::collision_squished(Player& player)
{
{
public:
PoisonIvy(const lisp::Lisp& reader);
- PoisonIvy(float pos_x, float pos_y, Direction d);
+ PoisonIvy(float pos_x, float pos_y, Direction d, bool stay_on_plat);
void activate();
void write(lisp::Writer& writer);
+ void active_update(float elapsed_time);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
protected:
bool collision_squished(Player& player);
bool set_direction;
+ bool stay_on_platform;
Direction initial_direction;
};
//This is for a hidden badguy :)
fluffy = false;
reader.get("fluffy",fluffy);
+ stay_on_platform = false;
+ reader.get("stay-on-platform", stay_on_platform);
bbox.set_size(31.8, 31.8);
if (fluffy) sprite = sprite_manager->create("images/creatures/fluffy/fluffy.sprite");
else sprite = sprite_manager->create("images/creatures/snowball/snowball.sprite");
set_direction = false;
}
-SnowBall::SnowBall(float pos_x, float pos_y, Direction d)
+SnowBall::SnowBall(float pos_x, float pos_y, Direction d, bool stay_on_plat = false)
{
start_position.x = pos_x;
start_position.y = pos_y;
+ stay_on_platform = stay_on_plat;
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/snowball/snowball.sprite");
set_direction = true;
writer.write_bool("fluffy", true);
}
+ if (stay_on_platform)
+ writer.write_bool("stay-on-platform", true);
+
writer.end_list("snowball");
}
sprite->set_action(dir == LEFT ? "left" : "right");
}
+void
+SnowBall::active_update(float elapsed_time)
+{
+ if (stay_on_platform && may_fall_off_platform())
+ {
+ dir = (dir == LEFT ? RIGHT : LEFT);
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+}
+
bool
SnowBall::collision_squished(Player& player)
{
{
public:
SnowBall(const lisp::Lisp& reader);
- SnowBall(float pos_x, float pos_y, Direction d);
+ SnowBall(float pos_x, float pos_y, Direction d, bool stay_on_plat);
void activate();
void write(lisp::Writer& writer);
+ void active_update(float elapsed_time);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit);
protected:
bool collision_squished(Player& player);
bool set_direction;
+ bool stay_on_platform;
Direction initial_direction;
bool fluffy;
};
{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
+ stay_on_platform = false;
+ reader.get("stay-on-platform", stay_on_platform);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/snowsnail/snowsnail.sprite");
set_direction = false;
}
-SnowSnail::SnowSnail(float pos_x, float pos_y, Direction d)
+SnowSnail::SnowSnail(float pos_x, float pos_y, Direction d, bool stay_on_plat = false)
: ice_state(ICESTATE_NORMAL), squishcount(0)
{
start_position.x = pos_x;
start_position.y = pos_y;
+ stay_on_platform = stay_on_plat;
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/snowsnail/snowsnail.sprite");
set_direction = true;
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
+ if (stay_on_platform) writer.write_bool("stay-on-platform", true);
writer.end_list("snowsnail");
}
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
}
+ if(ice_state == ICESTATE_NORMAL && stay_on_platform
+ && may_fall_off_platform())
+ {
+ dir = (dir == LEFT ? RIGHT : LEFT);
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
BadGuy::active_update(elapsed_time);
}
{
public:
SnowSnail(const lisp::Lisp& reader);
- SnowSnail(float pos_x, float pos_y, Direction d);
+ SnowSnail(float pos_x, float pos_y, Direction d, bool stay_on_plat);
void activate();
void write(lisp::Writer& writer);
Timer flat_timer;
int squishcount;
bool set_direction;
+ bool stay_on_platform;
Direction initial_direction;
};
{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
+ stay_on_platform = false;
+ reader.get("stay-on-platform", stay_on_platform);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/spiky/spiky.sprite");
}
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
+ if (stay_on_platform) writer.write_bool("stay-on-platform", true);
writer.end_list("spiky");
}
sprite->set_action(dir == LEFT ? "left" : "right");
}
+void
+Spiky::active_update(float elapsed_time)
+{
+ if (stay_on_platform && may_fall_off_platform())
+ {
+ dir = (dir == LEFT ? RIGHT : LEFT);
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
+}
+
HitResponse
Spiky::collision_solid(GameObject& , const CollisionHit& hit)
{
void activate();
void write(lisp::Writer& writer);
+ void active_update(float elapsed_time);
HitResponse collision_solid(GameObject& other, const CollisionHit& hit);
HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit);
+private:
+ bool stay_on_platform;
};
#endif
{
reader.get("x", start_position.x);
reader.get("y", start_position.y);
+ stay_on_platform = false;
+ reader.get("stay-on-platform", stay_on_platform);
bbox.set_size(31.8, 31.8);
sprite = sprite_manager->create("images/creatures/sspiky/sspiky.sprite");
state = SSPIKY_SLEEPING;
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
+ if (stay_on_platform) writer.write_bool("stay-on-platform", true);
writer.end_list("sspiky");
}
sprite->set_action(dir == LEFT ? "sleeping-left" : "sleeping-right");
}
+
+
HitResponse
SSpiky::collision_solid(GameObject& , const CollisionHit& hit)
{
}
}
+ if (state == SSPIKY_WALKING && stay_on_platform && may_fall_off_platform())
+ {
+ dir = (dir == LEFT ? RIGHT : LEFT);
+ sprite->set_action(dir == LEFT ? "left" : "right");
+ physic.set_velocity_x(-physic.get_velocity_x());
+ }
}
IMPLEMENT_FACTORY(SSpiky, "sspiky")
SSPIKY_WALKING
};
SSpikyState state;
-
+private:
+ bool stay_on_platform;
};
#endif
--- /dev/null
+// $Id: infoblock.cpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Ondrej Hosek <ondra.hosek@gmail.com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <config.h>
+
+#include "falling_coin.hpp"
+#include "player.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "resources.hpp"
+#include "main.hpp"
+
+FallingCoin::FallingCoin(const Vector& start_position, const int vel_x)
+{
+ pos = start_position;
+ sprite = sprite_manager->create("images/objects/coin/coin.sprite");
+ physic.set_velocity_y(800);
+ physic.set_velocity_x(vel_x);
+}
+
+FallingCoin::~FallingCoin()
+{
+ delete sprite;
+}
+
+void
+FallingCoin::draw(DrawingContext& context)
+{
+ sprite->draw(context, pos, LAYER_OBJECTS + 5);
+}
+
+void
+FallingCoin::update(float elapsed_time)
+{
+ pos += physic.get_movement(elapsed_time);
+ if (pos.y > SCREEN_HEIGHT)
+ remove_me();
+}
--- /dev/null
+// $Id: infoblock.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $
+//
+// SuperTux
+// Copyright (C) 2006 Ondrej Hosek <ondra.hosek@gmail.com>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef __FALLING_COIN_H__
+#define __FALLING_COIN_H__
+
+#include "game_object.hpp"
+#include "math/vector.hpp"
+#include "sprite/sprite.hpp"
+#include "video/drawing_context.hpp"
+#include "physic.hpp"
+
+class FallingCoin : public GameObject
+{
+public:
+ FallingCoin(const Vector& start_position, const int x_vel);
+ ~FallingCoin();
+
+ void draw(DrawingContext& context);
+ void update(float elapsed_time);
+private:
+ Vector pos;
+ Sprite* sprite;
+ Physic physic;
+};
+
+#endif
#include "badguy/badguy.hpp"
#include "player_status.hpp"
#include "log.hpp"
+#include "falling_coin.hpp"
static const int TILES_FOR_BUTTJUMP = 3;
static const float SHOOTING_TIME = .150;
feet->draw(context, pos, layer-2);
}
-FallingCoin::FallingCoin(const Vector& start_position, const int vel_x)
-{
- pos = start_position;
- sprite = sprite_manager->create("images/objects/coin/coin.sprite");
- physic.set_velocity_y(800);
- physic.set_velocity_x(vel_x);
-}
-
-FallingCoin::~FallingCoin()
-{
- delete sprite;
-}
-
-void
-FallingCoin::draw(DrawingContext& context)
-{
- sprite->draw(context, pos, LAYER_OBJECTS + 5);
-}
-
-void
-FallingCoin::update(float elapsed_time)
-{
- pos += physic.get_movement(elapsed_time);
- if (pos.y > SCREEN_HEIGHT)
- remove_me();
-}
-
Player::Player(PlayerStatus* _player_status)
: player_status(_player_status), grabbed_object(0)
{
extern TuxBodyParts* fire_tux;
extern TuxBodyParts* ice_tux;
-class FallingCoin : public GameObject
-{
-public:
- FallingCoin(const Vector& start_position, const int x_vel);
- ~FallingCoin();
-
- void draw(DrawingContext& context);
- void update(float elapsed_time);
-private:
- Vector pos;
- Sprite* sprite;
- Physic physic;
-};
-
class Player : public MovingObject, public Scripting::Player, public ScriptInterface
{
public:
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
+#include <stddef.h>
#include <physfs.h>
#include "level.hpp"
#include "sprite/sprite_manager.hpp"