added first level
parent
ab3998c77c
commit
a086ac65ae
|
@ -1,18 +1,18 @@
|
||||||
wwwwwwwwwwwwwwwwwe
|
wwwwwwwwwwwwwwwwwe qwwwwwwwwwwwwwwwwe +wwwwwwwwwwwwwwe
|
||||||
sssssssssssssssssd
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
sssssssssssssssssd 1
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
sssssssssssssssssd
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
sssssssssssssssssd
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
sssssssssssssssssd 1 1lllllllll1 1 1
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
sssssssssssssssssd 1
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
sssssssssssssssssd
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
qe qe
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
u qwe ad ! ad qre
|
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
|
||||||
h k a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
|
sssssssssssssssssd asssssssssssssssstwwwwwwwwwwwe +ssssssssssssssd
|
||||||
sssssssssssssssssd m zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
|
sssssssssssssssssd zxxxxxxxxxxxxxxxxxxxxxxxxxxxftwwwwwwe qe +ssssssssssssssd
|
||||||
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
|
sssssssssssssssssd bb zxxxxxxxcooad h +ssssssssssssssd
|
||||||
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
|
sssssssssssssssssd qe q e bb ad +ssssssssssssssd
|
||||||
sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
|
sssssssssssssssssd ad qwwwrlllte bb ad +ssssssssssssssd
|
||||||
sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
|
sssssssssssssssssd ad asssssssste bb ad +ssssssssssssssd
|
||||||
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwek vvvvvvvvvvvvvvvvvvvvv + ad
|
sssssssssssssssssd ad ! qwrssssssssstwwwe bb ad h +ssssssssssssssd
|
||||||
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3
|
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrtwwwwwwwwwwwwwwwwrsssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwd
|
||||||
|
|
Binary file not shown.
|
@ -350,7 +350,6 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
// throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.drawString(player.xVelocity+"",400,400);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//call the move methods in other classes to update positions
|
//call the move methods in other classes to update positions
|
||||||
|
@ -424,6 +423,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
} else {
|
} else {
|
||||||
LevelManager.bombs = bombCount;
|
LevelManager.bombs = bombCount;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
player.resetNoSound();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
//the CPU runs our game code too quickly - we need to slow it down! The following lines of code "force" the computer to get stuck in a loop for short intervals between calling other methods to update the screen.
|
//the CPU runs our game code too quickly - we need to slow it down! The following lines of code "force" the computer to get stuck in a loop for short intervals between calling other methods to update the screen.
|
||||||
long lastTime = System.nanoTime();
|
long lastTime = System.nanoTime();
|
||||||
double amountOfTicks = 60;
|
double amountOfTicks = 60;
|
||||||
|
@ -451,7 +455,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
}
|
}
|
||||||
checkCollision();
|
checkCollision();
|
||||||
updateEnemy();
|
updateEnemy();
|
||||||
if(fireballCounter<0){fireballCounter = 100;}
|
if(fireballCounter<0){fireballCounter = 200;}
|
||||||
fireballCounter--;
|
fireballCounter--;
|
||||||
if(fireballCounter == 0){
|
if(fireballCounter == 0){
|
||||||
updateShootingBlock();
|
updateShootingBlock();
|
||||||
|
@ -541,7 +545,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
|
||||||
waitForDialogue = false;
|
waitForDialogue = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.keyPressed(e);
|
try {
|
||||||
|
player.keyPressed(e);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class GenericSprite extends Rectangle implements Serializable {
|
||||||
//called from GamePanel when any keyboard input is detected
|
//called from GamePanel when any keyboard input is detected
|
||||||
//updates the direction of the ball based on user input
|
//updates the direction of the ball based on user input
|
||||||
//if the keyboard input isn't any of the options (d, a, w, s), then nothing happens
|
//if the keyboard input isn't any of the options (d, a, w, s), then nothing happens
|
||||||
public void keyPressed(KeyEvent e){
|
public void keyPressed(KeyEvent e) throws IOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class LevelManager implements Serializable {
|
public class LevelManager implements Serializable {
|
||||||
public static int level = 1;
|
public static int level = 1;
|
||||||
public static int xSpawn = 0;
|
public static int xSpawn = -400;
|
||||||
public static int ySpawn = 600;
|
public static int ySpawn = 500;
|
||||||
|
|
||||||
public static String filePath;
|
public static String filePath;
|
||||||
|
|
||||||
|
@ -21,8 +21,9 @@ public class LevelManager implements Serializable {
|
||||||
GameFrame.game.player.xVelocity = 0;
|
GameFrame.game.player.xVelocity = 0;
|
||||||
LevelManager.level = level;
|
LevelManager.level = level;
|
||||||
if(level == 1){
|
if(level == 1){
|
||||||
xSpawn = 0;
|
//-400/500
|
||||||
ySpawn = 300;
|
xSpawn = -400;
|
||||||
|
ySpawn = 500;
|
||||||
filePath = "saves/Level1.txt";
|
filePath = "saves/Level1.txt";
|
||||||
bombs = 99999;
|
bombs = 99999;
|
||||||
} else if(level == 2){
|
} else if(level == 2){
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class Player extends GenericSprite {
|
||||||
|
|
||||||
|
|
||||||
// moves paddle when key is pressed
|
// moves paddle when key is pressed
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) throws IOException {
|
||||||
if(e.getKeyCode() == KeyEvent.VK_D){
|
if(e.getKeyCode() == KeyEvent.VK_D){
|
||||||
rightPressed = true;
|
rightPressed = true;
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,9 @@ public class Player extends GenericSprite {
|
||||||
if(e.getKeyCode() == KeyEvent.VK_S){
|
if(e.getKeyCode() == KeyEvent.VK_S){
|
||||||
downPressed = true;
|
downPressed = true;
|
||||||
}
|
}
|
||||||
|
if(e.getKeyCode() == KeyEvent.VK_R){
|
||||||
|
resetNoSound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// stops moving paddle when key is released
|
// stops moving paddle when key is released
|
||||||
|
@ -105,6 +108,9 @@ public class Player extends GenericSprite {
|
||||||
// calls parent
|
// calls parent
|
||||||
|
|
||||||
public boolean canUpdate(double x, double y) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
public boolean canUpdate(double x, double y) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
||||||
|
if(this.y+y<=-HEIGHT){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
boolean canUpdate = true;
|
boolean canUpdate = true;
|
||||||
int lowX = Math.max(0, ((GameFrame.game.camera.x+GamePanel.GAME_WIDTH)/Tile.length)-4);
|
int lowX = Math.max(0, ((GameFrame.game.camera.x+GamePanel.GAME_WIDTH)/Tile.length)-4);
|
||||||
int highX = Math.min(lowX + 8, GameFrame.game.map.length);
|
int highX = Math.min(lowX + 8, GameFrame.game.map.length);
|
||||||
|
@ -129,6 +135,7 @@ public class Player extends GenericSprite {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return canUpdate;
|
return canUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +193,7 @@ public class Player extends GenericSprite {
|
||||||
public void move() throws IOException, UnsupportedAudioFileException, LineUnavailableException {
|
public void move() throws IOException, UnsupportedAudioFileException, LineUnavailableException {
|
||||||
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
|
||||||
// mouseY = MouseInfo.getPointerInfo().getLocation().y;
|
// mouseY = MouseInfo.getPointerInfo().getLocation().y;
|
||||||
|
|
||||||
pickupDelay = Math.max(0,pickupDelay - 1);
|
pickupDelay = Math.max(0,pickupDelay - 1);
|
||||||
int Tilex = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
|
int Tilex = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
|
||||||
int Tiley = (mouseY / Tile.length);
|
int Tiley = (mouseY / Tile.length);
|
||||||
|
@ -279,6 +287,7 @@ public class Player extends GenericSprite {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
capSpeed();
|
capSpeed();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
public void reset() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
||||||
|
@ -288,7 +297,7 @@ public class Player extends GenericSprite {
|
||||||
y = LevelManager.ySpawn;
|
y = LevelManager.ySpawn;
|
||||||
holdingSteel = false;
|
holdingSteel = false;
|
||||||
}
|
}
|
||||||
public void resetNoSound() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
public void resetNoSound() throws IOException {
|
||||||
LevelManager.setLevel(LevelManager.level, true);
|
LevelManager.setLevel(LevelManager.level, true);
|
||||||
GameFrame.game.camera.x = LevelManager.xSpawn;
|
GameFrame.game.camera.x = LevelManager.xSpawn;
|
||||||
y = LevelManager.ySpawn;
|
y = LevelManager.ySpawn;
|
||||||
|
|
|
@ -1,11 +1,29 @@
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
import javax.sound.sampled.UnsupportedAudioFileException;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
import javax.sound.sampled.Clip;
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
public class SoundWrapper implements Serializable {
|
public class SoundWrapper implements Serializable {
|
||||||
transient public Sound sound;
|
transient public Sound sound;
|
||||||
public String soundString;
|
public String soundString;
|
||||||
|
|
||||||
|
public static Sound grass;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
grass = new Sound("sound/grass.wav");
|
||||||
|
} catch (UnsupportedAudioFileException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (LineUnavailableException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// please note that not as many constructors were implemented as BufferedImage, as this class was created before most sounds were added;
|
// please note that not as many constructors were implemented as BufferedImage, as this class was created before most sounds were added;
|
||||||
// as such, backwards compatibility was not needed
|
// as such, backwards compatibility was not needed
|
||||||
public SoundWrapper(String soundLocation) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
public SoundWrapper(String soundLocation) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
|
||||||
|
@ -37,4 +55,5 @@ public class SoundWrapper implements Serializable {
|
||||||
}
|
}
|
||||||
sound.start();
|
sound.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue