projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix issue with action not being updated when typing grow()/fire()/etc in console...
[supertux.git]
/
src
/
object
/
growup.cpp
diff --git
a/src/object/growup.cpp
b/src/object/growup.cpp
index
4a6e0ce
..
d422c2a
100644
(file)
--- a/
src/object/growup.cpp
+++ b/
src/object/growup.cpp
@@
-28,11
+28,11
@@
#include "audio/sound_manager.hpp"
GrowUp::GrowUp(Direction direction)
#include "audio/sound_manager.hpp"
GrowUp::GrowUp(Direction direction)
- : MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
+
: MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
{
{
- physic.
gravity_enabled = true
;
- physic.
vx = (direction == LEFT
?-100:100);
- sound_manager->preload("sounds/grow.
wav
");
+ physic.
enable_gravity(true)
;
+ physic.
set_velocity_x((direction == LEFT)
?-100:100);
+ sound_manager->preload("sounds/grow.
ogg
");
}
void
}
void
@@
-44,21
+44,26
@@
GrowUp::update(float elapsed_time)
void
GrowUp::collision_solid(const CollisionHit& hit)
{
void
GrowUp::collision_solid(const CollisionHit& hit)
{
- if(hit.top || hit.bottom)
- physic.vy = 0;
+ if(hit.top)
+ physic.set_velocity_y(0);
+ if(hit.bottom && physic.get_velocity_y() > 0)
+ physic.set_velocity_y(0);
if(hit.left || hit.right)
if(hit.left || hit.right)
- physic.
vx = -physic.vx
;
+ physic.
set_velocity_x(-physic.get_velocity_x())
;
}
HitResponse
}
HitResponse
-GrowUp::collision(GameObject& other, const CollisionHit& )
+GrowUp::collision(GameObject& other, const CollisionHit&
hit
)
{
Player* player = dynamic_cast<Player*>(&other);
if(player != 0) {
{
Player* player = dynamic_cast<Player*>(&other);
if(player != 0) {
- if(!player->add_bonus(GROWUP_BONUS, true))
- return FORCE_MOVE;
+ if(!player->add_bonus(GROWUP_BONUS, true)){
+ // Tux can't grow right now.
+ collision_solid( hit );
+ return ABORT_MOVE;
+ }
- sound_manager->play("sounds/grow.
wav
");
+ sound_manager->play("sounds/grow.
ogg
");
remove_me();
return ABORT_MOVE;
remove_me();
return ABORT_MOVE;
@@
-66,3
+71,9
@@
GrowUp::collision(GameObject& other, const CollisionHit& )
return FORCE_MOVE;
}
return FORCE_MOVE;
}
+
+void
+GrowUp::do_jump()
+{
+ physic.set_velocity_y(-300);
+}