--- /dev/null
+(supertux-level\r
+ (version 2)\r
+ (name (_ "Ice test"))\r
+ (author "Mathnerd314")\r
+ (sector\r
+ (name "main")\r
+ (music "music/chipdisko.ogg")\r
+ (ambient-light 1 1 1)\r
+ (spawnpoint\r
+ (name "main")\r
+ (x 100)\r
+ (y 100)\r
+ )\r
+ (background\r
+ (speed 0.5)\r
+ (image "images/background/arctis.jpg")\r
+ )\r
+ (tilemap\r
+ (z-pos 0)\r
+ (solid #t)\r
+ (speed 1)\r
+ (width 27)\r
+ (height 19)\r
+ (tiles\r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+7 8 8 8 8 8 8 9 0 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 2406 \r
+13 14 14 14 14 14 14 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+10 11 11 11 11 11 11 12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \r
+ )\r
+ )\r
+\r
+ (camera\r
+ (mode "normal")\r
+ )\r
+ )\r
+)\r
/** instant velocity when tux starts to walk */
static const float WALK_SPEED = 100;
+ /** multiplied by WALK_ACCELERATION to give friction */
+ static const float NORMAL_FRICTION_MULTIPLIER = 1.5f;
+ /** multiplied by WALK_ACCELERATION to give friction */
+ static const float ICE_FRICTION_MULTIPLIER = 0.1f;
+ static const float ICE_ACCELERATION_MULTIPLIER = 0.25f;
+
/** time of the kick (kicking mriceblock) animation */
static const float KICK_TIME = .3f;
/** time of tux cheering (currently unused) */
backflip_direction = 0;
visible = true;
swimming = false;
+ on_ice = false;
+ ice_this_frame = false;
speedlimit = 0; //no special limit
on_ground_flag = false;
grabbed_object = NULL;
}
+ if(!ice_this_frame && on_ground())
+ on_ice = false;
+
on_ground_flag = false;
+ ice_this_frame = false;
// when invincible, spawn particles
if (invincible_timer.started() && !dying)
if ((on_ground()) && (fabs(physic.get_velocity_x()) < WALK_SPEED)) {
physic.set_velocity_x(0);
physic.set_acceleration_x(0);
- } else if(physic.get_velocity_x() < 0) {
- physic.set_acceleration_x(WALK_ACCELERATION_X * 1.5);
- } else if(physic.get_velocity_x() > 0) {
- physic.set_acceleration_x(WALK_ACCELERATION_X * -1.5);
+ } else {
+ float friction = on_ice ? (WALK_ACCELERATION_X * ICE_FRICTION_MULTIPLIER) :
+ (WALK_ACCELERATION_X * NORMAL_FRICTION_MULTIPLIER);
+ if(physic.get_velocity_x() < 0) {
+ physic.set_acceleration_x(friction);
+ } else /*if(physic.get_velocity_x() > 0)*/ {
+ physic.set_acceleration_x(-friction);
+ }
}
}
}
}
+ if(on_ice) {
+ ax *= ICE_ACCELERATION_MULTIPLIER;
+ }
+
physic.set_velocity(vx, vy);
physic.set_acceleration(ax, ay);
}
}
#endif
+
+ if(tile_attributes & (Tile::ICE | Tile::SOLID)) {
+ ice_this_frame = true;
+ on_ice = true;
+ }
}
void