Merge remote-tracking branch 'origin/master'

master
John 2022-06-19 14:21:31 -07:00
commit b5996f64c4
8 changed files with 115 additions and 60 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 359 B

View File

@ -12,7 +12,7 @@ sssssssssssssssssd
sssssssssssssssssd zxc asd asd zxxxxxc zxxxxxxxllllxxxxxxxxc ad
sssssssssssssssssd 1 zxc zxc vvvvvvvvwwwwvvvvvvvvv ad
sssssssssssssssssd qe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad 2 hqwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad 2 qwwwwwwwwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdlllllad bbb s qrsssslssstwe vvvvvvvvvvvvvvvvvvvvv ad
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
sssssssssssssssssdllllladbb s ooqwwrssssllssssstwe ! b h !!! qwe vvvvvvvvvvvvvvvvvvvvv + ad
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww3

View File

@ -3,20 +3,47 @@ import java.io.IOException;
public class FireBall extends GenericSprite{
public String spritePath;
public FireBall(int x, int y, int height, int width, int xv, int yv, String dir) {
private int realX;
public boolean dead;
public static final int height = 8;
public static final int width = 16;
public FireBall(int x, int y, int xv, int yv, String dir) {
super(x, y, height, width);
xVelocity = xv;
yVelocity = yv;
if(dir.equals("left")){
spritePath = "img/misc/flame/flameLeft.png";
}
realX = 0;
dead = false;
}
public void update(){
realX = x-GameFrame.game.camera.x;
}
public boolean collidePlayer(Player p){
if(realX+width>p.x&&realX<p.x+Player.PLAYER_WIDTH&&y-p.y<Player.PLAYER_HEIGHT&&p.y-y<height){
return true;
}
return false;
}
public void move(){
// x += xVelocity;
// y += yVelocity;
update();
if(canUpdate(xVelocity,yVelocity)) {
x += xVelocity;
y += yVelocity;
} else {
dead = true;
}
if(collidePlayer(GameFrame.game.player)){
dead = true;
GameFrame.game.player.reset();
}
}
public void draw(Graphics g) throws IOException {
//g.drawImage(GamePanel.getImage(spritePath),x-GameFrame.game.camera.x,y,null);
g.drawImage(GamePanel.getImage(spritePath),x-GameFrame.game.camera.x,y,null);
}
}

View File

@ -29,6 +29,8 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
//dimensions of window
public static final int GAME_WIDTH = 1225;
public static final int GAME_HEIGHT = 630;
public static final int fireballSpeed = 5;
public int bombCount;
public transient JPanel gameFrame;
@ -254,8 +256,15 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
}
}
for(int i=0; i<fireballs.size(); i++){
if(fireballs.get(i)!=null) {
fireballs.get(i).draw(g);
}
if(fireballs.get(i).dead){
fireballs.remove(i);
}
}
for(int i=0; i<particles.size(); i++){
// todo: find cause of particles being null
@ -267,7 +276,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
}
}
}
if(player.leftMouseDown){
if(player.leftMouseDown&&LevelManager.bombs>0&&!player.holdingSteel){
bombDir = new BombDirectionShow(this.player.x + this.camera.x + WIDTH/2, this.player.y+HEIGHT/2,
(player.mouseX - this.player.x) / 20, (player.mouseY - this.player.y) / 10);
@ -395,8 +404,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
now = System.nanoTime();
delta = delta + (now-lastTime)/ns;
lastTime = now;
// if(fireballCounter<0){fireballCounter = 20;}
// fireballCounter--;
//only move objects around and update screen if enough time has passed
if(delta >= 1){
if ((!isPaused && !isDialogue) && MenuPanel.gameStart) {
@ -408,7 +416,11 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
}
checkCollision();
updateEnemy();
//wwwwwwww
if(fireballCounter<0){fireballCounter = 100;}
fireballCounter--;
if(fireballCounter == 0){
updateShootingBlock();
}
try {
updateParticle();
} catch (IOException e) {
@ -455,7 +467,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener, Serializ
public void updateShootingBlock(){
for(Tile i: shootingTiles){
if(i.shootingDir.equals("left")){
//fireballs.add(new FireBall(i.x,i.y,80,41,-1,0,"left"));
fireballs.add(new FireBall(i.x-20,i.y+Tile.length/2-FireBall.height/2,-fireballSpeed,0,"left"));
}
}
}

View File

@ -10,6 +10,7 @@ Implements Runnable interface to use "threading" - let the game do two things at
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import javax.sound.sampled.LineUnavailableException;
@ -183,6 +184,16 @@ public class MenuPanel extends JPanel implements Runnable, KeyListener{
}
}
public static void deleteFiles(File dirPath) {
File filesList[] = dirPath.listFiles();
for(File file : filesList) {
if(file.isFile()) {
file.delete();
} else {
deleteFiles(file);
}
}
}
//if a key is released, we'll send it over to the Player class for processing
public void keyReleased(KeyEvent e){

View File

@ -14,7 +14,6 @@ import java.util.Arrays;
import java.util.LinkedList;
public class Player extends GenericSprite {
public final int SPEED = 5;
public static final int PLAYER_WIDTH = 52;
public static final int PLAYER_HEIGHT = 94;
@ -50,6 +49,11 @@ public class Player extends GenericSprite {
leftMouseDown = false;
holdingSteel = false;
canPlaceSteel = false;
rightPressed = false;
leftPressed = false;
upPressed= false;
downPressed = false;
isGrounded = false;
}
@ -126,12 +130,7 @@ public class Player extends GenericSprite {
return canUpdate;
}
// public boolean SteelCollide(GenericSprite g, int x, int y){
// if(x+WIDTH>tile.realX&&x<tile.realX+Tile.length&&y-tile.y<Tile.length&&tile.y-y<HEIGHT){
// return true;
// }
// return false;
// }
public void updatePlaceSteel(int x, int y){
if(this.y<0){
canPlaceSteel = false;
@ -248,7 +247,7 @@ public class Player extends GenericSprite {
xVelocity -= 1;
}
}
if(upPressed&isGrounded){
if(upPressed&&isGrounded&&!holdingSteel){
y-=1;
isGrounded = false;
if(canUpdate(0,-8)) {
@ -326,6 +325,7 @@ public class Player extends GenericSprite {
//TODO
public boolean canReach(int x, int y){
try {
int pX = (int) (((double) GameFrame.game.camera.x + GamePanel.GAME_WIDTH) / Tile.length);
int pY = (int) (((double) this.y + HEIGHT / 2) / Tile.length);
//System.out.println(pX+" "+pY);
@ -369,6 +369,9 @@ public class Player extends GenericSprite {
}
return false;
}catch(Exception e){
return false;
}
}
public void mouseDragged(MouseEvent e) {
@ -386,7 +389,7 @@ public class Player extends GenericSprite {
mouseY = e.getY();
if(e.getButton()==MouseEvent.BUTTON1) {
leftMouseDown = false;
if (GameFrame.game.bombs.size() < 3 && LevelManager.bombs>0) {
if (GameFrame.game.bombs.size() < 3 && LevelManager.bombs>0 && !holdingSteel) {
LevelManager.bombs--;
GameFrame.game.bombs.add(new StickyBomb(GameFrame.game.player.x + GameFrame.game.camera.x + WIDTH/2, GameFrame.game.player.y+HEIGHT/2,
(mouseX - GameFrame.game.player.x) / 20, (mouseY - GameFrame.game.player.y) / 10, GameFrame.game.bomb, GameFrame.game.explosionArray));

View File

@ -24,6 +24,8 @@ public class Tile implements Serializable {
public Tile previousBlock;
public String shootingDir;
public Tile(int x, int y){
isFinish = false;
collision = true;