projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Switched from tinygettext/tags/tinygetext-supertux/ to tinygettext/trunk/
[supertux.git]
/
src
/
object
/
trampoline.cpp
diff --git
a/src/object/trampoline.cpp
b/src/object/trampoline.cpp
index
4871cf6
..
e097dcd
100644
(file)
--- a/
src/object/trampoline.cpp
+++ b/
src/object/trampoline.cpp
@@
-1,12
+1,10
@@
-// $Id$
-//
// SuperTux - Trampoline
// Copyright (C) 2006 Wolfgang Becker <uafr@gmx.de>
//
// SuperTux - Trampoline
// Copyright (C) 2006 Wolfgang Becker <uafr@gmx.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,39
+12,39
@@
// 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 "trampoline.hpp"
-#include "object_factory.hpp"
-#include "player.hpp"
#include "audio/sound_manager.hpp"
#include "audio/sound_manager.hpp"
-#include "sprite/sprite_manager.hpp"
#include "badguy/walking_badguy.hpp"
#include "badguy/walking_badguy.hpp"
+#include "control/controller.hpp"
+#include "object/player.hpp"
+#include "object/trampoline.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "supertux/object_factory.hpp"
+#include "util/reader.hpp"
/* Trampoline will accelerate player to to VY_INITIAL, if
* he jumps on it to VY_MIN. */
namespace {
/* Trampoline will accelerate player to to VY_INITIAL, if
* he jumps on it to VY_MIN. */
namespace {
-
const std::string TRAMPOLINE_SOUND = "sounds/trampoline.wav";
-
const float VY_MIN = -900; //negative, upwards
-
const float VY_INITIAL = -500;
+const std::string TRAMPOLINE_SOUND = "sounds/trampoline.wav";
+const float VY_MIN = -900; //negative, upwards
+const float VY_INITIAL = -500;
}
}
-Trampoline::Trampoline(const lisp::Lisp& lisp)
- : Rock(lisp, "images/objects/trampoline/trampoline.sprite")
+Trampoline::Trampoline(const Reader& lisp) :
+ Rock(lisp, "images/objects/trampoline/trampoline.sprite"),
+ portable(true)
{
sound_manager->preload(TRAMPOLINE_SOUND);
{
sound_manager->preload(TRAMPOLINE_SOUND);
- portable = true;
//Check if this trampoline is not portable
if(lisp.get("portable", portable)) {
if(!portable) {
//Check if this trampoline is not portable
if(lisp.get("portable", portable)) {
if(!portable) {
-
//we need another sprite
-
sprite_name = "images/objects/trampoline/trampoline_fix.sprite";
-
sprite = sprite_manager->create(sprite_name);
-
sprite->set_action("normal");
+ //we need another sprite
+ sprite_name = "images/objects/trampoline/trampoline_fix.sprite";
+ sprite = sprite_manager->create(sprite_name);
+ sprite->set_action("normal");
}
}
}
}
}
}
@@
-70,18
+68,18
@@
Trampoline::collision(GameObject& other, const CollisionHit& hit)
Player* player = dynamic_cast<Player*> (&other);
//Trampoline works for player
if(player) {
Player* player = dynamic_cast<Player*> (&other);
//Trampoline works for player
if(player) {
- float vy = player->
physic
.get_velocity_y();
+ float vy = player->
get_physic()
.get_velocity_y();
//player is falling down on trampoline
if(hit.top && vy >= 0) {
//player is falling down on trampoline
if(hit.top && vy >= 0) {
- if(player->get_controller()->hold(Controller::JUMP)) {
- vy = VY_MIN;
- } else {
- vy = VY_INITIAL;
- }
-
player->physic
.set_velocity_y(vy);
- sound_manager->play(TRAMPOLINE_SOUND);
- sprite->set_action("swinging", 1);
- return FORCE_MOVE;
+
if(player->get_controller()->hold(Controller::JUMP)) {
+
vy = VY_MIN;
+
} else {
+
vy = VY_INITIAL;
+
}
+
player->get_physic()
.set_velocity_y(vy);
+
sound_manager->play(TRAMPOLINE_SOUND);
+
sprite->set_action("swinging", 1);
+
return FORCE_MOVE;
}
}
WalkingBadguy* walking_badguy = dynamic_cast<WalkingBadguy*> (&other);
}
}
WalkingBadguy* walking_badguy = dynamic_cast<WalkingBadguy*> (&other);
@@
-90,11
+88,11
@@
Trampoline::collision(GameObject& other, const CollisionHit& hit)
float vy = walking_badguy->get_velocity_y();
//walking_badguy is falling down on trampoline
if(hit.top && vy >= 0) {
float vy = walking_badguy->get_velocity_y();
//walking_badguy is falling down on trampoline
if(hit.top && vy >= 0) {
- vy = VY_INITIAL;
- walking_badguy->set_velocity_y(vy);
- sound_manager->play(TRAMPOLINE_SOUND);
- sprite->set_action("swinging", 1);
- return FORCE_MOVE;
+
vy = VY_INITIAL;
+
walking_badguy->set_velocity_y(vy);
+
sound_manager->play(TRAMPOLINE_SOUND);
+
sprite->set_action("swinging", 1);
+
return FORCE_MOVE;
}
}
}
}
}
}
@@
-125,3
+123,5
@@
Trampoline::is_portable() const
}
IMPLEMENT_FACTORY(Trampoline, "trampoline");
}
IMPLEMENT_FACTORY(Trampoline, "trampoline");
+
+/* EOF */