Package games.stendhal.client.entity

Examples of games.stendhal.client.entity.Player


    super(entity);
   
    if (entity instanceof User) {
      drawColor = COLOR_USER;
    } else if (entity instanceof Player) {
      final Player player = (Player) entity;

      choosePlayerColor(player);
     
      // Follow the ghost mode changes of other players
      entity.addChangeListener(new EntityChangeListener() {
View Full Code Here


   * @param g2d
   *            The graphics to drawn on.
   */
  @Override
  protected void draw(final Graphics2D g2d, final int x, final int y, final int width, final int height) {
    Player player = (Player) entity;
   
    boolean newIgnoreStatus = User.isIgnoring(player.getName());
    if (newIgnoreStatus != ignored) {
      visibilityChanged = true;
      ignored = newIgnoreStatus;
      markChanged();
    }
   
    super.draw(g2d, x, y, width, height);

    if (player.isAway()) {
      awaySprite.draw(g2d, x + (width * 3 / 4), y - 10);
    }
    if (player.isGrumpy()) {
      grumpySprite.draw(g2d, x - (width * 1 / 6), y - 6);
    }
    if (player.isBadBoy()) {
      skullSprite.draw(g2d, x , y);
    }
  }
View Full Code Here

   */
  @Test
  public void testCollidesEntity() throws Exception {
    final CollisionMap map = new CollisionMap(4, 4);
    map.set(1, 1);
    Player bob = new Player();
    PlayerTestHelper.generatePlayerRPClasses();
    StendhalRPRuleProcessor.get();
    MockStendlRPWorld.get();
    games.stendhal.server.entity.player.Player serverbob = games.stendhal.server.entity.player.Player
        .createZeroLevelPlayer("bob", null);
    serverbob.setPosition(0, 0);
    bob.initialize(serverbob);

    assertThat(bob.getWidth(), is(1.0));
    assertThat(bob.getWidth(), is(1.0));
    assertThat(bob.getX(), is(0.0));
    assertThat(bob.getY(), is(0.0));

    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(0, 1);
    bob.initialize(serverbob);
    assertThat(bob.getX(), is(0.0));
    assertThat(bob.getY(), is(1.0));

    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(0, 2);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(0, 3);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(1, 0);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(1, 1);
    bob.initialize(serverbob);
    assertTrue(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(1, 2);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(1, 3);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(2, 0);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(2, 1);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(2, 2);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(2, 3);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(3, 0);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(3, 1);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(3, 2);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));
    serverbob.setPosition(3, 3);
    bob.initialize(serverbob);
    assertFalse(map.collides((int) bob.getX(), (int) bob.getY(), (int) bob
        .getWidth(), (int) bob.getHeight()));

  }
View Full Code Here

   */
  private JButton createCharacterButton(final String name, final RPObject character) {
    // Abusing EntityView code to get the image of the player.
    // Avoid doing sound stuff. That is not available at this stage of
    // running the client.
    IEntity player = new Player() {
      @Override
      protected void onPosition(double x, double y) {
      }
      @Override
      protected void addSounds(String groupName, String categoryName, String... soundNames) {
      }
    };
    // Zero the coordinates, otherwise the EntityView will try to draw
    // itself to some weird place
    character.put("x", 0);
    character.put("y", 0);
    // ignore ghostmode for showing the image
    character.remove("ghostmode");
    // ignore player killer skull
    character.remove("last_player_kill_time");
    player.initialize(character);
   
    EntityView view = EntityViewFactory.create(player);
    // this if-block is there to be compatible with Stendhal 0.84 that is missing information
    Icon icon = null;
    if (view != null) {
View Full Code Here

    }
  }

  public boolean collides(final IEntity entity) {
    if (entity instanceof Player) {
      final Player player = (Player) entity;

      if (player.isGhostMode()) {
        return false;
      }
    }

    final Rectangle2D area = entity.getArea();
View Full Code Here

TOP

Related Classes of games.stendhal.client.entity.Player

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.