Beispiel #1
0
  public void assemble() {
    Input.addKeyListener(this);

    setFillColor(new Color(0, 0, 20));

    Collider colli = new Collider(this);
    colli.setRotationVelocity(0.01);

    for (int i = 0; i < 50; i++) new HelloWorld(this);

    Container rotorAquarium =
        new Container(this, 3 * getWidth() / 5, 0, 2 * getWidth() / 5, getHeight() / 2);
    rotorAquarium.setFillColor(new Color(0, 10, 40, 240));
    rotorAquarium.setDrawColor(Color.WHITE);
    for (int i = 0; i < 30; i++) new Rotor(rotorAquarium);

    Container colliderAquarium =
        new Container(this, 6 * getWidth() / 7, getHeight() / 2, getWidth() / 7, getHeight() / 5);

    colliderAquarium.setFillColor(new Color(50, 0, 30, 100));
    colliderAquarium.setDrawColor(Color.YELLOW);

    for (int i = 0; i < 10; i++) {
      Collider collider = new Collider(colliderAquarium);
      EntityInfoBox infobox =
          new EntityInfoBox(
              colliderAquarium,
              6 * getWidth() / 7 - EntityInfoBox.WIDTH - 1,
              getHeight() / 2 + i * (EntityInfoBox.HEIGHT + 1),
              collider);
      Link link = new Link(infobox, collider);
    }

    Container playerContainer = new Container(this, 50, 50, getWidth() / 2, 4 * getHeight() / 5);
    playerContainer.setFillColor(new Color(0, 30, 0, 50));
    playerContainer.setDrawColor(new Color(0, 130, 0));

    Player player = new Player(playerContainer);
    Input.addKeyListener(player);

    EntityInfoBox playerInfo = new EntityInfoBox(playerContainer, 1, 1, player);

    new Link(playerInfo, player);

    Container secondRotorContainer =
        new Container(this, getWidth() / 2 + 100, getHeight() / 2 + 50, 300, 400);

    secondRotorContainer.setFillColor(new Color(0, 0, 0, 180));
    secondRotorContainer.setDrawColor(Color.WHITE);

    Rotor rotor1 = new Rotor(secondRotorContainer);
    Rotor rotor2 = new Rotor(secondRotorContainer);
    Rotor rotor3 = new Rotor(secondRotorContainer);
    Link rotorLink1 = new Link(rotor1, rotor2);
    Link rotorLink2 = new Link(rotor2, rotor3);
    Link rotorLink3 = new Link(rotor3, rotor1);
  }
