org.newdawn.slick.Sound.play()

Here are the examples of the java api org.newdawn.slick.Sound.play() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

19 Source : MouseOverArea.java
with MIT License
from OxideWaveLength

/**
 * Update the current normalImage based on the mouse state
 */
private void updateImage() {
    if (!over) {
        currentImage = normalImage;
        currentColor = normalColor;
        state = NORMAL;
        mouseUp = false;
    } else {
        if (mouseDown) {
            if ((state != MOUSE_DOWN) && (mouseUp)) {
                if (mouseDownSound != null) {
                    mouseDownSound.play();
                }
                currentImage = mouseDownImage;
                currentColor = mouseDownColor;
                state = MOUSE_DOWN;
                notifyListeners();
                mouseUp = false;
            }
            return;
        } else {
            mouseUp = true;
            if (state != MOUSE_OVER) {
                if (mouseOverSound != null) {
                    mouseOverSound.play();
                }
                currentImage = mouseOverImage;
                currentColor = mouseOverColor;
                state = MOUSE_OVER;
            }
        }
    }
    mouseDown = false;
    state = NORMAL;
}

19 Source : MouseOverArea.java
with GNU Lesser General Public License v3.0
from DrunkShulker

private void updateImage() {
    if (!over) {
        currentImage = normalImage;
        currentColor = normalColor;
        state = NORMAL;
        mouseUp = false;
    } else {
        if (mouseDown) {
            if ((state != MOUSE_DOWN) && (mouseUp)) {
                if (mouseDownSound != null) {
                    mouseDownSound.play();
                }
                currentImage = mouseDownImage;
                currentColor = mouseDownColor;
                state = MOUSE_DOWN;
                notifyListeners();
                mouseUp = false;
            }
            return;
        } else {
            mouseUp = true;
            if (state != MOUSE_OVER) {
                if (mouseOverSound != null) {
                    mouseOverSound.play();
                }
                currentImage = mouseOverImage;
                currentColor = mouseOverColor;
                state = MOUSE_OVER;
            }
        }
    }
    mouseDown = false;
    state = NORMAL;
}

17 Source : DeferredLoadingTest.java
with MIT License
from OxideWaveLength

/**
 * @see org.newdawn.slick.BasicGame#update(org.newdawn.slick.GameContainer, int)
 */
public void update(GameContainer container, int delta) throws SlickException {
    if (nextResource != null) {
        try {
            nextResource.load();
            // slow down loading for example purposes
            try {
                Thread.sleep(50);
            } catch (Exception e) {
            }
        } catch (IOException e) {
            throw new SlickException("Failed to load: " + nextResource.getDescription(), e);
        }
        nextResource = null;
    }
    if (LoadingList.get().getRemainingResources() > 0) {
        nextResource = LoadingList.get().getNext();
    } else {
        if (!started) {
            started = true;
            music.loop();
            sound.play();
        }
    }
}

17 Source : DeferredLoadingTest.java
with GNU Lesser General Public License v3.0
from DrunkShulker

public void update(GameContainer container, int delta) throws SlickException {
    if (nextResource != null) {
        try {
            nextResource.load();
            try {
                Thread.sleep(50);
            } catch (Exception e) {
            }
        } catch (IOException e) {
            throw new SlickException("Failed to load: " + nextResource.getDescription(), e);
        }
        nextResource = null;
    }
    if (LoadingList.get().getRemainingResources() > 0) {
        nextResource = LoadingList.get().getNext();
    } else {
        if (!started) {
            started = true;
            music.loop();
            sound.play();
        }
    }
}

14 Source : SoundTest.java
with MIT License
from OxideWaveLength

/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
    if (key == Input.KEY_ESCAPE) {
        System.exit(0);
    }
    if (key == Input.KEY_SPACE) {
        sound.play();
    }
    if (key == Input.KEY_B) {
        burp.play();
    }
    if (key == Input.KEY_A) {
        sound.playAt(-1, 0, 0);
    }
    if (key == Input.KEY_L) {
        sound.playAt(1, 0, 0);
    }
    if (key == Input.KEY_RETURN) {
        charlie.play(1.0f, 1.0f);
    }
    if (key == Input.KEY_P) {
        if (music.playing()) {
            music.pause();
        } else {
            music.resume();
        }
    }
    if (key == Input.KEY_C) {
        music.stop();
        if (music == musica) {
            music = musicb;
        } else {
            music = musica;
        }
        music.loop();
    }
    for (int i = 0; i < 3; i++) {
        if (key == Input.KEY_1 + i) {
            if (engines[i] != 0) {
                System.out.println("Stop " + i);
                SoundStore.get().stopSoundEffect(engines[i]);
                engines[i] = 0;
            } else {
                System.out.println("Start " + i);
                engines[i] = engine.playreplacedoundEffect(1, 1, true);
            }
        }
    }
    if (c == '+') {
        volume += 1;
        setVolume();
    }
    if (c == '-') {
        volume -= 1;
        setVolume();
    }
    if (key == Input.KEY_Y) {
        int vol = (int) (music.getVolume() * 10);
        vol--;
        if (vol < 0)
            vol = 0;
        // set individual volume of music
        music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_X) {
        int vol = (int) (music.getVolume() * 10);
        vol++;
        if (vol > 10)
            vol = 10;
        // set individual volume of music
        music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_N) {
        int vol = (int) (myContainer.getSoundVolume() * 10);
        vol--;
        if (vol < 0)
            vol = 0;
        // set global volume of sound fx
        myContainer.setSoundVolume(vol / 10.0f);
    }
    if (key == Input.KEY_M) {
        int vol = (int) (myContainer.getSoundVolume() * 10);
        vol++;
        if (vol > 10)
            vol = 10;
        // set global volume of sound fx
        myContainer.setSoundVolume(vol / 10.0f);
    }
}

