public void tick() { if (hurtTime > 0) { hurtTime--; if (hurtTime == 0) { sprite.col = defaultColor; } } animTime++; sprite.tex = defaultTex + animTime / 10 % 2; move(); if (xa == 0 || za == 0) { rota += (random.nextGaussian() * random.nextDouble()) * 0.3; } rota += (random.nextGaussian() * random.nextDouble()) * spinSpeed; rot += rota; rota *= 0.8; xa *= 0.8; za *= 0.8; xa += Math.sin(rot) * 0.004 * runSpeed; za += Math.cos(rot) * 0.004 * runSpeed; }
protected void hurt(double xd, double zd) { sprite.col = Art.getCol(0xff0000); hurtTime = 15; double dd = Math.sqrt(xd * xd + zd * zd); xa += xd / dd * 0.2; za += zd / dd * 0.2; Sound.hurt2.play(); health--; if (health <= 0) { int xt = (int) (x + 0.5); int zt = (int) (z + 0.5); level.getBlock(xt, zt).addSprite(new PoofSprite(x - xt, 0, z - zt)); die(); remove(); Sound.kill.play(); } }