projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added a version of mriceblock that does not fall off ledges, title smartblock with...
[supertux.git]
/
src
/
badguy
/
treewillowisp.cpp
diff --git
a/src/badguy/treewillowisp.cpp
b/src/badguy/treewillowisp.cpp
index
36d798e
..
2b6c87e
100644
(file)
--- a/
src/badguy/treewillowisp.cpp
+++ b/
src/badguy/treewillowisp.cpp
@@
-1,12
+1,10
@@
-// $Id$
-//
// SuperTux - "Will-O-Wisp" Badguy
// Copyright (C) 2007 Matthias Braun
//
// SuperTux - "Will-O-Wisp" Badguy
// Copyright (C) 2007 Matthias Braun
//
-// 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,30
+12,43
@@
// 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.
-#include <config.h>
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#include "badguy/treewillowisp.hpp"
-#include "treewillowisp.hpp"
-#include "ghosttree.hpp"
+#include "audio/sound_manager.hpp"
+#include "audio/sound_source.hpp"
+#include "badguy/ghosttree.hpp"
#include "object/lantern.hpp"
#include "object/lantern.hpp"
+#include "object/player.hpp"
+#include "sprite/sprite.hpp"
+
+#include <math.h>
-static const std::string
SOUNDFILE
= "sounds/willowisp.wav";
+static const std::string
TREEWILLOSOUND
= "sounds/willowisp.wav";
static const float SUCKSPEED = 25;
TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos,
static const float SUCKSPEED = 25;
TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos,
- float radius, float speed)
- : BadGuy(Vector(0, 0), "images/creatures/willowisp/willowisp.sprite",
- LAYER_OBJECTS - 20), mystate(STATE_DEFAULT), tree(tree)
+ float radius, float speed) :
+ BadGuy(tree->get_pos() + pos, "images/creatures/willowisp/willowisp.sprite",
+ LAYER_OBJECTS - 20),
+ was_sucked(false),
+ mystate(STATE_DEFAULT),
+ color(),
+ angle(),
+ radius(),
+ speed(),
+ sound_source(),
+ tree(tree),
+ suck_target()
{
{
- treepos_delta = pos;
- sound_manager->preload(SOUNDFILE);
+ sound_manager->preload(TREEWILLOSOUND);
this->radius = radius;
this->angle = 0;
this->speed = speed;
this->radius = radius;
this->angle = 0;
this->speed = speed;
- start_position = tree->get_pos() + treepos_delta;
+
+ set_colgroup_active(COLGROUP_MOVING);
}
TreeWillOWisp::~TreeWillOWisp()
}
TreeWillOWisp::~TreeWillOWisp()
@@
-47,14
+58,12
@@
TreeWillOWisp::~TreeWillOWisp()
void
TreeWillOWisp::activate()
{
void
TreeWillOWisp::activate()
{
- sound_source.reset(sound_manager->create_sound_source(
SOUNDFILE
));
+ sound_source.reset(sound_manager->create_sound_source(
TREEWILLOSOUND
));
sound_source->set_position(get_pos());
sound_source->set_looping(true);
sound_source->set_gain(2.0);
sound_source->set_reference_distance(32);
sound_source->play();
sound_source->set_position(get_pos());
sound_source->set_looping(true);
sound_source->set_gain(2.0);
sound_source->set_reference_distance(32);
sound_source->play();
-
- set_group(COLGROUP_MOVING);
}
void
}
void
@@
-62,7
+71,7
@@
TreeWillOWisp::vanish()
{
mystate = STATE_VANISHING;
sprite->set_action("vanishing", 1);
{
mystate = STATE_VANISHING;
sprite->set_action("vanishing", 1);
- set_
group
(COLGROUP_DISABLED);
+ set_
colgroup_active
(COLGROUP_DISABLED);
}
void
}
void
@@
-70,6
+79,7
@@
TreeWillOWisp::start_sucking(Vector suck_target)
{
mystate = STATE_SUCKED;
this->suck_target = suck_target;
{
mystate = STATE_SUCKED;
this->suck_target = suck_target;
+ was_sucked = true;
}
HitResponse
}
HitResponse
@@
-91,6
+101,19
@@
TreeWillOWisp::collides(GameObject& other, const CollisionHit& ) {
}
void
}
void
+TreeWillOWisp::draw(DrawingContext& context)
+{
+ sprite->draw(context, get_pos(), layer);
+
+ context.push_target();
+ context.set_target(DrawingContext::LIGHTMAP);
+
+ sprite->draw(context, get_pos(), layer);
+
+ context.pop_target();
+}
+
+void
TreeWillOWisp::active_update(float elapsed_time)
{
// remove TreeWillOWisp if it has completely vanished
TreeWillOWisp::active_update(float elapsed_time)
{
// remove TreeWillOWisp if it has completely vanished
@@
-114,7
+137,7
@@
TreeWillOWisp::active_update(float elapsed_time)
}
angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
}
angle = fmodf(angle + elapsed_time * speed, (float) (2*M_PI));
- Vector newpos(
tree->get_pos() + treepos_delta
+ Vector(sin(angle) * radius, 0));
+ Vector newpos(
start_position
+ Vector(sin(angle) * radius, 0));
movement = newpos - get_pos();
float sizemod = cos(angle) * 0.8f;
/* TODO: modify sprite size */
movement = newpos - get_pos();
float sizemod = cos(angle) * 0.8f;
/* TODO: modify sprite size */
@@
-141,3
+164,4
@@
TreeWillOWisp::get_color() const
return color;
}
return color;
}
+/* EOF */