Compare commits
3 Commits
f3335f9df4
...
27ea2cb6d5
| Author | SHA1 | Date | |
|---|---|---|---|
|
27ea2cb6d5
|
|||
|
7502771f61
|
|||
|
9cf5c85727
|
BIN
assets/sounds/BlueBoyAdventure.wav
Normal file
BIN
assets/sounds/BlueBoyAdventure.wav
Normal file
Binary file not shown.
BIN
assets/sounds/Dungeon.wav
Normal file
BIN
assets/sounds/Dungeon.wav
Normal file
Binary file not shown.
BIN
assets/sounds/FinalBattle.wav
Normal file
BIN
assets/sounds/FinalBattle.wav
Normal file
Binary file not shown.
BIN
assets/sounds/Merchant.wav
Normal file
BIN
assets/sounds/Merchant.wav
Normal file
Binary file not shown.
BIN
assets/sounds/blocked.wav
Normal file
BIN
assets/sounds/blocked.wav
Normal file
Binary file not shown.
BIN
assets/sounds/burning.wav
Normal file
BIN
assets/sounds/burning.wav
Normal file
Binary file not shown.
BIN
assets/sounds/chipwall.wav
Normal file
BIN
assets/sounds/chipwall.wav
Normal file
Binary file not shown.
BIN
assets/sounds/coin.wav
Normal file
BIN
assets/sounds/coin.wav
Normal file
Binary file not shown.
BIN
assets/sounds/cursor.wav
Normal file
BIN
assets/sounds/cursor.wav
Normal file
Binary file not shown.
BIN
assets/sounds/cuttree.wav
Normal file
BIN
assets/sounds/cuttree.wav
Normal file
Binary file not shown.
BIN
assets/sounds/dooropen.wav
Normal file
BIN
assets/sounds/dooropen.wav
Normal file
Binary file not shown.
BIN
assets/sounds/fanfare.wav
Normal file
BIN
assets/sounds/fanfare.wav
Normal file
Binary file not shown.
BIN
assets/sounds/gameover.wav
Normal file
BIN
assets/sounds/gameover.wav
Normal file
Binary file not shown.
BIN
assets/sounds/hitmonster.wav
Normal file
BIN
assets/sounds/hitmonster.wav
Normal file
Binary file not shown.
BIN
assets/sounds/levelup.wav
Normal file
BIN
assets/sounds/levelup.wav
Normal file
Binary file not shown.
BIN
assets/sounds/parry.wav
Normal file
BIN
assets/sounds/parry.wav
Normal file
Binary file not shown.
BIN
assets/sounds/powerup.wav
Normal file
BIN
assets/sounds/powerup.wav
Normal file
Binary file not shown.
BIN
assets/sounds/receivedamage.wav
Normal file
BIN
assets/sounds/receivedamage.wav
Normal file
Binary file not shown.
BIN
assets/sounds/sleep.wav
Normal file
BIN
assets/sounds/sleep.wav
Normal file
Binary file not shown.
BIN
assets/sounds/speak.wav
Normal file
BIN
assets/sounds/speak.wav
Normal file
Binary file not shown.
BIN
assets/sounds/stairs.wav
Normal file
BIN
assets/sounds/stairs.wav
Normal file
Binary file not shown.
BIN
assets/sounds/unlock.wav
Normal file
BIN
assets/sounds/unlock.wav
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
package de.miaurizius.jgame2d.core;
|
||||
|
||||
import de.miaurizius.jgame2d.object.BootsObj;
|
||||
import de.miaurizius.jgame2d.object.ChestObj;
|
||||
import de.miaurizius.jgame2d.object.DoorObj;
|
||||
import de.miaurizius.jgame2d.object.KeyObj;
|
||||
@@ -40,6 +41,10 @@ public class AssetSetter {
|
||||
panel.obj[6] = new ChestObj();
|
||||
panel.obj[6].worldX = 10 * panel.tileSize;
|
||||
panel.obj[6].worldY = 7 * panel.tileSize;
|
||||
|
||||
panel.obj[7] = new BootsObj();
|
||||
panel.obj[7].worldX = 37 * panel.tileSize;
|
||||
panel.obj[7].worldY = 42 * panel.tileSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,17 +23,19 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
// WORLD SETTINGS
|
||||
public final int maxWorldCol = 50;
|
||||
public final int maxWorldRow = 50;
|
||||
public final int worldWidth = tileSize * maxWorldCol;
|
||||
public final int worldHeight = tileSize * maxWorldRow;
|
||||
|
||||
//FPS
|
||||
int FPS = 60;
|
||||
|
||||
// SYSTEM
|
||||
TileManager tileM = new TileManager(this);
|
||||
KeyHandler keyH = new KeyHandler();
|
||||
Sound sound = new Sound();
|
||||
Thread gameThread;
|
||||
public CollisionHandler collisionH = new CollisionHandler(this);
|
||||
public AssetSetter assetSetter = new AssetSetter(this);;
|
||||
|
||||
// ENTITY AND OBJECT
|
||||
public Player player = new Player(this, keyH);
|
||||
public SuperObject[] obj = new SuperObject[10];
|
||||
|
||||
@@ -47,6 +49,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
|
||||
public void setupGame() {
|
||||
assetSetter.setObject();
|
||||
playMusic(0); //Play main theme
|
||||
}
|
||||
|
||||
public void startGameThread() {
|
||||
@@ -98,4 +101,19 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
graphics.dispose();
|
||||
}
|
||||
|
||||
public void playMusic(int i) {
|
||||
sound.setFile(i);
|
||||
sound.play();
|
||||
sound.loop();
|
||||
}
|
||||
|
||||
public void stopMusic() {
|
||||
sound.stop();
|
||||
}
|
||||
|
||||
public void playSE(int i) {
|
||||
sound.setFile(i);
|
||||
sound.play();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
src/de/miaurizius/jgame2d/core/Sound.java
Normal file
49
src/de/miaurizius/jgame2d/core/Sound.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package de.miaurizius.jgame2d.core;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.Clip;
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class Sound {
|
||||
|
||||
Clip clip;
|
||||
URL[] soundURL = new URL[30];
|
||||
|
||||
public Sound() {
|
||||
try {
|
||||
soundURL[0] = new File("assets/sounds/BlueBoyAdventure.wav").toURI().toURL();
|
||||
soundURL[1] = new File("assets/sounds/coin.wav").toURI().toURL();
|
||||
soundURL[2] = new File("assets/sounds/powerup.wav").toURI().toURL();
|
||||
soundURL[3] = new File("assets/sounds/unlock.wav").toURI().toURL();
|
||||
soundURL[4] = new File("assets/sounds/fanfare.wav").toURI().toURL();
|
||||
} catch(MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setFile(int i) {
|
||||
try {
|
||||
AudioInputStream ais = AudioSystem.getAudioInputStream(soundURL[i]);
|
||||
clip = AudioSystem.getClip();
|
||||
clip.open(ais);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void play() {
|
||||
clip.start();
|
||||
}
|
||||
|
||||
public void loop() {
|
||||
clip.loop(Clip.LOOP_CONTINUOUSLY);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
clip.stop();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,15 +95,22 @@ public class Player extends Entity {
|
||||
if(index == 999) return;
|
||||
switch(panel.obj[index].name.toLowerCase()) {
|
||||
case "key":
|
||||
panel.playSE(1);
|
||||
hasKey++;
|
||||
panel.obj[index] = null;
|
||||
break;
|
||||
case "door":
|
||||
if(hasKey > 0) {
|
||||
panel.playSE(3);
|
||||
panel.obj[index] = null;
|
||||
hasKey--;
|
||||
}
|
||||
break;
|
||||
case "boots":
|
||||
panel.playSE(2);
|
||||
speed += 1;
|
||||
panel.obj[index] = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
18
src/de/miaurizius/jgame2d/object/BootsObj.java
Normal file
18
src/de/miaurizius/jgame2d/object/BootsObj.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package de.miaurizius.jgame2d.object;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BootsObj extends SuperObject {
|
||||
|
||||
public BootsObj() {
|
||||
name = "boots";
|
||||
try {
|
||||
image = ImageIO.read(new FileInputStream("assets/objects/boots.png"));
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user