Beispiel #2
0
  public void update(GameContainer gc, StateBasedGame game, int delta) throws SlickException {
    resetSelectionBooleans();

    int x = input.getMouseX(), y = input.getMouseY();
    backgroundX = -419 * x / 528 - 1365;
    backgroundY = -533 * y / 300 - 1365;

    if (x > 455 && x < 600 && y > 260 && y < 300) hovering[0] = true;
    else if (x > 380 && x < 675 && y > 320 && y < 360) hovering[1] = true;
    else if (x > 455 && x < 600 && y > 380 && y < 420) hovering[2] = true;
  }
  public void display(GLAutoDrawable gLDrawable) {
    key = Input.keysPressed();

    double dt = (System.currentTimeMillis() - dt_timer) / 1000.0;
    dt_timer = System.currentTimeMillis();

    // Start 3d Rendering
    GL gl = gLDrawable.getGL();

    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

    gl.glLoadIdentity();

    GLU glu = new GLU();

    // Code to adjust camera
    if (input.getKey(KeyEvent.VK_UP)) z -= .5 * dt;
    if (input.getKey(KeyEvent.VK_DOWN)) z += .5 * dt;

    if (input.getKey(KeyEvent.VK_LEFT)) y -= .5 * dt;
    if (input.getKey(KeyEvent.VK_RIGHT)) y += .5 * dt;
    if (input.getKey(KeyEvent.VK_SPACE)) System.out.println(y + " " + z);

    glu.gluLookAt(0, y, z, 0, 0, -3, 0, 1, 0);

    // orangeNote.drawBar(gLDrawable, zTest);
    // redNote.draw(gLDrawable, -3f, -4f, zTest);
    // yellowNote.draw(gLDrawable, -1.5f, -4f, zTest);
    // blueNote.draw(gLDrawable, 0f, -4f, zTest);
    // greenNote.draw(gLDrawable, 1.5f, -4f, zTest);
    zTest += 0.005f;
    if (zTest > -2f) zTest = -10f;

    gl.glPushMatrix();
    gl.glEnable(GL.GL_BLEND);
    // gl.glRotatef(70,1,-2,1);

    gl.glBegin(GL.GL_QUADS);
    // Draw the Board
    // x goes basically from -1 to 1(camera changed tho)
    // y stays same
    // board length is -z
    gl.glColor4f(40 / 256f, 100 / 256f, 150 / 256f, 1f); // R,G,B,A
    gl.glVertex3f(-3f, -4f, 0f); // x,y,z

    gl.glColor4f(40 / 256f, 100 / 256f, 150 / 256f, 1f);
    gl.glVertex3f(3f, -4f, 0f);

    gl.glColor4f(60 / 256f, 150 / 256f, 200 / 256f, 0f);
    gl.glVertex3f(3f, -4f, -10f);

    gl.glColor4f(60 / 256f, 150 / 256f, 200 / 256f, 0f);
    gl.glVertex3f(-3f, -4f, -10f);

    // All y values on top of the Board must have at least
    // 0.0001f added for some reason
    // Bottom bar - Orange
    gl.glColor4f(255 / 256f, 165 / 256f, 0 / 256f, 1f);
    gl.glVertex3f(-3f, -4f + .0001f, -2.15f); // close left
    gl.glVertex3f(3f, -4f + .0001f, -2.15f); // close right
    gl.glVertex3f(3f, -4f + .0001f, -2.85f); // far right
    gl.glVertex3f(-3f, -4f + .0001f, -2.85f); // far left
    // RedNote
    gl.glColor4f(1f, 0f, 0f, 1f);
    gl.glVertex3f(-3f, -4f + .001f, -2.25f);
    gl.glVertex3f(-1.5f, -4f + .001f, -2.25f);
    gl.glVertex3f(-1.5f, -4f + .001f, -2.75f);
    gl.glVertex3f(-3f, -4f + .001f, -2.75f);
    // YellowNote
    gl.glColor4f(1f, 1f, 0f, 1f);
    gl.glVertex3f(-1.5f, -4f + .001f, -2.25f);
    gl.glVertex3f(0f, -4f + .001f, -2.25f);
    gl.glVertex3f(0f, -4f + .001f, -2.75f);
    gl.glVertex3f(-1.5f, -4f + .001f, -2.75f);
    // BlueNote
    gl.glColor4f(0f, 0f, 1f, 1f);
    gl.glVertex3f(0f, -4f + .001f, -2.25f);
    gl.glVertex3f(1.5f, -4f + .001f, -2.25f);
    gl.glVertex3f(1.5f, -4f + .001f, -2.75f);
    gl.glVertex3f(0f, -4f + .001f, -2.75f);
    // GreenNote
    gl.glColor4f(0f, 1f, 0f, 1f);
    gl.glVertex3f(1.5f, -4f + .001f, -2.25f);
    gl.glVertex3f(3f, -4f + .001f, -2.25f);
    gl.glVertex3f(3f, -4f + .001f, -2.75f);
    gl.glVertex3f(1.5f, -4f + .001f, -2.75f);
    // End Bottom Bar

    this.renderNotes(gLDrawable, dt);

    /////////////////////////////////////
    gl.glEnd();

    gl.glDisable(GL.GL_BLEND);
    gl.glPopMatrix();

    try {
      Thread.sleep(1);
    } catch (Exception e) {
    }
  }
Beispiel #4
0
 public void init(GameContainer gc, StateBasedGame game) throws SlickException {
   input = new Input(600);
   input.addListener(this);
 }