From e82120c35ea07e596075958fe5c0193032f32fc3 Mon Sep 17 00:00:00 2001
From: Fahim Bashar <74380584+Keilwerth11270@users.noreply.github.com>
Date: Wed, 31 May 2023 22:05:59 -0400
Subject: [PATCH] Created JAR and EXE
Created runnable files.
---
.idea/artifacts/SnakeGame_jar.xml | 8 ++++++++
.idea/workspace.xml | 16 ++++++++++++++--
SnakeGame.iml | 1 +
src/GamePanel.java | 19 ++++++++++---------
src/META-INF/MANIFEST.MF | 3 +++
{music => src/resources}/song.wav | Bin
6 files changed, 36 insertions(+), 11 deletions(-)
create mode 100644 .idea/artifacts/SnakeGame_jar.xml
create mode 100644 src/META-INF/MANIFEST.MF
rename {music => src/resources}/song.wav (100%)
diff --git a/.idea/artifacts/SnakeGame_jar.xml b/.idea/artifacts/SnakeGame_jar.xml
new file mode 100644
index 0000000..4b84591
--- /dev/null
+++ b/.idea/artifacts/SnakeGame_jar.xml
@@ -0,0 +1,8 @@
+
+
+ $PROJECT_DIR$/out/artifacts/SnakeGame_jar
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 660025f..2d3b98b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,12 +1,20 @@
+
+
+
+
+
-
+
+
+
+
@@ -38,7 +46,11 @@
diff --git a/SnakeGame.iml b/SnakeGame.iml
index c90834f..d5095d4 100644
--- a/SnakeGame.iml
+++ b/SnakeGame.iml
@@ -4,6 +4,7 @@
+
diff --git a/src/GamePanel.java b/src/GamePanel.java
index 776bff5..1234896 100644
--- a/src/GamePanel.java
+++ b/src/GamePanel.java
@@ -7,7 +7,7 @@
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
-import java.io.File;
+import java.net.URL;
import java.util.Random;
public class GamePanel extends JPanel implements ActionListener
@@ -26,7 +26,7 @@ public class GamePanel extends JPanel implements ActionListener
Timer timer;
Random random;
- String musicPath = "music/song.wav";
+ String musicPath = "/resources/song.wav";
Clip music;
int[] x = new int[GAME_UNITS];
@@ -70,15 +70,16 @@ private void PlayMusic(String musicPath)
{
try
{
- File musicFile = new File(musicPath);
- if(musicFile.exists())
+ URL sound = getClass().getResource(musicPath);
+ AudioInputStream audioInput = null;
+ if (sound != null)
{
- AudioInputStream audioInput = AudioSystem.getAudioInputStream(musicFile);
- music = AudioSystem.getClip();
- music.open(audioInput);
- music.start();
- music.loop(Clip.LOOP_CONTINUOUSLY);
+ audioInput = AudioSystem.getAudioInputStream(sound);
}
+ music = AudioSystem.getClip();
+ music.open(audioInput);
+ music.start();
+ music.loop(Clip.LOOP_CONTINUOUSLY);
}
catch (Exception e)
{
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..5ee19cb
--- /dev/null
+++ b/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: Main
+
diff --git a/music/song.wav b/src/resources/song.wav
similarity index 100%
rename from music/song.wav
rename to src/resources/song.wav