Merge remote-tracking branch 'origin/master'

master
John 2022-06-19 17:31:20 -07:00
commit 2e3b2eb90b
7 changed files with 65 additions and 28 deletions

View File

@ -1,18 +1,18 @@
wwwwwwwwwwwwwwwwwe
sssssssssssssssssd
sssssssssssssssssd 1
sssssssssssssssssd
sssssssssssssssssd
sssssssssssssssssd 1 1lllllllll1 1 1
sssssssssssssssssd 1
sssssssssssssssssd
qe qe
u qwe ad ! ad qre
h k a d qwe qwe atwwwrd qwwwwwwellllqwwwwwwwe ad
sssssssssssssssssd m zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwek vvvvvvvvvvvvvvvvvvvvv + ad
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3
wwwwwwwwwwwwwwwwwe qwwwwwwwwwwwwwwwwe +wwwwwwwwwwwwwwe
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd assssssssssssssssd +ssssssssssssssd
sssssssssssssssssd asssssssssssssssstwwwwwwwwwwwe +ssssssssssssssd
sssssssssssssssssd zxxxxxxxxxxxxxxxxxxxxxxxxxxxftwwwwwwe qe +ssssssssssssssd
sssssssssssssssssd bb zxxxxxxxcooad h +ssssssssssssssd
sssssssssssssssssd qe q e bb ad +ssssssssssssssd
sssssssssssssssssd ad qwwwrlllte bb ad +ssssssssssssssd
sssssssssssssssssd ad asssssssste bb ad +ssssssssssssssd
sssssssssssssssssd ad ! qwrssssssssstwwwe bb ad h +ssssssssssssssd
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrtwwwwwwwwwwwwwwwwrsssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwd

BIN
sound/grass.wav Normal file

Binary file not shown.

View File

@ -369,7 +369,6 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
// throw new RuntimeException(e);
}
}
g.drawString(player.xVelocity+"",400,400);
}
//call the move methods in other classes to update positions
@ -443,6 +442,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
} else {
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.
long lastTime = System.nanoTime();
double amountOfTicks = 60;
@ -470,7 +474,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
}
checkCollision();
updateEnemy();
if(fireballCounter<0){fireballCounter = 100;}
if(fireballCounter<0){fireballCounter = 200;}
fireballCounter--;
if(fireballCounter == 0){
updateShootingBlock();
@ -560,7 +564,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
waitForDialogue = false;
}
} else {
try {
player.keyPressed(e);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}

View File

@ -40,7 +40,7 @@ public class GenericSprite extends Rectangle implements Serializable {
//called from GamePanel when any keyboard input is detected
//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
public void keyPressed(KeyEvent e){
public void keyPressed(KeyEvent e) throws IOException {
}

View File

@ -9,8 +9,8 @@ import java.util.Arrays;
public class LevelManager implements Serializable {
public static int level = 1;
public static int xSpawn = 0;
public static int ySpawn = 600;
public static int xSpawn = -400;
public static int ySpawn = 500;
public static String filePath;
@ -22,8 +22,9 @@ public class LevelManager implements Serializable {
GameFrame.game.player.xVelocity = 0;
LevelManager.level = level;
if(level == 1){
xSpawn = 0;
ySpawn = 300;
//-400/500
xSpawn = -400;
ySpawn = 500;
filePath = "saves/Level1.txt";
bombs = 99999;
} else if(level == 2){

View File

@ -59,7 +59,7 @@ public class Player extends GenericSprite {
// moves paddle when key is pressed
public void keyPressed(KeyEvent e) {
public void keyPressed(KeyEvent e) throws IOException {
if(e.getKeyCode() == KeyEvent.VK_D){
rightPressed = true;
}
@ -72,6 +72,9 @@ public class Player extends GenericSprite {
if(e.getKeyCode() == KeyEvent.VK_S){
downPressed = true;
}
if(e.getKeyCode() == KeyEvent.VK_R){
resetNoSound();
}
}
// stops moving paddle when key is released
@ -103,6 +106,9 @@ public class Player extends GenericSprite {
// calls parent
public boolean canUpdate(double x, double y) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
if(this.y+y<=-HEIGHT){
return false;
}
boolean canUpdate = true;
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);
@ -127,6 +133,7 @@ public class Player extends GenericSprite {
}
}
}
return canUpdate;
}
@ -184,6 +191,7 @@ public class Player extends GenericSprite {
public void move() throws IOException, UnsupportedAudioFileException, LineUnavailableException {
// mouseX = MouseInfo.getPointerInfo().getLocation().x;
// mouseY = MouseInfo.getPointerInfo().getLocation().y;
pickupDelay = Math.max(0,pickupDelay - 1);
int Tilex = (mouseX + GameFrame.game.camera.x + GamePanel.GAME_WIDTH / 2) / Tile.length;
int Tiley = (mouseY / Tile.length);
@ -277,6 +285,7 @@ public class Player extends GenericSprite {
reset();
}
capSpeed();
}
public void reset() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
@ -286,7 +295,7 @@ public class Player extends GenericSprite {
y = LevelManager.ySpawn;
holdingSteel = false;
}
public void resetNoSound() throws UnsupportedAudioFileException, LineUnavailableException, IOException {
public void resetNoSound() throws IOException {
LevelManager.setLevel(LevelManager.level, true);
GameFrame.game.camera.x = LevelManager.xSpawn;
y = LevelManager.ySpawn;

View File

@ -1,11 +1,29 @@
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
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 {
transient public Sound sound;
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;
// as such, backwards compatibility was not needed
public SoundWrapper(String soundLocation) throws UnsupportedAudioFileException, LineUnavailableException, IOException {
@ -37,4 +55,5 @@ public class SoundWrapper implements Serializable {
}
sound.start();
}
}