14 Source : SoundTest.java
with GNU Lesser General Public License v3.0
from DrunkShulker

public void keyPressed(int key, char c) {
    if (key == Input.KEY_ESCAPE) {
        System.exit(0);
    }
    if (key == Input.KEY_SPACE) {
        sound.play();
    }
    if (key == Input.KEY_B) {
        burp.play();
    }
    if (key == Input.KEY_A) {
        sound.playAt(-1, 0, 0);
    }
    if (key == Input.KEY_L) {
        sound.playAt(1, 0, 0);
    }
    if (key == Input.KEY_RETURN) {
        charlie.play(1.0f, 1.0f);
    }
    if (key == Input.KEY_P) {
        if (music.playing()) {
            music.pause();
        } else {
            music.resume();
        }
    }
    if (key == Input.KEY_C) {
        music.stop();
        if (music == musica) {
            music = musicb;
        } else {
            music = musica;
        }
        music.loop();
    }
    for (int i = 0; i < 3; i++) {
        if (key == Input.KEY_1 + i) {
            if (engines[i] != 0) {
                System.out.println("Stop " + i);
                SoundStore.get().stopSoundEffect(engines[i]);
                engines[i] = 0;
            } else {
                System.out.println("Start " + i);
                engines[i] = engine.playreplacedoundEffect(1, 1, true);
            }
        }
    }
    if (c == '+') {
        volume += 1;
        setVolume();
    }
    if (c == '-') {
        volume -= 1;
        setVolume();
    }
    if (key == Input.KEY_Y) {
        int vol = (int) (music.getVolume() * 10);
        vol--;
        if (vol < 0)
            vol = 0;
        music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_X) {
        int vol = (int) (music.getVolume() * 10);
        vol++;
        if (vol > 10)
            vol = 10;
        music.setVolume(vol / 10.0f);
    }
    if (key == Input.KEY_N) {
        int vol = (int) (myContainer.getSoundVolume() * 10);
        vol--;
        if (vol < 0)
            vol = 0;
        myContainer.setSoundVolume(vol / 10.0f);
    }
    if (key == Input.KEY_M) {
        int vol = (int) (myContainer.getSoundVolume() * 10);
        vol++;
        if (vol > 10)
            vol = 10;
        myContainer.setSoundVolume(vol / 10.0f);
    }
}

13 Source : SoundURLTest.java
with MIT License
from OxideWaveLength

/**
 * @see org.newdawn.slick.BasicGame#keyPressed(int, char)
 */
public void keyPressed(int key, char c) {
    if (key == Input.KEY_ESCAPE) {
        System.exit(0);
    }
    if (key == Input.KEY_SPACE) {
        sound.play();
    }
    if (key == Input.KEY_B) {
        burp.play();
    }
    if (key == Input.KEY_A) {
        sound.playAt(-1, 0, 0);
    }
    if (key == Input.KEY_L) {
        sound.playAt(1, 0, 0);
    }
    if (key == Input.KEY_RETURN) {
        charlie.play(1.0f, 1.0f);
    }
    if (key == Input.KEY_P) {
        if (music.playing()) {
            music.pause();
        } else {
            music.resume();
        }
    }
    if (key == Input.KEY_C) {
        music.stop();
        if (music == musica) {
            music = musicb;
        } else {
            music = musica;
        }
        music.loop();
    }
    if (key == Input.KEY_E) {
        if (engine.playing()) {
            engine.stop();
        } else {
            engine.loop();
        }
    }
    if (c == '+') {
        volume += 1;
        setVolume();
    }
    if (c == '-') {
        volume -= 1;
        setVolume();
    }
}

13 Source : SoundURLTest.java
with GNU Lesser General Public License v3.0
from DrunkShulker

public void keyPressed(int key, char c) {
    if (key == Input.KEY_ESCAPE) {
        System.exit(0);
    }
    if (key == Input.KEY_SPACE) {
        sound.play();
    }
    if (key == Input.KEY_B) {
        burp.play();
    }
    if (key == Input.KEY_A) {
        sound.playAt(-1, 0, 0);
    }
    if (key == Input.KEY_L) {
        sound.playAt(1, 0, 0);
    }
    if (key == Input.KEY_RETURN) {
        charlie.play(1.0f, 1.0f);
    }
    if (key == Input.KEY_P) {
        if (music.playing()) {
            music.pause();
        } else {
            music.resume();
        }
    }
    if (key == Input.KEY_C) {
        music.stop();
        if (music == musica) {
            music = musicb;
        } else {
            music = musica;
        }
        music.loop();
    }
    if (key == Input.KEY_E) {
        if (engine.playing()) {
            engine.stop();
        } else {
            engine.loop();
        }
    }
    if (c == '+') {
        volume += 1;
        setVolume();
    }
    if (c == '-') {
        volume -= 1;
        setVolume();
    }
}