public void checkground() { if (y < gameView.getHeight() - 64 - playerheight) { vspeed += gravity; if (y > gameView.getHeight() - 64 - playerheight - vspeed) { vspeed = gameView.getHeight() - 64 - y - playerheight; } } else if (vspeed > 0) { y = gameView.getHeight() - 64 - playerheight; vspeed = 0; } y += vspeed; }
/** * Constructor de la clase, posiciona al jugador al medio del mapa * * @param bmp Una imagen */ public Player(Bitmap bmp, GameView view, Map map, GPS gps) { super(bmp); this.health = 10; this.view = view; this.map = map; this.gps = gps; this.x = view.getWidth() / 2 - this.width / 2; this.y = view.getHeight() / 2 - this.height / 2; }
public void onTouch() { if (y >= gameView.getHeight() - 64 - playerheight) vspeed = jumppower; }
public TempSprite(List<TempSprite> temps, GameView gameView, float x, float y, Bitmap bmp) { this.x = Math.min(Math.max(x - bmp.getWidth() / 2, 0), gameView.getWidth() - bmp.getWidth()); this.y = Math.min(Math.max(y - bmp.getHeight() / 2, 0), gameView.getHeight() - bmp.getHeight()); this.bmp = bmp; this.temps = temps; }