#### a_lone_

##### Member

Code:

```
//get input
yin = (keyboard_check(ord("S")) - keyboard_check(ord("W")));
xin = (keyboard_check(ord("A")) - keyboard_check(ord("D")));
inDir = point_direction(0,0,xin,yin);
//round small velocities to 0
if abs(vx) < 0.3 {
vx = 0;
}
if abs(vy) < 0.3 {
vy = 0;
}
//friction
vx -= kfrict*vx;
vy -= kfrict*vy;
//acceleration
ax = (((dcos(inDir))*abs(xin)*movespeed)/mass);
ay = (((dsin(inDir))*abs(yin)*movespeed)/mass);
aMag = point_distance(x,y,x+ax,y+ay);
aDir = point_direction(x,y,x+ax,y+ay);
if abs(vy+ay) <= abs(yin*vmax) and abs(vx+ax) <= abs(xin*vmax) {
vy += ay;
vx += ax;
} else if abs(vy+ay) <= abs(yin*vmax) {
vy += ay;
} else if abs(vx+ax) <= abs(xin*vmax) {
vx += ax;
} else if abs(vy + ay) < abs(vy) {
vy += ay;
} else if abs(vx + ax) < abs(vx) {
vx += ax;
}
//collisions and movement
if place_meeting(x-vx,y-vy,oWall) {
while !place_meeting(x-sign(vx),y-sign(vy),oWall) {
y-=sign(vy);
x-=sign(vx);
}
if !place_meeting(x,y-vy,oWall) {
y -= vy;
}
if !place_meeting(x-vx,y,oWall) {
x -= vx;
}
} else {
x -= vx;
y -= vy;
}
```