projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Dispensed badguys are no longer counted in level stats.
[supertux.git]
/
src
/
badguy
/
mole.cpp
diff --git
a/src/badguy/mole.cpp
b/src/badguy/mole.cpp
index
4f035e2
..
c9a40cd
100644
(file)
--- a/
src/badguy/mole.cpp
+++ b/
src/badguy/mole.cpp
@@
-1,12
+1,10
@@
-// $Id$
-//
// SuperTux - Mole Badguy
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
//
// SuperTux - Mole Badguy
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
//
-// 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 2
-//
of the License, or
(at your option) any later version.
+// 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
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-14,26
+12,28
@@
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// 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
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <config.h>
+#include "audio/sound_manager.hpp"
+#include "badguy/mole.hpp"
+#include "badguy/mole_rock.hpp"
+#include "math/random_generator.hpp"
+#include "sprite/sprite.hpp"
+#include "supertux/object_factory.hpp"
+#include "supertux/sector.hpp"
-#include "mole.hpp"
-#include "mole_rock.hpp"
-#include "tile.hpp"
-#include "object/tilemap.hpp"
-#include "random_generator.hpp"
-#include "log.hpp"
-#include "level.hpp"
+#include <math.h>
-static const float
IDLE
_TIME = 0.2f; /**< time to wait before and after throwing */
+static const float
MOLE_WAIT
_TIME = 0.2f; /**< time to wait before and after throwing */
static const float THROW_TIME = 4.6f; /**< time to spend throwing */
static const float THROW_INTERVAL = 1; /**< time between two thrown rocks */
static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */
static const float THROW_TIME = 4.6f; /**< time to spend throwing */
static const float THROW_INTERVAL = 1; /**< time between two thrown rocks */
static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */
-Mole::Mole(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1), state(PRE_THROWING)
+Mole::Mole(const Reader& reader) :
+ BadGuy(reader, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
+ state(PRE_THROWING),
+ timer(),
+ throw_timer()
{
physic.enable_gravity(false);
sound_manager->preload("sounds/fall.wav");
{
physic.enable_gravity(false);
sound_manager->preload("sounds/fall.wav");
@@
-41,8
+41,11
@@
Mole::Mole(const lisp::Lisp& reader)
sound_manager->preload("sounds/dartfire.wav");
}
sound_manager->preload("sounds/dartfire.wav");
}
-Mole::Mole(const Vector& pos)
- : BadGuy(pos, "images/creatures/mole/mole.sprite", LAYER_TILES-1), state(PRE_THROWING)
+Mole::Mole(const Vector& pos) :
+ BadGuy(pos, "images/creatures/mole/mole.sprite", LAYER_TILES-1),
+ state(PRE_THROWING),
+ timer(),
+ throw_timer()
{
physic.enable_gravity(false);
sound_manager->preload("sounds/fall.wav");
{
physic.enable_gravity(false);
sound_manager->preload("sounds/fall.wav");
@@
-51,15
+54,6
@@
Mole::Mole(const Vector& pos)
}
void
}
void
-Mole::write(lisp::Writer& writer)
-{
- writer.start_list("mole");
- writer.write("x", start_position.x);
- writer.write("y", start_position.y);
- writer.end_list("mole");
-}
-
-void
Mole::activate()
{
if (state != DEAD) set_state(PRE_THROWING);
Mole::activate()
{
if (state != DEAD) set_state(PRE_THROWING);
@@
-70,7
+64,7
@@
Mole::kill_fall()
{
set_state(DEAD);
sound_manager->play("sounds/fall.wav", get_pos());
{
set_state(DEAD);
sound_manager->play("sounds/fall.wav", get_pos());
-
if (countMe) Sector::current()->get_level()->stats.badguys++
;
+
run_dead_script()
;
}
HitResponse
}
HitResponse
@@
-84,7
+78,7
@@
Mole::collision_squished(GameObject& )
{
set_state(DEAD);
sound_manager->play("sounds/squish.wav", get_pos());
{
set_state(DEAD);
sound_manager->play("sounds/squish.wav", get_pos());
-
if (countMe) Sector::current()->get_level()->stats.badguys++
;
+
run_dead_script()
;
return true;
}
return true;
}
@@
-94,7
+88,7
@@
Mole::throw_rock()
float px = get_bbox().get_middle().x;
float py = get_bbox().get_middle().y;
float px = get_bbox().get_middle().x;
float py = get_bbox().get_middle().y;
- float angle =
system
Random.rand(90 - 15, 90 + 15) * (M_PI / 180);
+ float angle =
game
Random.rand(90 - 15, 90 + 15) * (M_PI / 180);
float vx = cos(angle) * THROW_VELOCITY;
float vy = -sin(angle) * THROW_VELOCITY;
float vx = cos(angle) * THROW_VELOCITY;
float vy = -sin(angle) * THROW_VELOCITY;
@@
-145,7
+139,7
@@
Mole::set_state(MoleState new_state)
case PRE_THROWING:
sprite->set_action("idle");
set_colgroup_active(COLGROUP_DISABLED);
case PRE_THROWING:
sprite->set_action("idle");
set_colgroup_active(COLGROUP_DISABLED);
- timer.start(
IDLE
_TIME);
+ timer.start(
MOLE_WAIT
_TIME);
break;
case THROWING:
sprite->set_action("idle");
break;
case THROWING:
sprite->set_action("idle");
@@
-156,7
+150,7
@@
Mole::set_state(MoleState new_state)
case POST_THROWING:
sprite->set_action("idle");
set_colgroup_active(COLGROUP_DISABLED);
case POST_THROWING:
sprite->set_action("idle");
set_colgroup_active(COLGROUP_DISABLED);
- timer.start(
IDLE
_TIME);
+ timer.start(
MOLE_WAIT
_TIME);
break;
case PEEKING:
sprite->set_action("peeking", 1);
break;
case PEEKING:
sprite->set_action("peeking", 1);
@@
-171,4
+165,4
@@
Mole::set_state(MoleState new_state)
state = new_state;
}
state = new_state;
}
-IMPLEMENT_FACTORY(Mole, "mole")
+/* EOF */