From: Christoph Sommer Date: Sun, 2 Apr 2006 22:19:22 +0000 (+0000) Subject: Worldmap teleporter is now animated / All Worldmap special tiles can be arbitrary... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5912c0d5e4bed6894ca236b64a96d5849f3c8e44;p=supertux.git Worldmap teleporter is now animated / All Worldmap special tiles can be arbitrary sprites SVN-Revision: 3209 --- diff --git a/src/worldmap.cpp b/src/worldmap.cpp index ac9fdf32e..b667aec26 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -2,6 +2,7 @@ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Ingo Ruhnke +// Copyright (C) 2006 Christoph Sommer // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -345,7 +346,7 @@ WorldMap::WorldMap() add_object(tux); messagedot = new Surface("images/worldmap/common/messagedot.png"); - teleporterdot = new Surface("images/worldmap/common/teleporterdot.png"); + teleporterdot = sprite_manager->create("images/worldmap/common/teleporter.sprite"); name = ""; music = "music/salcon.ogg"; @@ -365,6 +366,9 @@ WorldMap::~WorldMap() Level& level = *i; delete level.sprite; } + for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) { + delete i->sprite; + } delete tile_manager; @@ -466,6 +470,14 @@ WorldMap::parse_special_tile(const lisp::Lisp* lisp) lisp->get("x", special_tile.pos.x); lisp->get("y", special_tile.pos.y); + + std::string sprite; + if (lisp->get("sprite", sprite)) { + special_tile.sprite = sprite_manager->create(sprite); + } else { + special_tile.sprite = 0; + } + lisp->get("map-message", special_tile.map_message); special_tile.passive_message = false; lisp->get("passive-message", special_tile.passive_message); @@ -926,9 +938,11 @@ WorldMap::draw(DrawingContext& context) if(i->invisible) continue; - if (i->teleport_dest != Vector(-1, -1)) - context.draw_surface(teleporterdot, - Vector(i->pos.x*32, i->pos.y*32), LAYER_TILES+1); + if (i->sprite) + i->sprite->draw(context, i->pos*32 + Vector(16, 16), LAYER_TILES+1); + + else if (i->teleport_dest != Vector(-1, -1)) + teleporterdot->draw(context, i->pos*32 + Vector(16, 16), LAYER_TILES+1); else if (!i->map_message.empty() && !i->passive_message) context.draw_surface(messagedot, diff --git a/src/worldmap.hpp b/src/worldmap.hpp index 1256d6ce6..782c212f4 100644 --- a/src/worldmap.hpp +++ b/src/worldmap.hpp @@ -2,6 +2,7 @@ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke +// Copyright (C) 2006 Christoph Sommer // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -112,7 +113,7 @@ private: Surface* leveldot_green; Surface* leveldot_red; Surface* messagedot; - Surface* teleporterdot; + Sprite* teleporterdot; std::string name; std::string music; @@ -130,6 +131,9 @@ public: /** Optional flags: */ + /** Sprite to render instead of guessing what image to draw */ + Sprite* sprite; + /** Position to swap to player */ Vector teleport_dest;