E
EZTALES
Guest
hey yall,
needing some help with an ice block, here is the code. i want my player to slide on the block.
CREATE OF PLAYER:
///intialize varibles
grav = 0.7;
hspd = 0;
vspd = 0;
jumpspeed_normal = 8;
jumpspeed_powerup = 10;
jspd = jumpspeed_normal;
speed_normal = 5;
speed_powerup = 7;
spd = speed_normal;
// note that there is no physics in room, therefore do not turn on physics.
STEP:
if (vspd < 0) && (!key_jump_held) vspd = max(vspd,0)
//moving right
if (rkey) {
hspd = spd
}
//moving left
if (lkey) {
hspd = -spd
}
// check for not moving
if ((!rkey && !lkey) || (rkey && lkey)) {
hspd = 0;
}
//Horizontal collisions
if (place_meeting(x+hspd, y, obj_ice)) {
while (!place_meeting(x+sign(hspd), y, obj_ice)) {
x+= sign(hspd);
}
hspd = 0;
}
//move horizontally
x += hspd;
//vertical collisions
if (place_meeting(x, y+vspd, obj_ice)) {
while (!place_meeting(x, y+sign(vspd), obj_ice)) {
y+= sign(vspd);
}
vspd = 0;
}
//move vertically
y += vspd;
/// any help would be great! examples, etc.
needing some help with an ice block, here is the code. i want my player to slide on the block.
CREATE OF PLAYER:
///intialize varibles
grav = 0.7;
hspd = 0;
vspd = 0;
jumpspeed_normal = 8;
jumpspeed_powerup = 10;
jspd = jumpspeed_normal;
speed_normal = 5;
speed_powerup = 7;
spd = speed_normal;
// note that there is no physics in room, therefore do not turn on physics.
STEP:
if (vspd < 0) && (!key_jump_held) vspd = max(vspd,0)
//moving right
if (rkey) {
hspd = spd
}
//moving left
if (lkey) {
hspd = -spd
}
// check for not moving
if ((!rkey && !lkey) || (rkey && lkey)) {
hspd = 0;
}
//Horizontal collisions
if (place_meeting(x+hspd, y, obj_ice)) {
while (!place_meeting(x+sign(hspd), y, obj_ice)) {
x+= sign(hspd);
}
hspd = 0;
}
//move horizontally
x += hspd;
//vertical collisions
if (place_meeting(x, y+vspd, obj_ice)) {
while (!place_meeting(x, y+sign(vspd), obj_ice)) {
y+= sign(vspd);
}
vspd = 0;
}
//move vertically
y += vspd;
/// any help would be great! examples, etc.