public void onStep() { super.onStep(); float rXOld = rX; float rYOld = rY; rX = rX - Math.signum(rX) * Game.getDeltaSeconds() * 250; rY = rY - Math.signum(rY) * Game.getDeltaSeconds() * 250; if (rXOld * rX < 0 || rYOld * rY < 0 || (rXOld == rX && rYOld == rY)) { rX = 0; rY = 0; if (path != null) { if (path.size() == 0) { // We made it to destination path = null; callback.execute(); } else { Node next = path.removeFirst(); rX = -(next.x - xcoord) * 16; rY = -(next.y - ycoord) * 16; xcoord = next.x; ycoord = next.y; x = xcoord * 16; y = ycoord * 16; } } } }
public void beginStep() { List<KeyboardEvent> keys = Game.getKeys(); if (Keyboard.isKeyDown(Keyboard.KEY_LEFT) && repeatTimers[2] == 0) { repeatTimers[2] = 0.12f; yesHover = !yesHover; AudioPlayer.playAudio("cursor2", 1, 1); } if (Keyboard.isKeyDown(Keyboard.KEY_RIGHT) && repeatTimers[3] == 0) { repeatTimers[3] = 0.12f; yesHover = !yesHover; AudioPlayer.playAudio("cursor2", 1, 1); } for (KeyboardEvent ke : keys) { if (ke.state) { if (ke.key == Keyboard.KEY_RETURN || ke.key == Keyboard.KEY_Z) { AudioPlayer.playAudio("select", 1, 1); if (yesHover) confirm(); else cancel(); destroy(); } if (ke.key == Keyboard.KEY_X) { AudioPlayer.playAudio("cancel", 1, 1); cancel(); destroy(); } } } for (int i = 0; i < repeatTimers.length; i++) { if (repeatTimers[i] > 0) { repeatTimers[i] -= Game.getDeltaSeconds(); if (repeatTimers[i] < 0) repeatTimers[i] = 0; } } }
@Override public void update() { super.update(); if (dodging) { dodgeTimer += Game.getDeltaSeconds(); if (dodgeTimer > DODGE_DURATION) { dodging = false; setSpeed(-DodgeAnimation.NORMAL_SPEED); } } }
public void render() { ClientOverworldStage cs = (ClientOverworldStage) stage; Renderer.translate(-cs.camX, -cs.camY); Renderer.addClip(0, 0, 368, 240, true); if (FEResources.hasTexture(functionalClassName().toLowerCase() + "_map_idle")) { Transform t = new Transform(); if (sprite.getAnimationName().equals("RIGHT")) { t.flipHorizontal(); t.setTranslation(14, 0); // Why do we have to do this? } Color mod = new Color(1.0f, 1.0f, 1.0f, 1.0f); t.setColor(mod); if (moved) { sprite.render(x + 1 + rX, y + 1 + rY, renderDepth, t, new ShaderArgs("greyscale")); } else { ShaderArgs args = PaletteSwapper.setup(this); sprite.render(x + 1 + rX, y + 1 + rY, renderDepth, t, args); } } else { Color c = !moved ? new Color(getPartyColor()) : new Color(128, 128, 128); Renderer.drawRectangle( x + 1 + rX, y + 1 + rY, x + 14 + rX, y + 14 + rY, ClientOverworldStage.UNIT_DEPTH, c); Renderer.drawString( "default_med", name.charAt(0) + "" + name.charAt(1), x + 2 + rX, y + 1 + rY, ClientOverworldStage.UNIT_DEPTH); } if (rescuedUnit != null) { counter += Game.getDeltaSeconds(); counter %= 1; if (counter > 0.5) { Renderer.render(rescue, 0, 0, 1, 1, x + 9, y + 7, x + 9 + 8, y + 7 + 8, renderDepth); } } Renderer.removeClip(); Renderer.translate(cs.camX, cs.camY); }