Okay so what I have here lets me move fine altho it does not let me move flush against the wall.. and if walking between 2 wall tiles.. example: wall, non, non, wall u have to be perfectly in between the walls to move. Also only lets me move at speeds close to (16/16) i think.
Anyone have any suggestions on making movements twards a wall flush? And is there any way to output the collision points of a onwall2?
PHP Code:
//#CLIENTSIDE
function onCreated()
{
this.enabled = true;
setTimer(0.05);
if ( this.enabled == true )
{
disabledefmovement;
} else {
enabledefmovement;
}
}
function onTimeOut()
{
this.speed = (8/16);
for ( i=0; i < 4; i++ )
{
if ( keydown(i) )
{
temp.tw = ( abs(vecx( i )) == 1 ? 16 : 32 ) / 16;
temp.th = ( abs(vecy( i )) == 1 ? 16 : 32 ) / 16;
temp.aa = ( abs(vecy( i )) == 1 ? .5 : 0 );
temp.tx = player.x + 1 + vecx( i ) * 1 - temp.aa;
temp.ty = player.y + 1 + vecy( i ) * 1 + temp.aa;
if ( player.ani != "walk" && player.ani != "swim") {
setAni("walk", null);
}
if ( this.enabled == true )
{
player.dir = i;
temp.nx = player.x + vecx(i)*this.speed;
temp.ny = player.y + vecy(i)*this.speed;
if ( !onwall2( temp.tx, temp.ty, temp.tw, temp.th ) ) {
player.x = temp.nx;
player.y = temp.ny;
}
}
} else {
if ( !keydown(0) && !keydown(1) && !keydown(2) && !keydown(3) ) {
if ( !onwater( player.x, player.y ) ) {
setAni("idle", null);
}
}
}
}
if ( onwater( player.x, player.y ) ) {
if ( player.ani != "swim" ) {
setAni("swim", null);
}
}
setTimer( 0.05 );
// debug only
showpoly(200,{temp.tx,temp.ty,temp.tx+temp.tw,temp.ty,temp.tx+temp.tw,temp.ty+temp.th,temp.tx,temp.ty+temp.th});
changeimgcolors(200,1,0,0,.25);
}
Any help or suggestions appreciated.
PS: This is a rough draft. I know its sloppy but its readable non-the-less.