From 6ae2d154b976957d8e209bb991672b0c12c503c7 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 29 Dec 2005 23:52:29 +0000 Subject: [PATCH] more adjustments to collision detection, tux is correctly placed above badguys again and doesn't die by jumping on mriceblocks and yeti SVN-Revision: 2967 --- data/images/tiles.strf | 16 +-- data/levels/test/script.stl | 2 +- data/levels/world2/level2.stl | 9 +- src/badguy/badguy.cpp | 23 +++-- src/badguy/badguy.hpp | 3 + src/badguy/stalactite.cpp | 1 + src/collision_grid.cpp | 4 +- src/collision_hit.hpp | 7 -- src/game_object.hpp | 2 +- src/moving_object.hpp | 7 ++ src/object/player.cpp | 24 ++--- src/object/player.hpp | 1 + src/object/powerup.cpp | 2 + src/sector.cpp | 230 +++++++++++++++++++++++------------------- src/sector.hpp | 8 +- src/textscroller.cpp | 2 + src/tile.cpp | 4 +- src/tile.hpp | 33 +++--- tools/tilemanager/Tile.cs | 10 +- 19 files changed, 216 insertions(+), 172 deletions(-) diff --git a/data/images/tiles.strf b/data/images/tiles.strf index a6ed16f9e..b7ecb3fce 100644 --- a/data/images/tiles.strf +++ b/data/images/tiles.strf @@ -1264,7 +1264,7 @@ "tiles/lava/lava1-4.png" ) (water #t) - (spike #t) + (hurts #t) (anim-fps 10) ) (tile @@ -1276,7 +1276,7 @@ "tiles/lava/lava2-4.png" ) (water #t) - (spike #t) + (hurts #t) (anim-fps 10) ) (tile @@ -1880,28 +1880,28 @@ (images "creatures/spike/up.png" ) - (spike #t) + (hurts #t) ) (tile (id 296) (images "creatures/spike/right.png" ) - (spike #t) + (hurts #t) ) (tile (id 297) (images "creatures/spike/down.png" ) - (spike #t) + (hurts #t) ) (tile (id 298) (images "creatures/spike/left.png" ) - (spike #t) + (hurts #t) ) (tile (id 301) @@ -5357,7 +5357,7 @@ "tiles/water/electrified-1.png" ) (anim-fps 10) - (spike #t) + (hurts #t) (water #t) ) (tile @@ -5367,7 +5367,7 @@ "tiles/water/electrified_waves-1.png" ) (anim-fps 10) - (spike #t) + (hurts #t) (water #t) ) (tile diff --git a/data/levels/test/script.stl b/data/levels/test/script.stl index 0c79c343b..9e2267b97 100644 --- a/data/levels/test/script.stl +++ b/data/levels/test/script.stl @@ -120,7 +120,7 @@ (name "TUX") (x 160) (y 448) - (sprite "images/creatues/yeti/yeti.sprite") + (sprite "images/creatures/yeti/yeti.sprite") ) (scriptedobject (name "PENNY") diff --git a/data/levels/world2/level2.stl b/data/levels/world2/level2.stl index 6f91f86c3..64bd0f0e8 100644 --- a/data/levels/world2/level2.stl +++ b/data/levels/world2/level2.stl @@ -195,10 +195,11 @@ (width 24.0) (height 19.0) (message (_ "Drink me"))) - (powerup (x 3168) (y 416) - (sprite "eat-me") - (script "levelflip();") - ) + + (powerup (x 3168) (y 416) + (sprite "eat-me") + (script "levelflip();") + ) (bonusblock (x 672) (y 1056) (contents "custom") (powerup diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index 91b4bc9e9..36fe717db 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -32,6 +32,7 @@ static const float Y_OFFSCREEN_DISTANCE = 1200; BadGuy::BadGuy() : countMe(true), sprite(0), dir(LEFT), state(STATE_INIT) { + set_group(COLGROUP_DISABLED); } BadGuy::~BadGuy() @@ -116,6 +117,13 @@ BadGuy::inactive_update(float ) { } +void +BadGuy::collision_tile(uint32_t tile_attributes) +{ + if(tile_attributes & Tile::HURTS) + kill_fall(); +} + HitResponse BadGuy::collision(GameObject& other, const CollisionHit& hit) { @@ -124,16 +132,8 @@ BadGuy::collision(GameObject& other, const CollisionHit& hit) case STATE_INACTIVE: return ABORT_MOVE; case STATE_ACTIVE: { - TileMap* tilemap = dynamic_cast (&other); - if(tilemap != 0) { - const TilemapCollisionHit* thit - = static_cast (&hit); - if(thit->tileflags & Tile::SPIKE) - kill_fall(); - if(thit->tileflags & Tile::SOLID) - return collision_solid(other, hit); - return FORCE_MOVE; - } + if(other.get_flags() & FLAG_SOLID) + return collision_solid(other, hit); BadGuy* badguy = dynamic_cast (&other); if(badguy && badguy->state == STATE_ACTIVE) @@ -172,7 +172,7 @@ BadGuy::collision_player(Player& player, const CollisionHit& ) // hit from above? if(player.get_movement().y - get_movement().y > 0 && player.get_bbox().p2.y < (get_bbox().p1.y + get_bbox().p2.y) / 2) { - // if it's not is it possible to squish us, then this will hurt + // if it's not possible to squish us, then this will hurt if(!collision_squished(player)) player.kill(Player::SHRINK); @@ -202,6 +202,7 @@ BadGuy::kill_squished(Player& player) physic.set_velocity_x(0); physic.set_velocity_y(0); set_state(STATE_SQUISHED); + set_group(COLGROUP_MOVING_ONLY_STATIC); global_stats.add_points(BADGUYS_KILLED_STAT, 1); player.bounce(*this); } diff --git a/src/badguy/badguy.hpp b/src/badguy/badguy.hpp index 93731772c..775478ae6 100644 --- a/src/badguy/badguy.hpp +++ b/src/badguy/badguy.hpp @@ -61,6 +61,9 @@ public: virtual HitResponse collision(GameObject& other, const CollisionHit& hit); + /** Called when a collision with tile with special attributes occured */ + virtual void collision_tile(uint32_t tile_attributes); + /** Set the badguy to kill/falling state, which makes him falling of the * screen (his sprite is turned upside-down) */ diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index 4b697f0e7..03b6742c4 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -76,6 +76,7 @@ Stalactite::collision_solid(GameObject& , const CollisionHit& hit) if(fabsf(hit.normal.y) > .5) { // hit floor or roof? state = STALACTITE_SQUISHED; + set_group(COLGROUP_MOVING_ONLY_STATIC); physic.set_velocity_y(0); sprite->set_action("squished"); if(!timer.started()) diff --git a/src/collision_grid.cpp b/src/collision_grid.cpp index 311811a8e..e7241cc09 100644 --- a/src/collision_grid.cpp +++ b/src/collision_grid.cpp @@ -167,7 +167,8 @@ void CollisionGrid::check_collisions() { std::vector moved_objects; - + +#if 0 CollisionGridIterator iter(*this, Sector::current()->get_active_region()); while(ObjectWrapper* wrapper = iter.next_wrapper()) { MovingObject* object = wrapper->object; @@ -191,6 +192,7 @@ CollisionGrid::check_collisions() moved_objects.push_back(wrapper); } } +#endif for(std::vector::iterator i = moved_objects.begin(); i != moved_objects.end(); ++i) { diff --git a/src/collision_hit.hpp b/src/collision_hit.hpp index e3ae28087..204460348 100644 --- a/src/collision_hit.hpp +++ b/src/collision_hit.hpp @@ -50,12 +50,5 @@ public: Vector normal; }; -class TilemapCollisionHit : public CollisionHit -{ -public: - /// the flags of all tiles tux collided with - int tileflags; -}; - #endif diff --git a/src/game_object.hpp b/src/game_object.hpp index 547353be5..6e0c4eed4 100644 --- a/src/game_object.hpp +++ b/src/game_object.hpp @@ -78,7 +78,7 @@ public: // flags enum { /// the tile so you can stand on it - FLAG_SOLID = 0x0001 + FLAG_SOLID = 0x0001, }; int get_flags() const diff --git a/src/moving_object.hpp b/src/moving_object.hpp index 7117777a5..0969cb0e9 100644 --- a/src/moving_object.hpp +++ b/src/moving_object.hpp @@ -30,6 +30,8 @@ class CollisionGrid; enum CollisionGroup { COLGROUP_DISABLED, COLGROUP_MOVING, + // moving object but don't collide against other moving objects + COLGROUP_MOVING_ONLY_STATIC, COLGROUP_STATIC, COLGROUP_MOVINGSTATIC, COLGROUP_TOUCHABLE, @@ -51,6 +53,11 @@ public: */ virtual HitResponse collision(GameObject& other, const CollisionHit& hit) = 0; + /** called when tiles with special attributes have been touched */ + virtual void collision_tile(uint32_t tile_attributes) + { + (void) tile_attributes; + } const Vector& get_pos() const { diff --git a/src/object/player.cpp b/src/object/player.cpp index 2adc8bfaf..9a388a92e 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -655,6 +655,13 @@ Player::draw(DrawingContext& context) } } +void +Player::collision_tile(uint32_t tile_attributes) +{ + if(tile_attributes & Tile::HURTS) + kill(SHRINK); +} + HitResponse Player::collision(GameObject& other, const CollisionHit& hit) { @@ -666,19 +673,8 @@ Player::collision(GameObject& other, const CollisionHit& hit) } if(other.get_flags() & FLAG_SOLID) { - TileMap* tilemap = dynamic_cast (&other); - if(tilemap) { - const TilemapCollisionHit* thit = - static_cast (&hit); - if(thit->tileflags & Tile::SPIKE) - kill(SHRINK); - - if(! (thit->tileflags & Tile::SOLID)) - return FORCE_MOVE; - } - if(hit.normal.y < 0) { // landed on floor? - if (physic.get_velocity_y() < 0) + if(physic.get_velocity_y() < 0) physic.set_velocity_y(0); on_ground_flag = true; } else if(hit.normal.y > 0) { // bumped against the roof @@ -696,9 +692,11 @@ Player::collision(GameObject& other, const CollisionHit& hit) if(trigger) { if(controller->pressed(Controller::UP)) trigger->event(*this, TriggerBase::EVENT_ACTIVATE); + + return FORCE_MOVE; } - return FORCE_MOVE; + return CONTINUE; } void diff --git a/src/object/player.hpp b/src/object/player.hpp index 1ec639749..253364d72 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -124,6 +124,7 @@ public: virtual void update(float elapsed_time); virtual void draw(DrawingContext& context); virtual HitResponse collision(GameObject& other, const CollisionHit& hit); + virtual void collision_tile(uint32_t tile_attributes); void make_invincible(); bool is_invincible() const diff --git a/src/object/powerup.cpp b/src/object/powerup.cpp index c7df31590..ad0f3df34 100644 --- a/src/object/powerup.cpp +++ b/src/object/powerup.cpp @@ -57,6 +57,8 @@ PowerUp::collision(GameObject& other, const CollisionHit& hit) if(fabsf(hit.normal.y) > .5) { // roof or ground physic.set_velocity_y(0); } else { // bumped left or right + printf("Normal: %f %f\n", hit.normal.x, hit.normal.y); + printf("LRbounce, new speed. %f\n", physic.get_velocity_x()); physic.set_velocity_x(-physic.get_velocity_x()); } diff --git a/src/sector.cpp b/src/sector.cpp index d828a41c4..ceb80a3d6 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "sector.hpp" #include "player_status.hpp" @@ -63,8 +64,6 @@ #include "scripting/scripted_object.hpp" #include "scripting/text.hpp" -//#define USE_GRID - Sector* Sector::_current = 0; Sector::Sector() @@ -559,15 +558,6 @@ Sector::draw(DrawingContext& context) context.push_transform(); context.set_translation(camera->get_translation()); -#if 0 - CollisionGridIterator iter(*grid, get_active_region()); - while(MovingObject* object = iter.next()) { - if(!object->is_valid()) - continue; - - object->draw(context); - } -#else for(GameObjects::iterator i = gameobjects.begin(); i != gameobjects.end(); ++i) { GameObject* object = *i; @@ -576,7 +566,6 @@ Sector::draw(DrawingContext& context) object->draw(context); } -#endif context.pop_transform(); } @@ -584,45 +573,36 @@ Sector::draw(DrawingContext& context) static const float DELTA = .001; void -Sector::collision_tilemap(MovingObject* object, int depth) +Sector::collision_tilemap(MovingObject* object, CollisionHit& hit) const { - if(depth >= 4) { -#ifdef DEBUG - std::cout << "Max collision depth reached.\n"; -#endif - object->movement = Vector(0, 0); - return; - } - // calculate rectangle where the object will move float x1, x2; if(object->get_movement().x >= 0) { - x1 = object->get_pos().x; + x1 = object->get_bbox().p1.x; x2 = object->get_bbox().p2.x + object->get_movement().x; } else { - x1 = object->get_pos().x + object->get_movement().x; + x1 = object->get_bbox().p1.x + object->get_movement().x; x2 = object->get_bbox().p2.x; } float y1, y2; if(object->get_movement().y >= 0) { - y1 = object->get_pos().y; + y1 = object->get_bbox().p1.y; y2 = object->get_bbox().p2.y + object->get_movement().y; } else { - y1 = object->get_pos().y + object->get_movement().y; + y1 = object->get_bbox().p1.y + object->get_movement().y; y2 = object->get_bbox().p2.y; } // test with all tiles in this rectangle - int starttilex = int(x1-1) / 32; - int starttiley = int(y1-1) / 32; - int max_x = int(x2+1); + int starttilex = int(x1) / 32; + int starttiley = int(y1) / 32; + int max_x = int(x2); + // the +1 is somehow needed to make characters stay on the floor int max_y = int(y2+1); - TilemapCollisionHit temphit, hit; + CollisionHit temphit; Rect dest = object->get_bbox(); dest.move(object->movement); - hit.tileflags = 0; - hit.time = -1; // represents an invalid value 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); @@ -646,9 +626,7 @@ Sector::collision_tilemap(MovingObject* object, int depth) if(Collision::rectangle_aatriangle(temphit, dest, object->movement, triangle)) { - hit.tileflags |= tile->getAttributes(); if(temphit.time > hit.time && (tile->getAttributes() & Tile::SOLID)) { - temphit.tileflags = hit.tileflags; hit = temphit; } } @@ -656,36 +634,63 @@ Sector::collision_tilemap(MovingObject* object, int depth) Rect rect(x*32, y*32, (x+1)*32, (y+1)*32); if(Collision::rectangle_rectangle(temphit, dest, object->movement, rect)) { - hit.tileflags |= tile->getAttributes(); if(temphit.time > hit.time && (tile->getAttributes() & Tile::SOLID)) { - temphit.tileflags = hit.tileflags; hit = temphit; } } } } } +} - // did we collide at all? - if(hit.tileflags == 0) - return; - - // call collision function - HitResponse response = object->collision(*solids, hit); - if(response == ABORT_MOVE) { - object->movement = Vector(0, 0); - return; +uint32_t +Sector::collision_tile_attributes(MovingObject* object) const +{ + /** XXX This function doesn't work correctly as it will check all tiles + * in the bounding box of the object movement, this might include tiles + * that have actually never been touched by the object + * (though this only occures for very fast objects...) + */ + + // calculate rectangle where the object will move + float x1, x2; + if(object->get_movement().x >= 0) { + x1 = object->get_bbox().p1.x; + x2 = object->get_bbox().p2.x + object->get_movement().x; + } else { + x1 = object->get_bbox().p1.x + object->get_movement().x; + x2 = object->get_bbox().p2.x; + } + float y1, y2; + if(object->get_movement().y >= 0) { + y1 = object->get_bbox().p1.y; + y2 = object->get_bbox().p2.y + object->get_movement().y; + } else { + y1 = object->get_bbox().p1.y + object->get_movement().y; + y2 = object->get_bbox().p2.y; } - if(response == FORCE_MOVE) { - return; + + // test with all tiles in this rectangle + int starttilex = int(x1-1) / 32; + int starttiley = int(y1-1) / 32; + int max_x = int(x2+1); + int max_y = int(y2+1); + + uint32_t result = 0; + 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(); + } } - // move out of collision and try again - object->movement += hit.normal * (hit.depth + DELTA); - collision_tilemap(object, depth+1); + + return result; } void -Sector::collision_object(MovingObject* object1, MovingObject* object2) +Sector::collision_object(MovingObject* object1, MovingObject* object2) const { CollisionHit hit; Rect dest1 = object1->get_bbox(); @@ -719,33 +724,90 @@ Sector::collision_object(MovingObject* object1, MovingObject* object2) void Sector::handle_collisions() { -#ifdef USE_GRID - grid->check_collisions(); -#else // part1: COLGROUP_MOVING vs COLGROUP_STATIC and tilemap + // we do this up to 4 times and have to sort all results for the smallest + // one before we can continue here for(MovingObjects::iterator i = moving_objects.begin(); i != moving_objects.end(); ++i) { - MovingObject* movingobject = *i; - if(movingobject->get_group() != COLGROUP_MOVING - || !movingobject->is_valid()) + MovingObject* moving_object = *i; + if((moving_object->get_group() != COLGROUP_MOVING + && moving_object->get_group() != COLGROUP_MOVING_ONLY_STATIC) + || !moving_object->is_valid()) continue; - // collision with tilemap - collision_tilemap(movingobject, 0); + // up to 4 tries + for(int t = 0; t < 4; ++t) { + CollisionHit hit; + hit.time = -1; + MovingObject* collided_with = NULL; + + // collision with tilemap + collision_tilemap(moving_object, hit); + + // collision with other objects + Rect dest1 = moving_object->get_bbox(); + dest1.move(moving_object->get_movement()); + CollisionHit temphit; + + for(MovingObjects::iterator i2 = moving_objects.begin(); + i2 != moving_objects.end(); ++i2) { + MovingObject* moving_object_2 = *i2; + if(moving_object_2->get_group() != COLGROUP_STATIC + || !moving_object_2->is_valid()) + continue; + + Rect dest2 = moving_object_2->get_bbox(); + dest2.move(moving_object_2->get_movement()); + Vector movement + = moving_object->get_movement() - moving_object_2->get_movement(); + if(Collision::rectangle_rectangle(temphit, dest1, movement, dest2) + && temphit.time > hit.time) { + hit = temphit; + collided_with = moving_object_2; + } + } + + if(hit.time < 0) + break; + + // call collision callbacks + HitResponse response; + if(collided_with != 0) { + response = moving_object->collision(*collided_with, hit); + hit.normal *= -1; + collided_with->collision(*moving_object, hit); + } else { + response = moving_object->collision(*solids, hit); + hit.normal *= -1; + } - // collision with other objects - for(MovingObjects::iterator i2 = i+1; - i2 != moving_objects.end(); ++i2) { - MovingObject* movingobject2 = *i2; - if(movingobject2->get_group() != COLGROUP_STATIC - || !movingobject2->is_valid()) - continue; + if(response == CONTINUE) { + moving_object->movement += -hit.normal * (hit.depth + DELTA); + } else if(response == ABORT_MOVE) { + moving_object->movement = Vector(0, 0); + break; + } else { // force move + break; + } + } + } - collision_object(movingobject, movingobject2); + // part2: COLGROUP_MOVING vs tile attributes + for(MovingObjects::iterator i = moving_objects.begin(); + i != moving_objects.end(); ++i) { + MovingObject* moving_object = *i; + if((moving_object->get_group() != COLGROUP_MOVING + && moving_object->get_group() != COLGROUP_MOVING_ONLY_STATIC) + || !moving_object->is_valid()) + continue; + + uint32_t tile_attributes = collision_tile_attributes(moving_object); + if(tile_attributes > Tile::FIRST_INTERESTING_FLAG) { + moving_object->collision_tile(tile_attributes); } } - // part2: COLGROUP_MOVING vs COLGROUP_TOUCHABLE + // part2.5: COLGROUP_MOVING vs COLGROUP_TOUCHABLE for(MovingObjects::iterator i = moving_objects.begin(); i != moving_objects.end(); ++i) { MovingObject* moving_object = *i; @@ -792,40 +854,6 @@ Sector::handle_collisions() moving_object->bbox.move(moving_object->get_movement()); moving_object->movement = Vector(0, 0); } - -#if 0 - for(MovingObjects::iterator i = moving_objects.begin(); - i != moving_objects.end(); ++i) { - MovingObject* movingobject = *i; - if(!movingobject->is_valid()) - continue; - if(movingobject->get_flags() & GameObject::FLAG_NO_COLLDET) { - movingobject->bbox.move(movingobject->movement); - movingobject->movement = Vector(0, 0); - continue; - } - - // collision with tilemap - if(! (movingobject->movement == Vector(0, 0))) - collision_tilemap(movingobject, 0); - - // collision with other objects - for(MovingObjects::iterator i2 = i+1; - i2 != moving_objects.end(); ++i2) { - MovingObject* movingobject2 = *i2; - if(!movingobject2->is_valid() - || movingobject2->get_flags() & GameObject::FLAG_NO_COLLDET) - continue; - - collision_object(movingobject, movingobject2); - } - - movingobject->bbox.move(movingobject->get_movement()); - movingobject->movement = Vector(0, 0); - } -#endif - -#endif } bool diff --git a/src/sector.hpp b/src/sector.hpp index 265fccff2..6d9e2f47e 100644 --- a/src/sector.hpp +++ b/src/sector.hpp @@ -42,6 +42,7 @@ class CollisionGrid; class ScriptInterpreter; class SpawnPoint; class MovingObject; +class CollisionHit; enum MusicType { LEVEL_MUSIC, @@ -102,12 +103,11 @@ public: /** Get total number of badguys */ int get_total_badguys(); - // make this private again soon - void collision_tilemap(MovingObject* object, int depth); + void collision_tilemap(MovingObject* object, CollisionHit& hit) const; + uint32_t collision_tile_attributes(MovingObject* object) const; private: - void collision_object(MovingObject* object1, MovingObject* object2); - + void collision_object(MovingObject* object1, MovingObject* object2) const; GameObject* parse_object(const std::string& name, const lisp::Lisp& lisp); static Sector* _current; diff --git a/src/textscroller.cpp b/src/textscroller.cpp index 1cb243bd9..e6577bb7d 100644 --- a/src/textscroller.cpp +++ b/src/textscroller.cpp @@ -250,6 +250,8 @@ InfoBox::~InfoBox() for(std::map::iterator i = images.begin(); i != images.end(); ++i) delete i->second; + delete arrow_scrollup; + delete arrow_scrolldown; } void diff --git a/src/tile.cpp b/src/tile.cpp index 68e271e12..0712dcd61 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -69,8 +69,8 @@ Tile::parse(const lisp::Lisp& reader) attributes |= ICE; if(reader.get("water", value) && value) attributes |= WATER; - if(reader.get("spike", value) && value) - attributes |= SPIKE; + if(reader.get("hurts", value) && value) + attributes |= HURTS; if(reader.get("fullbox", value) && value) attributes |= FULLBOX; if(reader.get("coin", value) && value) diff --git a/src/tile.hpp b/src/tile.hpp index 319702194..88ed0551f 100644 --- a/src/tile.hpp +++ b/src/tile.hpp @@ -22,6 +22,7 @@ #include #include +#include #include "video/surface.hpp" #include "math/rect.hpp" #include "lisp/lisp.hpp" @@ -42,23 +43,27 @@ public: UNISOLID = 0x0002, /** a brick that can be destroyed by jumping under it */ BRICK = 0x0004, - /** an ice brick that makes tux sliding more than usual */ - ICE = 0x0008, - /** a water tile in which tux starts to swim */ - WATER = 0x0010, - /** a tile that hurts the player if he touches it */ - SPIKE = 0x0020, - /** Bonusbox, content is stored in \a data */ - FULLBOX = 0x0040, - /** Tile is a coin */ - COIN = 0x0080, /** 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. */ - GOAL = 0x0100, + GOAL = 0x0008, /** slope tile */ - SLOPE = 0x0200, + SLOPE = 0x0010, + /** Bonusbox, content is stored in \a data */ + FULLBOX = 0x0020, + /** Tile is a coin */ + COIN = 0x0040, + + /* interesting flags (the following are passed to gameobjects) */ + FIRST_INTERESTING_FLAG = 0x0100, + + /** an ice brick that makes tux sliding more than usual */ + ICE = 0x0100, + /** a water tile in which tux starts to swim */ + WATER = 0x0200, + /** a tile that hurts the player if he touches it */ + HURTS = 0x0400, }; /// worldmap flags @@ -90,7 +95,7 @@ private: Surface* editor_image; /** tile attributes */ - Uint32 attributes; + uint32_t attributes; /** General purpose data attached to a tile (content of a box, type of coin)*/ int data; @@ -108,7 +113,7 @@ public: unsigned int getID() const { return id; } - Uint32 getAttributes() const + uint32_t getAttributes() const { return attributes; } int getData() const diff --git a/tools/tilemanager/Tile.cs b/tools/tilemanager/Tile.cs index 9c52b6089..1fc8401b0 100644 --- a/tools/tilemanager/Tile.cs +++ b/tools/tilemanager/Tile.cs @@ -17,7 +17,7 @@ public class Tile { public bool Water; public bool Slope; public bool Hidden; - public bool Spike; + public bool Hurts; public bool FullBox; public bool Brick; public bool Coin; @@ -67,8 +67,8 @@ public class Tile { writer.Write("water", true); if(Slope) writer.Write("slope-type", Data); - if(Spike) - writer.Write("spike", true); + if(Hurts) + writer.Write("hurts", true); if(Hidden) writer.Write("hidden", true); if(Coin) @@ -130,8 +130,8 @@ public class Tile { case "anim-fps": AnimFps = parser.FloatValue; break; - case "spike": - Spike = parser.BoolValue; + case "hurts": + Hurts = parser.BoolValue; break; case "hidden": Hidden = parser.BoolValue; -- 2.11.0