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
3b413e4
..
d422c2a
100644
(file)
--- a/
src/object/growup.cpp
+++ b/
src/object/growup.cpp
@@
-26,48
+26,46
@@
#include "sector.hpp"
#include "player.hpp"
#include "audio/sound_manager.hpp"
#include "sector.hpp"
#include "player.hpp"
#include "audio/sound_manager.hpp"
-#include "sprite/sprite_manager.hpp"
-GrowUp::GrowUp()
+GrowUp::GrowUp(Direction direction)
+ : MovingSprite(Vector(0,0), "images/powerups/egg/egg.sprite", LAYER_OBJECTS, COLGROUP_MOVING)
{
{
- bbox.set_size(32, 32);
-
- sprite = sprite_manager->create("images/powerups/egg/egg.sprite");
physic.enable_gravity(true);
physic.enable_gravity(true);
- physic.set_velocity_x(100);
- s
et_group(COLGROUP_MOVING
);
+ physic.set_velocity_x(
(direction == LEFT)?-100:
100);
+ s
ound_manager->preload("sounds/grow.ogg"
);
}
}
-GrowUp::~GrowUp()
+void
+GrowUp::update(float elapsed_time)
{
{
-
delete sprite
;
+
movement = physic.get_movement(elapsed_time)
;
}
void
}
void
-GrowUp::
update(float elapsed_time
)
+GrowUp::
collision_solid(const CollisionHit& hit
)
{
{
- movement = physic.get_movement(elapsed_time);
+ 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)
+ physic.set_velocity_x(-physic.get_velocity_x());
}
HitResponse
}
HitResponse
-GrowUp::collision(GameObject& other, const CollisionHit& hit)
+GrowUp::collision(GameObject& other, const CollisionHit& hit
)
{
{
- if(other.get_flags() & FLAG_SOLID) {
- if(fabsf(hit.normal.y) > .5) { // roof or ground
- physic.set_velocity_y(0);
- } else { // bumped left or right
- physic.set_velocity_x(-physic.get_velocity_x());
- }
-
- return CONTINUE;
- }
-
Player* player = dynamic_cast<Player*>(&other);
if(player != 0) {
Player* player = dynamic_cast<Player*>(&other);
if(player != 0) {
- player->set_bonus(GROWUP_BONUS, true);
- sound_manager->play("sounds/grow.wav");
+ if(!player->add_bonus(GROWUP_BONUS, true)){
+ // Tux can't grow right now.
+ collision_solid( hit );
+ return ABORT_MOVE;
+ }
+
+ sound_manager->play("sounds/grow.ogg");
remove_me();
remove_me();
-
+
return ABORT_MOVE;
}
return ABORT_MOVE;
}
@@
-75,8
+73,7
@@
GrowUp::collision(GameObject& other, const CollisionHit& hit)
}
void
}
void
-GrowUp::d
raw(DrawingContext& context
)
+GrowUp::d
o_jump(
)
{
{
-
sprite->draw(context, get_pos(), LAYER_OBJECTS
);
+
physic.set_velocity_y(-300
);
}
}
-