public Vector2f getScreenBowPosition() { float dx = -Sizes.BLOCK / 2; if (playerController.getPlayer().isLeftFaced()) { dx *= -1; } return new Vector2f( pointOfView.getWindowWidth() / 2 + dx, pointOfView.getWindowHeight() / 2 - Sizes.BLOCK / 2); }
public void listen(Input input, int delta) { /* if (KeyboardUtils.isDownPressed(input)) { player.setY(player.getY() + delta); } */ Rectangle belowPlayer = new Rectangle( player.getShape().getMinX(), player.getShape().getMaxY() + 2, player.getShape().getWidth(), 0); Iterator<AbstractBlock> sb = blocks.intersects(belowPlayer); boolean flying = !sb.hasNext(); if (KeyboardUtils.isUpPressed(input) && !flying) { player.getYMovement().setSpeed(-Player.JUMP_SPEED); } else { player.getYMovement().setAcceleration(Sizes.G); } if (KeyboardUtils.isLeftPressed(input)) { player.getXMovement().setAcceleration(-Player.X_ACCELERATION); } if (KeyboardUtils.isRightPressed(input)) { player.getXMovement().setAcceleration(Player.X_ACCELERATION); } float x = player.getXMovement().getPos(); float y = player.getYMovement().getPos(); player.update(delta); List<AbstractBlock> colliding_blocks = Collections3.getList(blocks.intersects(player.getShape())); for (AbstractBlock b : colliding_blocks) { HitResolver.resolve( player, player.getXMovement().getPos() - x, player.getYMovement().getPos() - y, b.getShape()); player.updateShape(); } for (AbstractBlock b : colliding_blocks) { Assert.assertThat(!player.getShape().intersects(b.getShape())); } pointOfView.setCenterX(Math.round(player.getShape().getCenterX())); pointOfView.setCenterY(Math.round(player.getShape().getCenterY())); }