Merge remote-tracking branch 'origin/master'

master
John 2022-06-08 12:35:47 -04:00
commit bfa449e8a0
6 changed files with 70 additions and 5 deletions

View File

@ -14,5 +14,5 @@ sssssssssssssssssd bbb 1 zxc
sssssssssssssssssdbbbbbbbbbbbbbbbbbbbbbbb sssssssssssssssssdbbbbbbbbbbbbbbbbbbbbbbb
sssssssssssssssssd qwwwwwwwwe sssssssssssssssssd qwwwwwwwwe
sssssssssssssssssd qrsssssssstwe sssssssssssssssssd qrsssssssstwe
sssssssssssssssssd bbb qwwrssssssssssstwe qwe sssssssssssssssssd bbb qwwrssssssssssstwe qwe +
ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwww3 ssssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrsssssssssssssssstwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwrstwwwwww3

18
saves/Level3.txt Normal file
View File

@ -0,0 +1,18 @@
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

View File

@ -44,6 +44,7 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
public static Tile[][]map = new Tile[300][18]; public static Tile[][]map = new Tile[300][18];
public static ArrayList<NonPlayer>enemy = new ArrayList<NonPlayer>(); public static ArrayList<NonPlayer>enemy = new ArrayList<NonPlayer>();
public static ArrayList<Particle>particles = new ArrayList<Particle>();
public static StickyBomb b; public static StickyBomb b;
public static Camera camera; public static Camera camera;
@ -140,6 +141,13 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
} }
playerFrameCounter += player.draw(g, playerFrame); playerFrameCounter += player.draw(g, playerFrame);
b.draw(g); b.draw(g);
for(int i=0; i<particles.size(); i++){
particles.get(i).draw(g);
particles.get(i).lifeSpan--;
if(particles.get(i).lifeSpan<=0){
particles.remove(i);
}
}
g.drawString(camera.x+" "+((camera.x+GAME_WIDTH)/Tile.length),100,100); g.drawString(camera.x+" "+((camera.x+GAME_WIDTH)/Tile.length),100,100);
g.drawString(b.x+" "+((b.x+GamePanel.GAME_WIDTH)/Tile.length-4),100,200); g.drawString(b.x+" "+((b.x+GamePanel.GAME_WIDTH)/Tile.length-4),100,200);
} }
@ -152,6 +160,9 @@ public class GamePanel extends JPanel implements Runnable, KeyListener{
n.move(); n.move();
} }
b.move(); b.move();
for (Particle p: particles) {
p.move();
}
} }
//handles all collision detection and responds accordingly //handles all collision detection and responds accordingly

View File

@ -18,6 +18,10 @@ public class LevelManager {
xSpawn = 200; xSpawn = 200;
ySpawn = 0; ySpawn = 0;
filePath = "saves/Level2.txt"; filePath = "saves/Level2.txt";
} else if(level == 3){
xSpawn = 200;
ySpawn = 0;
filePath = "saves/Level3.txt";
} }
try { try {
MapReader.inputMap(filePath); MapReader.inputMap(filePath);

25
src/Particle.java Normal file
View File

@ -0,0 +1,25 @@
import java.awt.*;
public class Particle extends GenericSprite{
public static final int small = 3;
public static final int big = 10;
public int xVelocity;
public int yVelocity;
public int lifeSpan = 10;
public Particle(int x, int y, int xVelocity, int yVelocity){
super(x,y,(int)(Math.random()*(big-small+1))+3, (int)(Math.random()*(big-small+1))+3);
this.xVelocity = xVelocity;
this.yVelocity = yVelocity;
}
public void move(){
x+=xVelocity;
y+=yVelocity;
}
public void draw(Graphics g){
g.drawRect(x-GamePanel.camera.x,y,WIDTH,HEIGHT);
}
}

View File

@ -157,11 +157,18 @@ public class Player extends GenericSprite {
} }
if(rightPressed && xVelocity<5){ if(rightPressed){
xVelocity+=1; if(isGrounded){
GamePanel.particles.add(new Particle(x+GamePanel.camera.x+WIDTH/2,(int)(y+HEIGHT*0.8),3,3));
}
if(xVelocity<5) {
xVelocity += 1;
}
} }
if(leftPressed && xVelocity>-5) { if(leftPressed) {
xVelocity -= 1; if(xVelocity>-5) {
xVelocity -= 1;
}
} }
if(upPressed&isGrounded){ if(upPressed&isGrounded){
y-=1; y-=1;