projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
at the left or right end, it's obvious which dir we will go next
[supertux.git]
/
src
/
object
/
rock.cpp
diff --git
a/src/object/rock.cpp
b/src/object/rock.cpp
index
472e396
..
e5f10b3
100644
(file)
--- a/
src/object/rock.cpp
+++ b/
src/object/rock.cpp
@@
-64,6
+64,8
@@
Rock::update(float elapsed_time)
if( grabbed )
return;
if( grabbed )
return;
+ if (on_ground) physic.set_velocity_x(0);
+
movement = physic.get_movement(elapsed_time);
}
movement = physic.get_movement(elapsed_time);
}
@@
-104,17
+106,22
@@
void
Rock::grab(MovingObject& , const Vector& pos, Direction)
{
movement = pos - get_pos();
Rock::grab(MovingObject& , const Vector& pos, Direction)
{
movement = pos - get_pos();
+ last_movement = movement;
set_group(COLGROUP_DISABLED);
on_ground = true;
grabbed = true;
}
void
set_group(COLGROUP_DISABLED);
on_ground = true;
grabbed = true;
}
void
-Rock::ungrab(MovingObject& , Direction )
+Rock::ungrab(MovingObject& , Direction
dir
)
{
set_group(COLGROUP_MOVING_STATIC);
on_ground = false;
{
set_group(COLGROUP_MOVING_STATIC);
on_ground = false;
- physic.set_velocity(0, 0);
+ if (last_movement.norm() > 1) {
+ physic.set_velocity((dir == RIGHT) ? 200 : -200, -200);
+ } else {
+ physic.set_velocity(0, 0);
+ }
grabbed = false;
}
grabbed = false;
}