/**
 * Copyright 2007 Fred Sauer
 */
package com.allen_sauer.gwt.game.client.behavior;

import com.allen_sauer.gwt.game.client.Game;
import com.allen_sauer.gwt.game.client.sprite.player.PlayerSprite;
import com.allen_sauer.gwt.game.client.ui.util.Page;

public class PlayerMovementBehavior extends Behavior {
  private final Game game;
  private final PlayerSprite playerSprite;
  private final double xDelta = 0.2;
  private final double yDelta = 0.2;

  public PlayerMovementBehavior(PlayerSprite sprite) {
    super(sprite);
    playerSprite = sprite;
    game = sprite.getGame();
  }

  @Override
  public void doFirstFrame() {
    clientResized();
    //  setX(Random.nextInt(getXMax()));
    //  setY(Random.nextInt(getYMax()));
    setX(getXMax() / 2);
    setY(getYMax());
    super.doFirstFrame();
  }

  @Override
  public boolean doFrame(double millis) {
    if (game.input.isKeyboardMode()) {
      if (game.input.isKeyDown(Page.CODES.KEY_LEFT)) {
        setXSpeed(-xDelta);
      } else if (game.input.isKeyDown(Page.CODES.KEY_RIGHT)) {
        setXSpeed(xDelta);
      } else {
        setXSpeed(0);
      }

      if (game.input.isKeyDown(Page.CODES.KEY_UP)) {
        setYSpeed(-yDelta);
      } else if (game.input.isKeyDown(Page.CODES.KEY_DOWN)) {
        setYSpeed(yDelta);
      } else {
        setYSpeed(0);
      }
    } else {
      double x = game.input.getClickX() - playerSprite.getBulletStartOffsetX();
      double y = game.input.getClickY() - playerSprite.getBulletStartOffsetY();

      if (x < getX()) {
        setXSpeed(-xDelta);
      } else if (x > getX()) {
        setXSpeed(xDelta);
      } else {
        setXSpeed(0);
      }

      if (y < getY()) {
        setYSpeed(-yDelta);
      } else if (y > getY()) {
        setYSpeed(yDelta);
      } else {
        setXSpeed(0);
      }
    }
    return super.doFrame(millis);
  }
}

@@ -81,16 +81,66 @@
 avior;%0A%0A
+import com.google.gwt.event.dom.client.KeyCodes;%0A%0A
 import c
@@ -246,61 +246,8 @@
 ite;
-%0Aimport com.allen_sauer.gwt.game.client.ui.util.Page;
 %0A%0Apu
@@ -922,34 +922,32 @@
 t.isKeyDown(
-Page.CODES
+KeyCodes
 .KEY_LEFT)) 
@@ -1010,34 +1010,32 @@
 t.isKeyDown(
-Page.CODES
+KeyCodes
 .KEY_RIGHT))
@@ -1137,34 +1137,32 @@
 t.isKeyDown(
-Page.CODES
+KeyCodes
 .KEY_UP)) %7B%0A
@@ -1231,18 +1231,16 @@
 own(
-Page.CODES
+KeyCodes
 .KEY

replace deprecated key codes