function movement(gravityMov, speedMov, jumpMov, canDoubleJump, canWallJump, canDash) {
mask_index = Spr_duck;
function checkWallSlide(canWallJump) {
mask_index = Spr_wallJumpCol;
if (OnGround == 0) {
if (place_meeting(x, y, Obj_water) && canWallJump == 1) {
canWallSlide = 1;
sprite_index = Spr_duckHang;
dashable = 1;
Jumps = 1;
} else {
canWallSlide = 0;
sprite_index = Spr_duck;
}
} else {
canWallSlide = 0;
sprite_index = Spr_duck;
}
mask_index = Spr_duck;
}
if (!(keyboard_check(ord("M")))) {
JumpButtonPress = 0;
}
// 控制左到右
if (keyboard_check(ord("A"))) {
if (!(Velx < -2)) {
Velx -= speedMov;
DirFacing = -1;
}
}
if (keyboard_check(ord("D"))) {
if (!(Velx > 2)) {
Velx += speedMov;
DirFacing = 1;
}
}
if (keyboard_check(ord("N")) && canDash == 1 && dashable > 0) {
Velx += 10 * DirFacing;
Vely = 0;
dashable -= 1;
}
// 跳跃
if (keyboard_check(ord("M"))) {
checkWallSlide(canWallJump);
if (canWallSlide == 1) {
Vely = 0 - jumpMov;
DirFacing = 0 - DirFacing;
Velx = DirFacing * 4;
JumpButtonPress = 1;
canWallSlide = 0;
} else {
if (Jumps > 0) {
if (JumpButtonPress == 0) {
Vely = 0 - jumpMov;
Jumps -= 1;
JumpButtonPress = 1;
if (OnGround == 0) {
Velx = 0;
}
}
}
}
}
// 摩擦力
if (Velx > -0.5 && Velx < 0.5) {
Velx = 0;
}
if (Velx > 0.5) {
Velx -= FrictionPower;
}
if (Velx < -0.5) {
Velx += FrictionPower;
}
// 水平碰撞
mask_index = Spr_duck;
Pastx = x;
x += Velx;
if (place_meeting(x, y, Obj_water)) {
y += 1;
if (place_meeting(x, y, Obj_water)) {
y -= 1;
x = Pastx;
Velx = 0;
}
}
// 应用垂直运动
mask_index = Spr_duck;
Pasty = y;
y += Vely;
if (place_meeting(x, y, Obj_water)) {
y = Pasty;
y += 15;
if (place_meeting(x, y, Obj_water)) {
y = Pasty;
Vely = 0;
OnGround = 1;
Jumps = canDoubleJump;
dashable = 1;
} else {
Vely = 0;
show_debug_message("TOUCHING ROOF");
}
} else {
OnGround = 0;
if (canWallSlide == 1) {
Vely = 0;
} else {
Vely += gravityMov;
}
}
image_xscale = 2 * DirFacing;
checkWallSlide(canWallJump);
// 其他碰撞
mask_index = Spr_breadCol;
if (place_meeting(x, y, Obj_duck)) {
target = instance_position(x, y, Obj_duck);
if (target != -4 && target.object_index == Obj_duck) {
if (target.TouchingBread == 1) {
instance_destroy();
}
}
}
target = instance_position(x, y, Obj_bread);
if (target != -4) {
if (target.object_index == Obj_bread) {
instance_destroy(target);
global.Bread += 1;
}
}
image_xscale = 2 * DirFacing;
checkWallSlide(canWallJump);
}
评论 (0)