Skip to content

Commit

Permalink
New bonus_block contnet: trampolines & rock
Browse files Browse the repository at this point in the history
  • Loading branch information
LMH0013 committed Dec 7, 2012
1 parent f0fb4b7 commit 02a5360
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 9 deletions.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/objects/bonus_block/bonus-rock.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/images/objects/bonus_block/bonus-tramp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified data/images/objects/bonus_block/light.xcf
Binary file not shown.
Binary file modified data/images/objects/lightmap_light/bonusblock_light.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 71 additions & 2 deletions data/images/tiles.strf
Expand Up @@ -14,6 +14,75 @@
;; - the meaning of the values in (attributes ...) can be seen in
;; src/tile.cpp, unisolid is 3 not 2
(supertux-tiles
(tile
(id 2946)
(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/bonus-rock.png")
(data 9)
(fps 15)
)

(tile
(id 2945)
(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/bonus-porttramp.png")
(data 8)
(fps 15)
)

(tile
(id 2944)
(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/bonus-tramp.png")
(data 7)
(fps 15)
)

(tile
(id 2943)
(images
Expand Down Expand Up @@ -546,7 +615,7 @@
)
(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 2943)
(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 2943 2944 2945 2946 1311 2153)
)
(tilegroup
(name "Background")
Expand Down Expand Up @@ -3846,5 +3915,5 @@
(image "tiles/snow/slope-upper.png" )
)

;; next-id: 2944
;; next-id: 2947
)
6 changes: 3 additions & 3 deletions data/levels/test/bonusblock.stl
Expand Up @@ -22,20 +22,20 @@
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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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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 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 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 2943 0 0 0 2944 2945 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
Expand Down
44 changes: 41 additions & 3 deletions src/object/bonus_block.cpp
Expand Up @@ -28,6 +28,7 @@
#include "object/portable.hpp"
#include "object/specialriser.hpp"
#include "object/star.hpp"
#include "object/trampoline.hpp"
#include "sprite/sprite_manager.hpp"
#include "supertux/constants.hpp"
#include "supertux/level.hpp"
Expand All @@ -41,7 +42,7 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
contents(),
object(0),
hit_counter(1),
lightsprite(Surface::create("/images/objects/lightmap_light/bonusblock_light.png"))
lightsprite()
{
bbox.set_pos(pos);
sprite->set_action("normal");
Expand All @@ -51,7 +52,13 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
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;
case 6: contents = CONTENT_LIGHT;
sound_manager->preload("sounds/switch.ogg");
lightsprite=Surface::create("/images/objects/lightmap_light/bonusblock_light.png");
break;
case 7: contents = CONTENT_TRAMPOLINE; break;
case 8: contents = CONTENT_PORTTRAMPOLINE; break;
case 9: contents = CONTENT_ROCK; break;
default:
log_warning << "Invalid box contents" << std::endl;
contents = CONTENT_COIN;
Expand All @@ -64,7 +71,7 @@ BonusBlock::BonusBlock(const Reader& lisp) :
contents(),
object(0),
hit_counter(1),
lightsprite(Surface::create("/images/objects/lightmap_light/bonusblock_light.png"))
lightsprite()
{
Vector pos;

Expand Down Expand Up @@ -103,6 +110,12 @@ BonusBlock::BonusBlock(const Reader& lisp) :
} else if(contentstring == "light") {
contents = CONTENT_LIGHT;
sound_manager->preload("sounds/switch.ogg");
} else if(contentstring == "trampoline") {
contents = CONTENT_TRAMPOLINE;
} else if(contentstring == "porttrampoline") {
contents = CONTENT_PORTTRAMPOLINE;
} else if(contentstring == "rock") {
contents = CONTENT_ROCK;
} else {
log_warning << "Invalid box contents '" << contentstring << "'" << std::endl;
}
Expand All @@ -121,6 +134,8 @@ BonusBlock::BonusBlock(const Reader& lisp) :

if(contents == CONTENT_CUSTOM && object == 0)
throw std::runtime_error("Need to specify content object for custom block");
if(contents == CONTENT_LIGHT)
lightsprite = Surface::create("/images/objects/lightmap_light/bonusblock_light.png");

bbox.set_pos(pos);
}
Expand Down Expand Up @@ -257,6 +272,29 @@ BonusBlock::try_open(Player *player)
else
sprite->set_action("on");
sound_manager->play("sounds/switch.ogg");
break;
}
case CONTENT_TRAMPOLINE:
{
SpecialRiser* riser = new SpecialRiser(get_pos(), new Trampoline(get_pos(), false));
sector->add_object(riser);
sound_manager->play("sounds/upgrade.wav");
break;
}
case CONTENT_PORTTRAMPOLINE:
{
SpecialRiser* riser = new SpecialRiser(get_pos(), new Trampoline(get_pos(), true));
sector->add_object(riser);
sound_manager->play("sounds/upgrade.wav");
break;
}
case CONTENT_ROCK:
{
SpecialRiser* riser = new SpecialRiser(get_pos(),
new Rock(get_pos(), "images/objects/rock/rock.sprite"));
sector->add_object(riser);
sound_manager->play("sounds/upgrade.wav");
break;
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/object/bonus_block.hpp
Expand Up @@ -38,7 +38,10 @@ class BonusBlock : public Block
CONTENT_1UP,
CONTENT_CUSTOM,
CONTENT_SCRIPT,
CONTENT_LIGHT
CONTENT_LIGHT,
CONTENT_TRAMPOLINE,
CONTENT_PORTTRAMPOLINE,
CONTENT_ROCK
};

protected:
Expand Down
12 changes: 12 additions & 0 deletions src/object/trampoline.cpp
Expand Up @@ -49,6 +49,18 @@ Trampoline::Trampoline(const Reader& lisp) :
}
}

Trampoline::Trampoline(const Vector& pos, bool port) :
Rock(pos, "images/objects/trampoline/trampoline.sprite"),
portable(port)
{
sound_manager->preload(TRAMPOLINE_SOUND);
if(!port) {
sprite_name = "images/objects/trampoline/trampoline_fix.sprite";
sprite = sprite_manager->create(sprite_name);
sprite->set_action("normal");
}
}

void
Trampoline::update(float elapsed_time)
{
Expand Down
1 change: 1 addition & 0 deletions src/object/trampoline.hpp
Expand Up @@ -26,6 +26,7 @@ class Trampoline : public Rock
{
public:
Trampoline(const Reader& reader);
Trampoline(const Vector& pos, bool port);

HitResponse collision(GameObject& other, const CollisionHit& hit);
void collision_solid(const CollisionHit& hit);
Expand Down

0 comments on commit 02a5360

Please sign in to comment.