autostart main theme

This commit is contained in:
2025-11-27 17:28:41 +01:00
parent 9cf5c85727
commit 7502771f61
2 changed files with 69 additions and 2 deletions

View File

@@ -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();
}
}