B
BGamers11
Guest
I was trying to make a basic code of collision and movement, but I don't know why the code don't works, I already tried many times, using place_empty, place_free, but nothing works. The problem is that the character keeps floating in air, and it don't stops walking when I release a key. (Notes: Sprite Size is 16x50, but looks like it already "detect" a collision when I put y + 15, I think it searches for the collision box, not it's origin, also it don't detects collision with y + a number below 15)(It has 2 events: Create(with a single line: "gravity = 1;" and the Step Event, posted below):
Code:
if (y > room_height) {
x = 32;
y = 640;
}
if (vspeed > 12) {
vspeed = 12
}
if place_free(x, y + sprite_height) == false {
gravity = 0 }
else {
gravity = 1
}
if keyboard_check(vk_right) and hspeed == 0 {
hspeed = hspeed + 1 }
if keyboard_key_release(vk_right) and hspeed > 0 {
hspeed = hspeed - 1
}
if keyboard_check(vk_left) and hspeed == 0 {
hspeed = hspeed - 1 }
if keyboard_key_release(vk_left) and hspeed < 0 {
hspeed = hspeed + 1
}