I'll just post my code... JKWhoSaysNi, thanks, but that won't work with full angles (I think?)
PHP Code:
//#CLIENTSIDE
function onCreated()
{
this.speed = 2;
this.car = false;
setTimer( 0.05 );
}
function getMoveX()
{
return player.x + ( this.mspeed * sin( this.ang ) );
}
function getMoveY()
{
return player.y + ( this.mspeed * cos( this.ang ) );
}
function getMoveDX()
{
return player.x + ( 1 * sin( this.ang ) );
}
function getMoveDY()
{
return player.y + ( 1 * cos( this.ang ) );
}
function willCrash()
{
temp.movex = getMoveX();
temp.movey = getMoveY();
if ( onwall( temp.movex, temp.movey ) )
{
return true;
}
if ( onwall( temp.movex + 1, temp.movey ) )
{
return true;
}
if ( onwall( temp.movex - 1, temp.movey ) )
{
return true;
}
if ( onwall( temp.movex, temp.movey + 1 ) )
{
return true;
}
if ( onwall( temp.movex, temp.movey - 1 ) )
{
return true;
}
if ( onwall( temp.movex + 3, temp.movey ) )
{
return true;
}
if ( onwall( temp.movex - 2, temp.movey ) )
{
return true;
}
if ( onwall( temp.movex, temp.movey + 2 ) )
{
return true;
}
if ( onwall( temp.movex, temp.movey - 2 ) )
{
return true;
}
}
function doHonk()
{
player.attr[8] = "eb_sound-honk.gani";
scheduleevent( .2, "ClearHorn", "" );
}
function newCheck()
{
temp.movex = getMoveX();
temp.movey = getMoveY();
s1 = ( onwall2( temp.movex, temp.movey - abs(vecx(this.dir)),1,1)) ? 1: 0;
s2 = ( onwall2( temp.movey, y+vecy(this.dir)+vecy(this.dir)+abs(vecx(this.dir)*2),1,1)) ? 1: 0;
}
function onClearHorn()
{
player.attr[8] = "";
}
function setDir()
{
temp.movex = getMoveDX();
temp.movey = getMoveDY();
player.dir = getdir( temp.movex - player.x, temp.movey - player.y );
}
function checkCar()
{
player.attr[7] = this.ang;
client.car_angle = this.ang;
setAni( "sit", NULL );
disabledefmovement();
temp.movex = getMoveX();
temp.movey = getMoveY();
if ( keydown( 1 ) )
{
this.ang += .1;
setDir();
}
if ( keydown( 3 ) )
{
this.ang -= .1;
setDir();
}
if ( keydown2( 32, true ) )
{
doHonk();
}
if ( keydown( 2 ) )
{
if ( this.mspeed > -1 )
{
this.mspeed -= .2;
}
}
if ( keydown( 0 ) )
{
if ( this.mspeed < this.speed )
{
this.mspeed += .05;
}
}
else
{
if ( this.mspeed > 0 )
{
this.mspeed -= .1;
if ( this.mspeed < 0 )
{
this.mspeed = 0;
}
}
if ( this.mspeed < 0 )
{
this.mspeed += .1;
if ( this.mspeed > 0 )
{
this.mspeed = 0;
}
}
}
temp.movex = getMoveX();
temp.movey = getMoveY();
if ( willCrash() == false )
{
player.x = temp.movex;
player.y = temp.movey;
}
else
{
this.mspeed = - .5;
}
//player.chat = "Speed:" SPC this.mspeed;
//player.chat = format( "Angle: %s Move X: %s Move Y: %s", this.ang, temp.movex, temp.movey );
}
function onTimeOut()
{
if ( this.car == true )
{
checkCar();
player.attr[6] = "eb_car.gani";
}
else
{
player.attr[6] = "";
enabledefmovement();
}
setTimer( 0.05 );
}
function onPlayerChats()
{
if ( player.chat == "/car on" )
{
this.car = true;
}
if ( player.chat == "/car off" )
{
this.car = false;
}
}
That's not what the car will be like in the end, I just need the basic moving, turning, wall checking.