From: Ryan Flegel Date: Mon, 17 May 2004 06:26:41 +0000 (+0000) Subject: - added spikes X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c11b04d0525c1566260b02bacd78fd7faa7be8f1;p=supertux.git - added spikes SVN-Revision: 1230 --- diff --git a/src/badguy.cpp b/src/badguy.cpp index d2fe17db8..7b8db66c9 100644 --- a/src/badguy.cpp +++ b/src/badguy.cpp @@ -719,6 +719,17 @@ BadGuy::action(double frame_ratio) return; } + // Kill us if we landed on spikes + if (dying == DYING_NOT + && (kind != BAD_STALACTITE && kind != BAD_FLAME && kind != BAD_BOMB) + && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y) + || isspike(base.x, base.y + base.height) + || isspike(base.x + base.width, base.y + base.height))) + { + physic.set_velocity_y(3); + kill_me(0); + } + // Once it's on screen, it's activated! if (base.x <= scroll_x + screen->w + OFFSCREEN_DISTANCE) seen = true; @@ -965,6 +976,7 @@ BadGuy::kill_me(int score) physic.enable_gravity(true); /* Gain some points: */ + if (score != 0) World::current()->add_score(base.x, base.y, score * player_status.score_multiplier); diff --git a/src/collision.cpp b/src/collision.cpp index 2466d8c38..5f087566d 100644 --- a/src/collision.cpp +++ b/src/collision.cpp @@ -263,6 +263,12 @@ bool isice(float x, float y) return tile && tile->ice; } +bool isspike(float x, float y) +{ + Tile* tile = gettile(x,y); + return tile && tile->spike; +} + bool isfullbox(float x, float y) { Tile* tile = gettile(x,y); diff --git a/src/collision.h b/src/collision.h index b9e841002..225a771ff 100644 --- a/src/collision.h +++ b/src/collision.h @@ -54,6 +54,7 @@ Tile* gettile(float x, float y); bool issolid(float x, float y); bool isbrick(float x, float y); bool isice(float x, float y); +bool isspike(float x, float y); bool isfullbox(float x, float y); typedef void* (*tiletestfunction)(Tile* tile); diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index f96a72cf7..3a1eeacb6 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -255,6 +255,8 @@ Trampoline::draw() void Trampoline::action(double frame_ratio) { + // TODO: Remove if we're too far off the screen + physic.apply(frame_ratio, base.x, base.y); // Falling diff --git a/src/player.cpp b/src/player.cpp index a00560ec9..93b3cfcce 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -184,6 +184,14 @@ Player::action(double frame_ratio) collision_swept_object_map(&old_base, &base); + if (!invincible_timer.started() + && (isspike(base.x, base.y) || isspike(base.x + base.width, base.y) + || isspike(base.x, base.y + base.height) + || isspike(base.x + base.width, base.y + base.height))) + { + kill(SHRINK); + } + // Don't accelerate Tux if he is running against a wall if (target.x != base.x) { diff --git a/src/tile.cpp b/src/tile.cpp index 116f18529..19a514fb3 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -91,6 +91,7 @@ void TileManager::load_tileset(std::string filename) tile->brick = false; tile->ice = false; tile->water = false; + tile->spike = false; tile->fullbox = false; tile->distro = false; tile->goal = false; @@ -104,6 +105,7 @@ void TileManager::load_tileset(std::string filename) reader.read_bool("brick", &tile->brick); reader.read_bool("ice", &tile->ice); reader.read_bool("water", &tile->water); + reader.read_bool("spike", &tile->spike); reader.read_bool("fullbox", &tile->fullbox); reader.read_bool("distro", &tile->distro); reader.read_bool("goal", &tile->goal); diff --git a/src/tile.h b/src/tile.h index c2c6a35ec..4d4f0082b 100644 --- a/src/tile.h +++ b/src/tile.h @@ -58,12 +58,16 @@ public: /** water */ bool water; + /** spike - kills player on contact */ + bool spike; + /** Bonusbox, content is stored in \a data */ bool fullbox; /** Tile is a distro/coin */ bool distro; + /** the level should be finished when touching a goaltile. * if data is 0 then the endsequence should be triggered, if data is 1 * then we can finish the level instantly.