コード例 #1
0
ファイル: fdg.java プロジェクト: ilangray/braun-and-blew
    private Rect getBounds() {
      if (bounds == null) {
        println("BOUNDS ARE NULL IN DIE CENTER PUSHER");
        System.exit(1);
      }
      float left = bounds.w;
      float top = bounds.h;
      float right = bounds.x;
      float bottom = bounds.y;

      for (Node n : nodes) {
        left = min(left, n.pos.x - n.radius);
        top = min(top, n.pos.y - n.radius);
        right = max(right, n.pos.x + n.radius);
        bottom = max(bottom, n.pos.y + n.radius);
      }

      return new Rect(left, top, right - left, bottom - top);
    }
コード例 #2
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
      public void executePlay() {
        println("play");

        isPlaying = true;
        startTime = System.nanoTime();
      }
コード例 #3
0
ファイル: GUI.java プロジェクト: BNHeadrick/AFM-GUI
      public void update() {

        if (isPlaying) {
          // only plays sound for dialog
          if (sMan.eventHappened(getPosInSeconds())) {
            // put sound code here!!!
            sMan.peekNextEvent().execute(getPosInSeconds());
            println(sMan.popEvent());
          }

          // find if previous dialog should still be playing, and if so, play it
          if (sMan.getPreviousPoppedDialog(getPosInSeconds()) != null) {
            sMan.getPreviousPoppedDialog(getPosInSeconds()).execute(getPosInSeconds());
            //          println(sMan.getPreviousPoppedDialog(getPosInSeconds()));
          }
        }

        if (overSlide()) {
          over = true;
        } else {
          over = false;
        }

        if (mousePressed && over) {
          locked = true;
        }
        if (!mousePressed) {
          locked = false;
        }
        if (locked) {
          newspos = constrain(mouseX - sheight / 2, sposMin, sposMax);
        }

        if (abs(newspos - spos) > 1 || isPlaying) {

          // if playback has collided with the end of the timeline, stop playing
          if (isPlaying) {
            if (getPosInSeconds() >= totalTime) {
              executePause();
            }
          }

          if (isPlaying) {
            long estimatedTime = System.nanoTime() - startTime;

            if (estimatedTime / 1000000000 >= 1) {
              // if one second has passed, make a new start time (reset the second timer)
              startTime = System.nanoTime();
              //            println("before spos is " + spos + " time is " + getPosInSeconds());
              spos = incrementSposInSeconds();
              println(
                  "spos is "
                      + spos
                      + " time is "
                      + getPosInSeconds()
                      + " frame is "
                      + getPosInFrames());
            }

          } else {
            spos = spos + (newspos - spos) / loose;
          }
        }
        // if the timeline is NOT playing, create the queue for the events to unfold in order
        if (!isPlaying) {
          sMan.createQueue(getPosInSeconds());
        }
        //      println(getPosInSeconds());

      }