Skip to content

Commit

Permalink
New BonusBlock content: 'explode' - a coin explosion.
Browse files Browse the repository at this point in the history
Causes ten coins to be hurled through the air as an alternative to coin rain in covered areas such as cave levels.  These coins are included in the level stats.  Testable in test/bonusblock.stl.
  • Loading branch information
LMH0013 committed Jul 13, 2013
1 parent c0b1f81 commit 4f0d26a
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 18 deletions.
Binary file added data/images/objects/bonus_block/bonus-explode.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 30 additions & 7 deletions data/images/tiles.strf
Expand Up @@ -14,6 +14,29 @@
;; - the meaning of the values in (attributes ...) can be seen in
;; src/tile.cpp, unisolid is 3 not 2
(supertux-tiles
(tile
(id 2948)
(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-explode.png")
(data 11)
(fps 15)
)

(tile
(id 2947)
(images
Expand All @@ -36,7 +59,7 @@
(data 10)
(fps 15)
)

(tile
(id 2946)
(images
Expand All @@ -59,7 +82,7 @@
(data 9)
(fps 15)
)

(tile
(id 2945)
(images
Expand All @@ -82,7 +105,7 @@
(data 8)
(fps 15)
)

(tile
(id 2944)
(images
Expand All @@ -105,7 +128,7 @@
(data 7)
(fps 15)
)

(tile
(id 2943)
(images
Expand All @@ -128,7 +151,7 @@
(data 6)
(fps 15)
)

(tilegroup
(name "Pipe: Green")
(tiles
Expand Down Expand Up @@ -638,7 +661,7 @@
)
(tilegroup
(name "Block")
(tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 44 83 2947 84 102 140 103 104 105 112 128 2943 2944 2945 2946 1311 2153)
(tiles 27 28 29 47 48 50 49 211 77 51 52 212 78 62 61 213 44 83 2947 2948 84 102 140 103 104 105 112 128 2943 2944 2945 2946 1311 2153)
)
(tilegroup
(name "Background")
Expand Down Expand Up @@ -3938,5 +3961,5 @@
(image "tiles/snow/slope-upper.png" )
)

;; next-id: 2948
;; next-id: 2949
)
20 changes: 10 additions & 10 deletions data/levels/test/bonusblock.stl
Expand Up @@ -30,7 +30,7 @@
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 384
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 416
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 448
0 0 0 0 2946 0 0 0 2947 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 480
0 0 0 0 2946 0 0 0 2947 0 0 0 2948 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 480
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ; 512
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
Expand All @@ -45,15 +45,15 @@
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 256 )
(y 640 )
(contents "coin" )
(count 3 )
)
(bonusblock
(x 384 )
(y 640 )
Expand Down
12 changes: 12 additions & 0 deletions src/object/bonus_block.cpp
Expand Up @@ -22,6 +22,7 @@
#include "object/broken_brick.hpp"
#include "object/flower.hpp"
#include "object/bouncy_coin.hpp"
#include "object/coin_explode.hpp"
#include "object/coin_rain.hpp"
#include "object/growup.hpp"
#include "object/oneup.hpp"
Expand Down Expand Up @@ -61,6 +62,7 @@ BonusBlock::BonusBlock(const Vector& pos, int data) :
case 8: contents = CONTENT_PORTTRAMPOLINE; break;
case 9: contents = CONTENT_ROCK; break;
case 10: contents = CONTENT_RAIN; break;
case 11: contents = CONTENT_EXPLODE; break;
default:
log_warning << "Invalid box contents" << std::endl;
contents = CONTENT_COIN;
Expand Down Expand Up @@ -120,6 +122,8 @@ BonusBlock::BonusBlock(const Reader& lisp) :
contents = CONTENT_ROCK;
} else if(contentstring == "rain") {
contents = CONTENT_RAIN;
} else if(contentstring == "explode") {
contents = CONTENT_EXPLODE;
} else {
log_warning << "Invalid box contents '" << contentstring << "'" << std::endl;
}
Expand Down Expand Up @@ -301,6 +305,14 @@ BonusBlock::try_open(Player *player)
hit_counter = 1; // multiple hits of coin rain is not allowed
Sector::current()->add_object(new CoinRain(get_pos(), true));
sound_manager->play("sounds/upgrade.wav");
break;
}
case CONTENT_EXPLODE:
{
hit_counter = 1; // multiple hits of coin explode is not allowed
Sector::current()->add_object(new CoinExplode(get_pos() + Vector (0, -40), 1));
sound_manager->play("sounds/upgrade.wav");
break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/object/bonus_block.hpp
Expand Up @@ -42,7 +42,8 @@ class BonusBlock : public Block
CONTENT_TRAMPOLINE,
CONTENT_PORTTRAMPOLINE,
CONTENT_ROCK,
CONTENT_RAIN
CONTENT_RAIN,
CONTENT_EXPLODE
};

protected:
Expand Down
4 changes: 4 additions & 0 deletions src/object/coin.cpp
Expand Up @@ -194,10 +194,14 @@ HeavyCoin::collision_solid(const CollisionHit& hit)
{
if(hit.bottom) {
physic.set_velocity_y(0);
physic.set_velocity_x(0);
}
if(hit.right || hit.left) {
physic.set_velocity_x(-physic.get_velocity_x());
}
if(hit.top) {
physic.set_velocity_y(0);
}
}

/* EOF */
55 changes: 55 additions & 0 deletions src/object/coin_explode.cpp
@@ -0,0 +1,55 @@
// CoinExplode - several coins are hurled through the air
// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "object/coin_explode.hpp"

#include "math/random_generator.hpp"
#include "object/coin.hpp"
#include "supertux/sector.hpp"

CoinExplode::CoinExplode(const Vector& pos, const int vert) :
position(pos),
y_velocity_weight(vert) // should generally be +/- 1 to send coins up or down respectively
{
}

void
CoinExplode::update(float )
{
int mag = 100; // madnitude that coins are to be thrown
int rand = 30; // max variation to be subtracted from magnitide

//TODO: this needs its own snazzy sound
Sector::current()->add_object(new HeavyCoin(position, Vector (2.5,-4.5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (2,-5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (1.5,-5.5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (1,-6)*(mag+gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (0.5,-6.5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (-2.5,-4.5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (-2,-5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (-1.5,-5.5)*(mag-gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (-1,-6)*(mag+gameRandom.rand(rand))));
Sector::current()->add_object(new HeavyCoin(position, Vector (-0.5,-6.5)*(mag-gameRandom.rand(rand))));

remove_me();
}

void
CoinExplode::draw(DrawingContext &)
{
}

/* EOF */
39 changes: 39 additions & 0 deletions src/object/coin_explode.hpp
@@ -0,0 +1,39 @@
// CoinExplode - several coins are hurled through the air
// Copyright (C) 2013 LMH <lmh.0013@gmail.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#ifndef HEADER_SUPERTUX_OBJECT_COIN_EXPLODE_HPP
#define HEADER_SUPERTUX_OBJECT_COIN_EXPLODE_HPP

#include <memory>

#include "math/vector.hpp"
#include "supertux/game_object.hpp"

class CoinExplode : public GameObject
{
public:
CoinExplode(const Vector& pos, const int vert);
virtual void update(float elapsed_time);
virtual void draw(DrawingContext& context);

private:
Vector position;
int y_velocity_weight;
};

#endif

/* EOF */
3 changes: 3 additions & 0 deletions src/supertux/level.cpp
Expand Up @@ -206,6 +206,9 @@ Level::get_total_coins()
} else if (block->contents == BonusBlock::CONTENT_RAIN) {
total_coins += 10;
continue;
} else if (block->contents == BonusBlock::CONTENT_EXPLODE) {
total_coins += 10;
continue;
}
#if 0
// FIXME: do we want this? q.v. src/object/oneup.cpp
Expand Down
1 change: 1 addition & 0 deletions src/supertux/object_factory.cpp
Expand Up @@ -86,6 +86,7 @@
#include "object/candle.hpp"
#include "object/cloud_particle_system.hpp"
#include "object/coin.hpp"
#include "object/coin_explode.hpp"
#include "object/coin_rain.hpp"
#include "object/comet_particle_system.hpp"
#include "object/decal.hpp"
Expand Down

0 comments on commit 4f0d26a

Please sign in to comment.