public Janela(int width, int height, GLCanvas canvas) throws IOException {
    animator = new FPSAnimator(canvas, 240);
    setSize(new Dimension(width, height));
    setLocationRelativeTo(null);
    setMinimumSize(getSize());
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(canvas, BorderLayout.CENTER);
    getContentPane().add(panel);
    canvas.addGLEventListener(new GLWindow(panel, canvas));
    addWindowListener(
        new WindowAdapter() {

          @Override
          public void windowClosing(WindowEvent e) {
            super.windowClosing(
                e); // To change body of generated methods, choose Tools | Templates.
            animator.stop();
            System.out.println("Animação parou!");
          }
        });
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    setVisible(true);
    JDInfo info = new JDInfo(this, true);
    info.setVisible(true);
    animator.start();
    clip = Applet.newAudioClip(new File("./resources/Cabin.wav").toURL());
    clip.loop();
  }
  public static AudioClip reproducirSonido(AudioClip sonido, boolean loop) {
    if (loop) {
      sonido.loop();
    }

    sonido.play();

    return sonido;
  }
 /**
  * Plays an audio file (in .wav, .mid, or .au format) in a loop in a background thread.
  *
  * @param filename the name of the audio file
  */
 public void loop(String filename) {
   URL url = null;
   try {
     File file = new File(filename);
     if (file.canRead()) url = file.toURI().toURL();
   } catch (MalformedURLException e) {
     e.printStackTrace();
   }
   // URL url = StdAudio.class.getResource(filename);
   if (url == null) throw new RuntimeException("audio " + filename + " not found");
   AudioClip clip = Applet.newAudioClip(url);
   clip.loop();
 }
Beispiel #4
0
 /** Loop a sound file (in .wav or .au format) in a background thread. */
 public static void loop(String filename) {
   if (muted) {
     return;
   }
   URL url = null;
   try {
     File file = new File(filename);
     if (file.canRead()) url = file.toURI().toURL();
   } catch (MalformedURLException e) {
     e.printStackTrace();
   }
   // URL url = StdAudio.class.getResource(filename);
   if (url == null) throw new RuntimeException("audio " + filename + " not found");
   AudioClip clip = Applet.newAudioClip(url);
   clip.loop();
   notifyListeners(new AudioEvent(AudioEvent.Type.LOOP));
 }
  public void musicClicked() {
    // Mutes/unmutes music
    // checks to see if mute/unmute button is clicked
    if (muteB.clicked(mx, my, true) && pause == true && musicOn == true) {
      clickedSound();
      musicOn = false;
      clicked.stop();
      bckGrndMusic.stop();
      coinSound.stop();
      starSound.stop();
      bounce.stop();

    } else if (unmuteB.clicked(mx, my, true) && pause == true && musicOn == false) {
      clickedSound();
      musicOn = true;
      bckGrndMusic.loop();
    }
  }
  public BearSweeper() {
    super("BearSweeper");

    Container contentPane = getContentPane();
    panel = new DrawingPanel();
    contentPane.add(panel, BorderLayout.CENTER);

    timerOn = true;
    time = 0;
    timer = new Timer(100, new TimerEventHandler());

    Square.loadGraphics();
    addMenus();
    newGame();
    timer.start();

    // Loads and plays background music in a loop
    backgroundMusic = Applet.newAudioClip(getCompleteURL("background.wav"));
    backgroundMusic.loop();
  } // Constructor
Beispiel #7
0
  public void startGame() {

    bread.loop();
    gameOn = true;
    yellow.removeFromCanvas();
    pink.removeFromCanvas();
    purple.removeFromCanvas();
    green.removeFromCanvas();
    grey.removeFromCanvas();
    button.removeFromCanvas();
    author.removeFromCanvas();
    title.removeFromCanvas();

    start = new Location(canvas.getWidth() / 2, canvas.getHeight() / 2);
    theFish = new TheFish(fishPic, start, canvas, 50, 25);
    ocean = new Ocean(angryFishPic, angryFishL, bubblePic, canvas, theFish);

    score = new Text("Score: " + currentScore, 0, 0, canvas);
    score.setFontSize(16);
    score.moveTo((canvas.getWidth() - score.getWidth()) / 2, 50);

    bubbles = new Bubbles(dopeBubble, canvas);
  }
 public void loop() {
   myClip.loop();
 }
Beispiel #9
0
 public void start() {
   if (clip != null) {
     clip.loop();
   }
 }
Beispiel #10
0
 public void drive() {
   if (drivingClip != null) {
     drivingClip.loop();
   }
 }
Beispiel #11
0
 public void playSoundtrack() {
   if (soundTrack == null) return;
   soundTrack.loop();
 }
  public synchronized void loop() {

    if (audioClip != null) audioClip.loop();
  }
  public GamePanel(String name, int l) {
    setFocusable(true);
    grabFocus();
    addMouseListener(this);
    addMouseMotionListener(this);
    addKeyListener(this);
    keys = new boolean[10000];

    try {
      scoreFont =
          Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(new File("BRLNSB.ttf")))
              .deriveFont(0, 32);
    } catch (IOException ioe) {
      System.out.println("error loading BRLNSB.tff");
    } catch (FontFormatException ffe) {
      System.out.println("Something went wrong with the font.");
    }

    gameBckgrnd = new ImageIcon("Backgroundimage.png").getImage();
    for (int i = 1; i < 7; i++) {
      magnetList.add(new ImageIcon("gamelayerstuff/powerups/magnet" + i + ".png").getImage());
    }

    coinPic = new ImageIcon("gamelayerstuff/coins/byellowcoin1.png").getImage();
    player1 = new Player(200, 300, 100, "sheldon");

    click = false;
    ground = true;
    pause = false;
    lvlClear = false;
    die = false;
    musicOn = true;

    player1.setVelo(150);
    player1.setInvi(true);
    // ------------------------------------------------------------------------------------------------------------------------------------
    // Sound
    coinSound = Applet.newAudioClip(getClass().getResource("coin_pickup_2.wav"));
    clicked = Applet.newAudioClip(getClass().getResource("menu_deselect.wav"));
    starSound = Applet.newAudioClip(getClass().getResource("star.wav"));
    bounce = Applet.newAudioClip(getClass().getResource("grav_step_4.wav"));
    bckGrndMusic = Applet.newAudioClip(getClass().getResource("bgmusic00.wav"));
    bckGrndMusic.loop();
    // ------------------------------------------------------------------------------------------------------------------------------------

    // distance=0;
    score = 0;
    coins = 0;
    level = 1;
    prevLvl = level;
    backy = 0;
    height = backy;
    dieHeight = 0;
    dieMenuHeight = 0;

    pauseB = new SButton(400, 670, "pause", "");
    resumeB = new SButton(100, 500, "resume", "");
    menuB = new SButton(100, 620, "back", "");
    muteB = new SButton(400, 600, "mute", "");
    unmuteB = new SButton(400, 600, "unmute", "");
    // System.out.println("characters/"+name+"/"+name+"35.png");
  }
 public void startMusic() {
   // starts the background music
   bckGrndMusic.loop();
   on = true;
 }
 public void loop() {
   if (clip != null) clip.loop();
 }