projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updating cherrybomb, adding juicebox (blue bomb).
[supertux.git]
/
src
/
badguy
/
stalactite.cpp
diff --git
a/src/badguy/stalactite.cpp
b/src/badguy/stalactite.cpp
index
ab4fc4d
..
f53a944
100644
(file)
--- a/
src/badguy/stalactite.cpp
+++ b/
src/badguy/stalactite.cpp
@@
-1,7
+1,7
@@
// $Id$
// $Id$
-//
+//
// SuperTux
// SuperTux
-// Copyright (C) 200
5
Matthias Braun <matze@braunis.de>
+// Copyright (C) 200
6
Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@
-12,27
+12,24
@@
// 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.
// 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, write to the Free Software
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-// 02111-1307, USA.
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
#include "stalactite.hpp"
#include <config.h>
#include "stalactite.hpp"
+#include "random_generator.hpp"
-static const int SHAKE_RANGE = 40;
+static const int SHAKE_RANGE
_X
= 40;
static const float SHAKE_TIME = .8;
static const float SQUISH_TIME = 2;
static const float SHAKE_TIME = .8;
static const float SQUISH_TIME = 2;
+static const float SHAKE_RANGE_Y = 400;
Stalactite::Stalactite(const lisp::Lisp& lisp)
Stalactite::Stalactite(const lisp::Lisp& lisp)
+ : BadGuy(lisp, "images/creatures/stalactite/stalactite.sprite"), state(STALACTITE_HANGING)
{
{
- lisp.get("x", start_position.x);
- lisp.get("y", start_position.y);
- bbox.set_size(31.8, 31.8);
- sprite = sprite_manager->create("images/creatures/stalactite/stalactite.sprite");
- state = STALACTITE_HANGING;
countMe = false;
}
countMe = false;
}
@@
-51,9
+48,10
@@
Stalactite::active_update(float elapsed_time)
if(state == STALACTITE_HANGING) {
Player* player = this->get_nearest_player();
if (player) {
if(state == STALACTITE_HANGING) {
Player* player = this->get_nearest_player();
if (player) {
- if(player->get_bbox().p2.x > bbox.p1.x - SHAKE_RANGE
- && player->get_bbox().p1.x < bbox.p2.x + SHAKE_RANGE
- && player->get_bbox().p2.y > bbox.p1.y) {
+ if(player->get_bbox().p2.x > bbox.p1.x - SHAKE_RANGE_X
+ && player->get_bbox().p1.x < bbox.p2.x + SHAKE_RANGE_X
+ && player->get_bbox().p2.y > bbox.p1.y
+ && player->get_bbox().p1.y < bbox.p2.y + SHAKE_RANGE_Y) {
timer.start(SHAKE_TIME);
state = STALACTITE_SHAKING;
}
timer.start(SHAKE_TIME);
state = STALACTITE_SHAKING;
}
@@
-76,7
+74,7
@@
Stalactite::collision_solid(GameObject& , const CollisionHit& hit)
if(state != STALACTITE_FALLING && state != STALACTITE_SQUISHED)
return FORCE_MOVE;
if(state != STALACTITE_FALLING && state != STALACTITE_SQUISHED)
return FORCE_MOVE;
- if(
fabsf(hit.normal.y) > .5) { // hit floor or roof
?
+ if(
hit.normal.y < .9) { // hit floor
?
state = STALACTITE_SQUISHED;
set_group(COLGROUP_MOVING_ONLY_STATIC);
physic.set_velocity_y(0);
state = STALACTITE_SQUISHED;
set_group(COLGROUP_MOVING_ONLY_STATIC);
physic.set_velocity_y(0);
@@
-92,7
+90,7
@@
HitResponse
Stalactite::collision_player(Player& player, const CollisionHit& )
{
if(state != STALACTITE_SQUISHED) {
Stalactite::collision_player(Player& player, const CollisionHit& )
{
if(state != STALACTITE_SQUISHED) {
- player.kill(
Player::SHRINK
);
+ player.kill(
false
);
}
return FORCE_MOVE;
}
return FORCE_MOVE;
@@
-110,7
+108,7
@@
Stalactite::draw(DrawingContext& context)
return;
if(state == STALACTITE_SHAKING) {
return;
if(state == STALACTITE_SHAKING) {
- sprite->draw(context, get_pos() + Vector(
(rand() % 6)-3
, 0), LAYER_OBJECTS);
+ sprite->draw(context, get_pos() + Vector(
systemRandom.rand(-3,3)
, 0), LAYER_OBJECTS);
} else {
sprite->draw(context, get_pos(), LAYER_OBJECTS);
}
} else {
sprite->draw(context, get_pos(), LAYER_OBJECTS);
}