コード例 #1
0
 @Override
 public int getPlayerRenderPosY() {
   return player.getRenderPosY();
 }
コード例 #2
0
  public DefaultGameContext(Level level, Settings settings) {
    LOGGER.info("Creating default game context");
    this.settings = settings;
    this.level = level;

    // TODO: test objects
    for (int i = 0; i < 20 + Math.random() * 4; i++) {
      GameObject object = new GameObject(GameObjectSpec.PHARAO);
      object.setAi(new SimpleAI());
      object.setAnimation(new FixedDurationAnimation(250, 4, true));
      object.pos =
          new Vect2d(
              Math.random() * level.bitmap.getWidth() - 100,
              Math.random() * level.bitmap.getHeight() - 100);
      object.delta = new Vect2d(VERY_SLOW, VERY_SLOW);
      objects.add(object);
    }

    for (int i = 0; i < 40 + Math.random() * 8; i++) {
      GameObject object = new GameObject(GameObjectSpec.MUMMY);
      object.setAi(new SimpleAI());
      object.setAnimation(new FixedDurationAnimation(200, 4, true));
      object.pos =
          new Vect2d(
              Math.random() * level.bitmap.getWidth() - 100,
              Math.random() * level.bitmap.getHeight() - 100);
      object.delta = new Vect2d(SLOW, SLOW);
      objects.add(object);
    }

    for (int i = 0; i < 5 + Math.random() * 15; i++) {
      GameObject object = new GameObject(GameObjectSpec.SNAKE);
      object.setAi(new SimpleAI());
      object.setAnimation(new FixedDurationAnimation(75, 4, true));
      object.pos =
          new Vect2d(
              Math.random() * level.bitmap.getWidth() - 100,
              Math.random() * level.bitmap.getHeight() - 100);
      object.delta = new Vect2d(VERY_FAST, VERY_FAST);
      objects.add(object);
    }

    player = new GameObject(GameObjectSpec.PLAYER);
    player.setAnimation(new FixedDurationAnimation(100, 6, true));
    player.pos = new Vect2d(0, 0);
    player.delta = new Vect2d(NORMAL, NORMAL);
    objects.add(player);
    objects.addAll(level.getGameObjects());
  }
コード例 #3
0
 @Override
 public GameContext dup() {
   DefaultGameContext ctx = new DefaultGameContext(level, settings);
   ctx.player.pos = player.pos;
   return ctx;
 }