Ejemplo n.º 1
0
  @Override
  public void draw(Graphics2D g) {
    for (BBox box : walls) {
      camera.draw(box);
    }

    for (BBox box : platforms) {
      camera.draw(box);
    }

    camera.draw(character1);

    camera.drawCamera();
    if (black) {
      camera.drawClear(g);
      g.setColor(Color.WHITE);
    } else {
      camera.drawWhite(g);
    }
    g.setFont(g.getFont().deriveFont(Font.PLAIN, 12));
    g.drawString("Max speed: " + character1.getMaxSpeed(), 10, 10);
    g.drawString("Acceleration: " + character1.getAcceleration(), 10, 20);
    g.drawString("Friction: " + character1.getFriction(), 10, 30);
    g.drawString("Jump: " + character1.getJump(), 10, 40);
    g.drawString("Gravity: " + character1.getGravity(), 10, 50);
    g.drawString("----------------" + character1.getGravity(), 10, 60);
    g.drawString("Controls: ", 10, 70);
    g.drawString("--------", 10, 80);
    g.drawString("q, a, w, s, e, d", 10, 90);
    g.drawString("r, f, t, g, c, v, b", 10, 100);
  }
Ejemplo n.º 2
0
  @Override
  public void update() {
    Engine.setControlSpeeds(character1);
    for (BBox box : walls) {
      CollisionEngine.wallCollision(character1, box);
    }

    for (BBox box : platforms) {
      CollisionEngine.platformCollision(character1, box);
    }

    character1.move();

    camera.updateCamera();
  }
Ejemplo n.º 3
0
  @Override
  public void load() {
    BBox box = new BBox();
    box.setCoordinates(new Point(0, 0));
    box.setSize(new Dimensions(600, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(0, 600));
    box.setSize(new Dimensions(600, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(0, 30));
    box.setSize(new Dimensions(30, 570));
    box.setOffsets(new Dimensions(5, 0));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(570, 30));
    box.setSize(new Dimensions(30, 570));
    box.setOffsets(new Dimensions(5, 0));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(30, 500));
    box.setSize(new Dimensions(150, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(420, 500));
    box.setSize(new Dimensions(150, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(30, 100));
    box.setSize(new Dimensions(150, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(420, 100));
    box.setSize(new Dimensions(150, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(200, 400));
    box.setSize(new Dimensions(200, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(200, 200));
    box.setSize(new Dimensions(200, 30));
    box.setOffsets(new Dimensions(0, 5));
    walls.add(box);

    box = new BBox();
    box.setCoordinates(new Point(30, 300));
    box.setSize(new Dimensions(540, 30));
    box.setOffsets(new Dimensions(0, 5));
    platforms.add(box);

    character1.setCoordinates(new Point(100, 360));
    character1.setSize(new Dimensions(45, 45));
    character1.setOffsets(new Dimensions(7, 7));
    character1.setVector(new Point(0, 0));
    character1.setKeys(
        new int[] {
          KeyEvent.VK_LEFT, KeyEvent.VK_UP, KeyEvent.VK_RIGHT, KeyEvent.VK_DOWN, KeyEvent.VK_UP
        });
    character1.setAcceleration(0.15);
    character1.setMaxSpeed(3);
    character1.setFriction(0.3);
    character1.setJump(9);
    character1.setGravity(0.3);

    camera.setSize(new Dimensions(getWidth(), getHeight()));
    camera.setOffsets(new Dimensions(400, 200));

    setLoaded(true);
  }