コード例 #1
0
ファイル: TurretOne.java プロジェクト: eettlin/JRockOn
 public Bullet createBullet() {
   return new BulletOne(ImageCache.getImage("bullets/b1.png"));
 }
コード例 #2
0
 public BulletThree() {
   super(ImageCache.getImage("bullets/b3.png"), 10);
 }
コード例 #3
0
ファイル: PongPuck.java プロジェクト: pstorum/ani
  public PongPuck() {
    super(ImageCache.forClass(Pong.class).get("puck.png"));
    cmc = new ConstantMovementController(new Random().nextBoolean() ? 5 : -5, 0);
    addController(cmc);
    addListener(new BoundaryRemovalListener());
    setPrimitive(PrimitiveShape.CIRCLE);

    ParentBoundsListener bounce =
        new ParentBoundsListener() {
          @Override
          public void invoke(GObject target, Context context) {
            cmc.setVelocityY(-cmc.getVelocityY());
            double vx = cmc.getVelocityX();

            // Test the sign.
            if (vx > 0) {
              vx += 0.01;
            } else if (vx < 0) {
              vx -= 0.01;
            } else {
              // It's zero; do nothing.
            }

            // Set the velocity.
            cmc.setVelocityX(vx);
          }
        };

    bounce.setValidateHorizontal(false);
    addListener(bounce);

    HitTestListener htl =
        new HitTestListener(PongPaddle.class) {
          @Override
          public void invoke(GObject target, Context context) {

            flip();
            PongPaddleTwo paddle = context.hitTestClass(PongPaddleTwo.class).get(0);
            double offset = getY() - paddle.getY();
            double maxVelocity = getHeight();
            double newVelocity = cmc.getVelocityY() + offset * 0.1 - 0.05;
            if (newVelocity > maxVelocity) {
              newVelocity = maxVelocity;
            }
            cmc.setVelocityY(newVelocity);
          }
        };
    addListener(htl);
    HitTestListener htlTwo =
        new HitTestListener(PongPaddleTwo.class) {

          @Override
          public void invoke(GObject target, Context context) {

            flip();
            PongPaddleTwo paddle = context.hitTestClass(PongPaddleTwo.class).get(0);
            double offset = getY() - paddle.getY();
            double maxVelocity = getHeight();
            double newVelocity = cmc.getVelocityY() + offset * 0.1 - 0.05;
            if (newVelocity > maxVelocity) {
              newVelocity = maxVelocity;
            }
            cmc.setVelocityY(newVelocity);
          }
        };
    addListener(htlTwo);
  }
コード例 #4
0
ファイル: GameOverView.java プロジェクト: patrickclank9/Pong
 public GameOverView() {
   super(new GSprite(ImageCache.forClass(Pong.class).get("gameover.png")));
   ImageCache cache = ImageCache.forClass(Pong.class);
   Image image = cache.get("gameover.png");
   GSprite sprite = new GSprite(image);
 }