--- /dev/null
+(supertux-level
+ (version 2)
+ (name (_ "Bonusblock Test"))
+ (author "LMH")
+ (license "GPL 2 / CC-by-sa 3.0" )
+ (sector (name "main" )
+ (ambient-light 1 1 1 )
+ (camera (mode "normal" ))
+ (init-script " lightson <- true; ")
+
+ (spawnpoint (name "main" )
+ (x 80 )(y 704 ))
+
+ (tilemap (name "Interactive" )
+ (z-pos 0 )(solid #t )
+ (width 42 )(height 30 )
+ (tiles ; 160 192 224 256 288 320 352 384 416 448 480 512 544 576 608 640 672 704 736 768 800 832 864 896 928 960 992 1024 1056 1088 1120 1152 1184 1216 1248 1280 1312
+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
+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 ; 32
+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 ; 64
+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 ; 96
+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 ; 128
+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 ; 160
+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 ; 192
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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 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 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 0 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 8 8 ; 736
+14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 ; 768
+11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 800
+11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 832
+11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 864
+11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 896
+11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ; 928
+ ))
+
+ (bonusblock
+ (x 256 )
+ (y 640 )
+ (contents "coin" )
+ (count 3 )
+ )
+
+ (bonusblock
+ (x 384 )
+ (y 640 )
+ (contents "firegrow" )
+ (sprite "images/objects/bonus_block/brick.sprite" )
+ )
+
+ (bonusblock
+ (x 512 )
+ (y 640 )
+ (contents "1up" )
+ (sprite "images/objects/bonus_block/hiddenbonus.sprite" )
+ )
+
+ (bonusblock
+ (x 640 )
+ (y 640 )
+ (contents "script" )
+ (script "
+ vineA.goto_node(8);
+ vineB.goto_node(8);
+ vineC.goto_node(8);
+ vineD.goto_node(8);
+ vineE.goto_node(8);
+ vineF.goto_node(8);
+ vineG.goto_node(8);
+ vineH.goto_node(8);
+ ")
+ )
+
+ (bonusblock
+ (x 768 )
+ (y 640 )
+ (contents "script" )
+ (sprite "images/objects/bonus_block/hiddenbonus.sprite" )
+ (count 0 )
+ (script "
+ if(lightson){
+ lightson <- false;
+ settings.set_ambient_light(0, 0, 0);
+ cover.fade(0,0);
+ } else {
+ lightson <- true;
+ settings.set_ambient_light(1, 1, 1);
+ cover.fade(1,0);
+ }
+ ")
+ )
+ (candle (x 768 )(y 640 ))
+
+ (tilemap (name "cover" )(alpha 1 )
+ (z-pos -100 )(solid #f )
+ (path (node (x 767 )(y 640 )) )
+ (width 1 )(height 1 )
+ (tiles 131 ))
+ (tilemap
+ (z-pos -200 )(solid #f )
+ (path (node (x 767 )(y 640 )) )
+ (width 1 )(height 1 )
+ (tiles 61 ))
+
+ (tilemap (name "vineA" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 ))
+ (node (x 640 )(y 544 )(time 0.25 ))
+ (node (x 640 )(y 512 )(time 0.25 ))
+ (node (x 640 )(y 480 )(time 0.25 ))
+ (node (x 640 )(y 448 )(time 0.25 ))
+ (node (x 640 )(y 416 )(time 0.25 ))
+ (node (x 640 )(y 384 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2163 ))
+ (tilemap (name "vineB" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 ))
+ (node (x 640 )(y 544 )(time 0.25 ))
+ (node (x 640 )(y 512 )(time 0.25 ))
+ (node (x 640 )(y 480 )(time 0.25 ))
+ (node (x 640 )(y 448 )(time 0.25 ))
+ (node (x 640 )(y 416 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2162 ))
+ (tilemap (name "vineC" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 ))
+ (node (x 640 )(y 544 )(time 0.25 ))
+ (node (x 640 )(y 512 )(time 0.25 ))
+ (node (x 640 )(y 480 )(time 0.25 ))
+ (node (x 640 )(y 448 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2162 ))
+ (tilemap (name "vineD" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 ))
+ (node (x 640 )(y 544 )(time 0.25 ))
+ (node (x 640 )(y 512 )(time 0.25 ))
+ (node (x 640 )(y 480 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2162 ))
+ (tilemap (name "vineE" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 ))
+ (node (x 640 )(y 544 )(time 0.25 ))
+ (node (x 640 )(y 512 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2163 ))
+ (tilemap (name "vineF" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 ))
+ (node (x 640 )(y 544 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2162 ))
+ (tilemap (name "vineG" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 ))
+ (node (x 640 )(y 576 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2162 ))
+ (tilemap (name "vineH" )
+ (z-pos -50 )(solid #t )
+ (path (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 640 )(time 0.25 ))
+ (node (x 640 )(y 608 )(time 0.25 )) )
+ (width 1 )(height 1 )
+ (tiles 2162 ))
+))
BonusBlock::BonusBlock(const Vector& pos, int data) :
Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
contents(),
- object(0)
+ object(0),
+ hit_counter(1)
{
bbox.set_pos(pos);
sprite->set_action("normal");
BonusBlock::BonusBlock(const Reader& lisp) :
Block(sprite_manager->create("images/objects/bonus_block/bonusblock.sprite")),
contents(),
- object(0)
+ object(0),
+ hit_counter(1)
{
Vector pos;
iter.value()->get(pos.x);
} else if(token == "y") {
iter.value()->get(pos.y);
+ } else if(token == "sprite") {
+ iter.value()->get(sprite_name);
+ sprite = sprite_manager->create(sprite_name);
+ } else if(token == "count") {
+ iter.value()->get(hit_counter);
+ } else if(token == "script") {
+ iter.value()->get(script);
} else if(token == "contents") {
std::string contentstring;
iter.value()->get(contentstring);
contents = CONTENT_1UP;
} else if(contentstring == "custom") {
contents = CONTENT_CUSTOM;
+ } else if(contentstring == "script") {
+ contents = CONTENT_SCRIPT;
} else {
log_warning << "Invalid box contents '" << contentstring << "'" << std::endl;
}
break;
case CONTENT_CUSTOM:
- SpecialRiser* riser = new SpecialRiser(get_pos(), object);
- object = 0;
- sector->add_object(riser);
- sound_manager->play("sounds/upgrade.wav");
+ {
+ SpecialRiser* riser = new SpecialRiser(get_pos(), object);
+ object = 0;
+ sector->add_object(riser);
+ sound_manager->play("sounds/upgrade.wav");
+ break;
+ }
+
+ case CONTENT_SCRIPT:
+ if(script != "") {
+ std::istringstream stream(script);
+ Sector::current()->run_script(stream, "powerup-script");
+ }
break;
}
start_bounce(player);
- sprite->set_action("empty");
+ if(hit_counter <= 0){ //use 0 to allow infinite hits
+ }else if(hit_counter == 1){
+ sprite->set_action("empty");
+ }else{
+ hit_counter--;
+ }
}
void