nice1, your version of intersection/setloc control is a tad easier to read than mine, thanks for the tip :D Here's my nightmare btw,
/**
* different locations gives different conditions, if the characters feet are inside the top half of a block(groundobject)
**/
public void checkFall()
{
int vy = getWorld().getHeight()-2;
if(getY() > vy)
{
death();
}
Actor ground1 = getOneObjectAtOffset(-xGround, yGround, Ground.class);
Actor ground2 = getOneObjectAtOffset(xGround, yGround, Ground.class);
if( ground1 != null)
{
vSpeed = 0;
if((getY()+getImage().getHeight()/2 > ground1.getY()-xGround) || (getY() > ground1.getY()+getImage().getHeight()/2 && onLadder()))
{
setLocation(getX(), ground1.getY()-ground1.getImage().getHeight()/2-getImage().getHeight()/2);
}
onGround = true;
}
else if( ground2 != null)
{
vSpeed = 0;
if(getY()+getImage().getHeight()/2 > ground2.getY()-xGround || (getY() > ground1.getY()+getImage().getHeight()/2 && onLadder()))
{
setLocation(getX(), ground2.getY()-ground2.getImage().getHeight()/2-getImage().getHeight()/2);
}
onGround = true;
}
Recent Comments | Show All
2014/1/13
Platformer Tutorial
2013/12/29
Snake Avoider