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
/
kugelblitz.cpp
diff --git
a/src/badguy/kugelblitz.cpp
b/src/badguy/kugelblitz.cpp
index
eb4fc2e
..
f8ecf17
100644
(file)
--- a/
src/badguy/kugelblitz.cpp
+++ b/
src/badguy/kugelblitz.cpp
@@
-1,7
+1,7
@@
-// $Id
: Kugelblitz.cpp 2654 2005-06-29 14:16:22Z wansti
$
-//
+// $Id$
+//
// SuperTux
// SuperTux
-// Copyright (C) 200
5 Marek Moeckel <wansti@gmx
.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,17
+12,18
@@
// 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 "kugelblitz.hpp"
#include "object/tilemap.hpp"
#include "object/camera.hpp"
#include "tile.hpp"
#include <config.h>
#include "kugelblitz.hpp"
#include "object/tilemap.hpp"
#include "object/camera.hpp"
#include "tile.hpp"
+#include "random_generator.hpp"
#define LIFETIME 5
#define MOVETIME 0.75
#define LIFETIME 5
#define MOVETIME 0.75
@@
-33,12
+34,9
@@
static const float X_OFFSCREEN_DISTANCE = 1600;
static const float Y_OFFSCREEN_DISTANCE = 1200;
Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
static const float Y_OFFSCREEN_DISTANCE = 1200;
Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
- : groundhit_pos_set(false)
+ :
BadGuy(Vector(0,0), "images/creatures/kugelblitz/kugelblitz.sprite"),
groundhit_pos_set(false)
{
reader.get("x", start_position.x);
{
reader.get("x", start_position.x);
- start_position.y = 0; //place above visible area
- bbox.set_size(63.8, 63.8);
- sprite = sprite_manager->create("images/creatures/kugelblitz/kugelblitz.sprite");
sprite->set_action("falling");
physic.enable_gravity(false);
}
sprite->set_action("falling");
physic.enable_gravity(false);
}
@@
-56,7
+54,7
@@
Kugelblitz::write(lisp::Writer& writer)
void
Kugelblitz::activate()
{
void
Kugelblitz::activate()
{
- physic.set_velocity_y(
-
300);
+ physic.set_velocity_y(300);
physic.set_velocity_x(-20); //fall a little to the left
direction = 1;
dying = false;
physic.set_velocity_x(-20); //fall a little to the left
direction = 1;
dying = false;
@@
-80,11
+78,11
@@
Kugelblitz::collision_player(Player& player, const CollisionHit& )
(get_bbox().p1.y + get_bbox().p2.y) / 2) {
// if it's not is it possible to squish us, then this will hurt
if(!collision_squished(player))
(get_bbox().p1.y + get_bbox().p2.y) / 2) {
// if it's not is it possible to squish us, then this will hurt
if(!collision_squished(player))
- player.kill(
Player::SHRINK
);
+ player.kill(
false
);
explode();
return FORCE_MOVE;
}
explode();
return FORCE_MOVE;
}
- player.kill(
Player::SHRINK
);
+ player.kill(
false
);
explode();
return FORCE_MOVE;
}
explode();
return FORCE_MOVE;
}
@@
-111,8
+109,8
@@
Kugelblitz::hit(const CollisionHit& chit)
sprite->set_action("flying");
physic.set_velocity_y(0);
//Set random initial speed and direction
sprite->set_action("flying");
physic.set_velocity_y(0);
//Set random initial speed and direction
-
if ((rand() % 2) == 1) direction = 1; else direction =
-1;
- int speed = (BASE_SPEED + (
rand() % RAND_SPEED
)) * direction;
+
direction = systemRandom.rand(2)? 1:
-1;
+ int speed = (BASE_SPEED + (
systemRandom.rand(RAND_SPEED)
)) * direction;
physic.set_velocity_x(speed);
movement_timer.start(MOVETIME);
lifetime.start(LIFETIME);
physic.set_velocity_x(speed);
movement_timer.start(MOVETIME);
lifetime.start(LIFETIME);
@@
-134,7
+132,7
@@
Kugelblitz::active_update(float elapsed_time)
if (groundhit_pos_set) {
if (movement_timer.check()) {
if (direction == 1) direction = -1; else direction = 1;
if (groundhit_pos_set) {
if (movement_timer.check()) {
if (direction == 1) direction = -1; else direction = 1;
- int speed = (BASE_SPEED + (
rand() % RAND_SPEED
)) * direction;
+ int speed = (BASE_SPEED + (
systemRandom.rand(RAND_SPEED)
)) * direction;
physic.set_velocity_x(speed);
movement_timer.start(MOVETIME);
}
physic.set_velocity_x(speed);
movement_timer.start(MOVETIME);
}