*/
if (k.check(KeyFlag.LEFT))
{
//this.setSpeed(new Vec2(-hSpeed, generator.nextFloat() ));
this.setSpeed(new Vec2(-hSpeed, 0f));
if(!isJumping) this.applySpeed(new Vec2(0f, (generator.nextFloat()-0.5f) *0.5f));
if(isRunning!=-1) this.directionX=-1;
isRunning = -1;
}
if (k.check(KeyFlag.RIGHT))
{
//this.setSpeed(new Vec2(hSpeed, generator.nextFloat()));
this.setSpeed(new Vec2(hSpeed, 0f));
if(!isJumping) this.applySpeed(new Vec2(0f,(generator.nextFloat()-0.5f)*0.5f ));
if(isRunning!=1) this.directionX=1;
isRunning = 1;
}
if (k.check(KeyFlag.JUMP) && !isJumping)
this.setSpeed(new Vec2(0, -jumpSpeed));
((ActionTimer)actions.getAction("jumptime")).active=true;
if (k.check(KeyFlag.FIRE))
{
this.gl.get(currentGunIndex).fire();
k.del(KeyFlag.FIRE);
isFiring=true;
((ActionTimer)actions.getAction("firetime")).active=true;
}
if (k.check(KeyFlag.SPECIAL)) {
specialMove(k);
}
if (k.check(KeyFlag.DOWN) && !isJumping ||(!k.check(KeyFlag.DOWN) && isBending)) {
Vec2 oldPos = getPosition().clone();
Vec2 oldSize = getSize().clone();
Vec2 newPos = new Vec2();
Vec2 newSize = new Vec2();
// Common.info(1,"DOWN: oldPOS="+getPosition()+" oldSIZE="+getSize());
PolygonShape newShape = new PolygonShape();
//bodydef = new BodyDef();
//level.delElement(this);
if (isBending) {
newPos = new Vec2(oldPos.x, oldPos.y + oldSize.y / 2f- standardSize.y / 2);
newSize = new Vec2(standardSize.x, standardSize.y);
isBending = false;
} else {
newPos = new Vec2(oldPos.x, oldPos.y + oldSize.y / 2f - reducedSize.y / 2);
newSize = new Vec2(reducedSize.x, reducedSize.y);
isBending = true;
}
// Common.info(1,"DOWN: oldPOS="+getPosition()+" oldSIZE="+getSize());
body.setTransform(newPos,0f);
body.destroyFixture(body.getFixtureList());
//body.resetMassData();
//FixtureDef fd = new FixtureDef();
setBoxShape(newSize.x, newSize.y);
//fd.shape=shape;
//body.createFixture(fd);
//setFixture(body.createFixture(fd));
setBody(body);
updateAABB();
k.del(KeyFlag.DOWN);
}
if (k.number()!=0) {
int n=k.number()-1;
if(gl.get(n)!=null) currentGunIndex=n;
}
if (k.Key == KeyFlag.NONE)
{
allKeysReleased();
applySpeed(new Vec2(-getSpeed().x,0));
isRunning = 0;
}
//Common.info(1,"bodu:"+body.isActive()+" mass:"+body.getMass()+ " waawakw"+body.isAwake());
}