I started working on a movement script which lets you steer using the left/right keys and accelerate with up/down.
It's meant for underwater/swimming movement.
Do you people think that it's usable, or should I change it's behaviour?
NPC Code:
//#CLIENTSIDE
if (created) {
this.playerdir = 1;
timeout = 0.05;
}
if (timeout) {
disabledefmovement;
// Steering left/right
// Changing the dir
if (keydown(1)) this.playerdir += 0.05;
if (keydown(3)) this.playerdir -= 0.05;
this.playerdir = this.playerdir%2;
// Calculating the actual angle
angle = 3.14159265 * this.playerdir;
// Displaying the current direction
showimg 0,@tempus sans itc@cb@X,playerx+1.5+xmove,playery+2+ymove;
// Accelerating
// Calculating current direction
xmove = sin(angle);
ymove = cos(angle);
// Adding speed into a direction
if (keydown(0)) {
this.xspeed += xmove/5;
this.yspeed += ymove/5;
}
if (keydown(2)) {
this.xspeed -= xmove/20;
this.yspeed -= ymove/20;
}
// Limiting the speed
if (this.xspeed>0.5) this.xspeed = 0.5;
if (this.yspeed>0.5) this.yspeed = 0.5;
if (this.xspeed<-0.5) this.xspeed = -0.5;
if (this.yspeed<-0.5) this.yspeed = -0.5;
// Moving the player
playerx += this.xspeed;
playery += this.yspeed;
// Slowing down a bit
this.xspeed *= 0.99;
this.yspeed *= 0.99;
// Displaying the speed
setplayerprop #c,#v(this.xspeed) #v(this.yspeed);
timeout = 0.05;
}