示例#1
0
 public void keyReleased(KeyEvent e) {
   int key = e.getKeyCode();
   if (key == KeyEvent.VK_LEFT) hast.left = false;
   if (key == KeyEvent.VK_RIGHT) hast.right = false;
   if (key == KeyEvent.VK_UP) hast.up = false;
   if (key == KeyEvent.VK_DOWN) hast.down = false;
   if (key == KeyEvent.VK_SPACE) hast.jump = true;
 }
示例#2
0
  public void checkCollisions() {

    for (int i = 0; i < 20; i++) {
      if (hast.getBounds().intersects(box[i].getBounds())) {
        hast.collision = true;
        traff = true;
      } else if (traff == false) {
        hast.collision = false;
      }
    }
  }
示例#3
0
  public void drawBuffer() {
    Graphics2D b = buffer.createGraphics();

    b.setColor(Color.black);
    b.fillRect(0, 0, 800, 600);

    if (hast.collision == false) {
      b.setColor(Color.red);
      b.fillRect(hast.getX(), hast.getY(), hast.getWidth(), hast.getHeight());

      for (int i = 0; i < 20; i++) {
        b.setColor(Color.blue);
        b.fillRect(box[i].getX(), box[i].getY(), box[i].getWidth(), box[i].getHeight());
      }

      b.dispose();
    } else b.setColor(Color.white);
    b.drawString("Horsie is DEAD!!!!", 350, 300);
    b.dispose();
  }
示例#4
0
 public void update() {
   hast.move();
 }