;; - the meaning of the values in (attributes ...) can be seen in
;; src/tile.cpp, unisolid is 3 not 2
(supertux-tiles
+ (tile
+ (id 2943)
+ (images
+ "objects/bonus_block/full-0.png"
+ "objects/bonus_block/full-1.png"
+ "objects/bonus_block/full-2.png"
+ "objects/bonus_block/full-3.png"
+ "objects/bonus_block/full-4.png"
+ "objects/bonus_block/full-3.png"
+ "objects/bonus_block/full-2.png"
+ "objects/bonus_block/full-1.png"
+ "objects/bonus_block/full-0.png"
+ "objects/bonus_block/full-0.png"
+ "objects/bonus_block/full-0.png"
+ )
+ (solid #t)
+ (fullbox #t)
+ (next-tile 84)
+ (editor-images "objects/bonus_block/off.png")
+ (data 6)
+ (fps 15)
+ )
+
(tilegroup
(name "Pipe: Green")
(tiles
)
(tilegroup
(name "Block")
- (tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 44 83 84 102 140 103 104 105 112 128 1311 2153)
+ (tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 44 83 84 102 140 103 104 105 112 128 1311 2153 2943)
)
(tilegroup
(name "Background")
(image "tiles/snow/slope-upper.png" )
)
-;; next-id: 2943
+;; next-id: 2944
)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 544
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 576
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 608
-0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 640
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2943 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 640
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 672
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 132 0 ; 704
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 48 8 ; 736
Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
contents(),
object(0),
- hit_counter(1)
+ hit_counter(1),
+ lightsprite(Surface::create("/images/objects/lightmap_light/bonusblock_light.png"))
{
bbox.set_pos(pos);
sprite->set_action("normal");
case 3: contents = CONTENT_STAR; break;
case 4: contents = CONTENT_1UP; break;
case 5: contents = CONTENT_ICEGROW; break;
+ case 6: contents = CONTENT_LIGHT; sound_manager->preload("sounds/switch.ogg"); break;
default:
log_warning << "Invalid box contents" << std::endl;
contents = CONTENT_COIN;
Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
contents(),
object(0),
- hit_counter(1)
+ hit_counter(1),
+ lightsprite(Surface::create("/images/objects/lightmap_light/bonusblock_light.png"))
{
Vector pos;
contents = CONTENT_CUSTOM;
} else if(contentstring == "script") {
contents = CONTENT_SCRIPT;
+ } else if(contentstring == "light") {
+ contents = CONTENT_LIGHT;
+ sound_manager->preload("sounds/switch.ogg");
} else {
log_warning << "Invalid box contents '" << contentstring << "'" << std::endl;
}
}
break;
}
+ case CONTENT_LIGHT:
+ {
+ if(sprite->get_action() == "on")
+ sprite->set_action("off");
+ else
+ sprite->set_action("on");
+ sound_manager->play("sounds/switch.ogg");
+ }
}
start_bounce(player);
- if(hit_counter <= 0){ //use 0 to allow infinite hits
+ if(hit_counter <= 0 || contents == CONTENT_LIGHT){ //use 0 to allow infinite hits
}else if(hit_counter == 1){
sprite->set_action("empty");
}else{
remove_me();
}
+void
+BonusBlock::draw(DrawingContext& context){
+ // draw regular sprite
+ sprite->draw(context, get_pos(), 10);
+ //Draw light if on.
+ if(sprite->get_action() == "on") {
+ Vector pos = get_pos() + (bbox.get_size() - lightsprite->get_size()) / 2;
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+ context.draw_surface(lightsprite, pos, 10);
+ context.pop_target();
+ }
+}
/* EOF */
#define HEADER_SUPERTUX_OBJECT_BONUS_BLOCK_HPP
#include "object/block.hpp"
+#include "object/moving_sprite.hpp"
class BonusBlock : public Block
{
CONTENT_STAR,
CONTENT_1UP,
CONTENT_CUSTOM,
- CONTENT_SCRIPT
+ CONTENT_SCRIPT,
+ CONTENT_LIGHT
};
protected:
Contents contents;
MovingObject* object;
int hit_counter;
+ void draw(DrawingContext& context);
private:
BonusBlock(const BonusBlock&);
BonusBlock& operator=(const BonusBlock&);
std::string sprite_name;
std::string script;
+ SurfacePtr lightsprite;
};
#endif