ID:1800489
 
Problem description:

So I'm playing around with forum_account's sidescroller library and I'm using his spikes tiles code from the game-demo section. Below is a gif (terrible quality using gyazo) of what my problem is. Once i step onto the spikes my character sort of slides along of the floor and doesn't lock up the controls.

http://gyazo.com/80e82b47fa1e1f022c3e52a30e8d4255

Code:
//spikes code
turf
spikes
icon_state = "spikes"
New()
..()

var/obj/o = new /obj()
o.icon_state = "spikes-overlay"
o.layer = MOB_LAYER + 1
overlays += o

stepped_on(mob/m)
var/turf/t = locate(x,y+1,z)
if(istype(t,/turf/spikes))
m.die()

//die code
die()
if(dead) return

dead = 1

if(client)
src << "Ouch! You died!"

client.clear_input()
client.lock_input()

spawn(10)
loc = locate(2,5,1)
dead = 0
client.unlock_input()

// make enemies (mobs without clients) get deleted
else
spawn(20)
del src


Um, look at the game_demo folder, and check in mobs.dm to look for the way he has it working. In the die() procedure, you want to make sure it returns nothing if a npc steps on it by using if(!client) return, and not have it check if what's stepping on it is the client. You might want to clear input at the end of spawn too. Also, you almost always want to use set_pos instead of loc with his libs.

This is his die() proc I mentioned.

mob
proc
die()
if(dead) return

if(!client) return

src << "You died! You will respawn shortly."
dead = 1
client.clear_input()
client.lock_input()

spawn(20)
set_pos(32 * saved_location.x, 32 * saved_location.y)

client.clear_input()
client.unlock_input()
dead = 0
Alternatively, you can define how you want npcs to be dealt with under the if(!client) check too. But if that doesn't fix it, it's something other than what you shared with us.

Assuming your map format and icon size is 32x32, then set_pos() would come out to this:

set_pos(64, 160) //32x2 = 64 for the x_pixel 32x5 = 160 for your y_pixel
I already this, sorry probably should have mentioned it before hand. Anyways the die proc makes no difference to the issue.

Tried using the original pixel art from the demo too and it makes no difference. Gone through the code multiple times and I haven't changed anything regarding movement.
So i found the problem. The issue is down to the action procedure. Just an oversight on my part, but hey that's why I'm playing with it.

    action()

if(dead) return // i had this

if(dead) //i needed this.
slow_down()
return

if(boost > 0)
boost -= 1
if(client.keys[controls.jump])
vel_y += gravity

else
boost = 0
..()