level 4
This commit is contained in:
@@ -1,20 +1,20 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..P...............................................................................................................
|
||||||
...P
|
..................................................................................................................
|
||||||
...............E
|
..................................................................................................................
|
||||||
BBBBBBBB..BBBBBBBBBB
|
BBBBBBBBBB.....BBBBBB.............................................................................................................
|
||||||
|
|||||||
@@ -1,21 +1,29 @@
|
|||||||
..................................................................................................................
|
..................................................................................................................
|
||||||
..................................................................................................
|
..................................................................................................
|
||||||
..................................................................................................
|
..................................................................................................
|
||||||
..................................................................................................
|
....................Q.............................................................................
|
||||||
..................................................................................................
|
..................................................................................................
|
||||||
....................A.............................................................................
|
....................A.............................................................................
|
||||||
...................BBBBB..........................................................................
|
...................BBBBB.........................................................................
|
||||||
.................................BBBBB....................Q......................................
|
.
|
||||||
|
.
|
||||||
|
.................................BBBBB
|
||||||
|
..........................................................
|
||||||
.................................................A................................................
|
.................................................A................................................
|
||||||
..............................................BBBBBBBB....................................................
|
..............................................BBBBBBBB..
|
||||||
..........................................................BBBBB........................................
|
.
|
||||||
|
..................................................
|
||||||
|
..........................................................BBBBB..
|
||||||
|
......................................
|
||||||
.....................................................................BBBBBBBBBB....A............................A
|
.....................................................................BBBBBBBBBB....A............................A
|
||||||
..................................................................................BBBBB.....BBBBB............BBBBBBB.........E....................
|
..................................................................................BBBBB.....BBBBB............BBBBBBB.........E....................
|
||||||
.......................................................................................................................BBBBBBBB........................................
|
.......................................................................................................................BBBBBBBB........................................
|
||||||
.....................................................................................................A...................................................................
|
.....................................................................................................A...................................................................
|
||||||
....................................................................................................BBBBBB...........................A...........................
|
....................................................................................................BBBBBB...........................A...........................
|
||||||
...............................................................A.................................................................BBBBBBBB..............................
|
.................................................................................................................................BBBBBBBB........
|
||||||
|
...............................................................A
|
||||||
..P...................A..................BBBQBBBBB............BBBBBBBB.................BBBQBBBB....................................................................
|
..P...................A..................BBBQBBBBB............BBBBBBBB.................BBBQBBBB....................................................................
|
||||||
...............................................................................................................................................................
|
..............................................................................................
|
||||||
|
.................................................................
|
||||||
...............E.............A..............................................A........................................................................F......
|
...............E.............A..............................................A........................................................................F......
|
||||||
BBBBBBBB......BBBBBBBBBB....BBBBB...BBBBBBBBBBBBB........................BBBBBBBBBB.......BB................................................BBBBBBBBBB
|
BBBBBBBB......BBBBBBBBBB....BBBBB...BBBBBBBBBBBBB........................BBBBBBBBBB.......BB................................................BBBBBBBBBB
|
||||||
|
|||||||
@@ -1,20 +1,24 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
|
..................................................................................................................
|
||||||
|
..................................................................................................................
|
||||||
|
..................................................................................................................
|
||||||
|
..P................................................................................................................
|
||||||
|
..................................................................................................................
|
||||||
|
BBBBBBBBBBB..................................................................................................................
|
||||||
|
..................................................................................................................
|
||||||
|
....
|
||||||
|
....B.........................................B
|
||||||
|
....B.........................................B......................
|
||||||
|
....B.........................................B....................................................................
|
||||||
|
....B.........................................B....................................................................
|
||||||
|
....B.........................................B.....................................................................
|
||||||
|
....BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB..............................................................................................................
|
||||||
|
................................................
|
||||||
.
|
.
|
||||||
.
|
..................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
...................AAAAAAAAAAAAAAAAAA..........................F............................................
|
||||||
.
|
.................BBBBBBBBBBBBBBBBBBBBBBB.....BBBBBBBBBBBBBBBBBBBBB............................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
.
|
|
||||||
...P
|
|
||||||
...............E
|
|
||||||
BBBBBBBB..BBBBBBBBBB
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..P...............................................................................................................
|
||||||
...P
|
..................................................................................................................
|
||||||
...............E
|
..................................................................................................................
|
||||||
BBBBBBBB..BBBBBBBBBB
|
BBBBBBBBBB.....BBBBBB.............................................................................................................
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..P...............................................................................................................
|
||||||
...P
|
..................................................................................................................
|
||||||
...............E
|
..................................................................................................................
|
||||||
BBBBBBBB..BBBBBBBBBB
|
BBBBBBBBBB.....BBBBBB.............................................................................................................
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..P...............................................................................................................
|
||||||
...P
|
..................................................................................................................
|
||||||
...............E
|
..................................................................................................................
|
||||||
BBBBBBBB..BBBBBBBBBB
|
BBBBBBBBBB.....BBBBBB.............................................................................................................
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..P...............................................................................................................
|
||||||
...P
|
..................................................................................................................
|
||||||
...............E
|
..................................................................................................................
|
||||||
BBBBBBBB..BBBBBBBBBB
|
BBBBBBBBBB.....BBBBBB.............................................................................................................
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
.................................
|
..................................................................................................................
|
||||||
.................................
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..................................................................................................................
|
||||||
.
|
..P...............................................................................................................
|
||||||
...P
|
..................................................................................................................
|
||||||
...............E
|
..................................................................................................................
|
||||||
BBBBBBBB..BBBBBBBBBB
|
BBBBBBBBBB.....BBBBBB.............................................................................................................
|
||||||
|
|||||||
BIN
Platformer.class
BIN
Platformer.class
Binary file not shown.
@@ -3,6 +3,7 @@ import java.awt.event.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Random;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class Platformer extends JPanel implements KeyListener, ActionListener {
|
public class Platformer extends JPanel implements KeyListener, ActionListener {
|
||||||
@@ -16,7 +17,7 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
static final int MAXYVELO = 15;
|
static final int MAXYVELO = 15;
|
||||||
static final int MAXXVELO = 5;
|
static final int MAXXVELO = 5;
|
||||||
static final int totalLevels = 10;
|
static final int totalLevels = 10;
|
||||||
static int[] numAm = {4, 5, 10, 0, 0, 0, 0, 0, 0, 0};
|
static int[] numAm = {4, 5, 10, 18, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
// game objects
|
// game objects
|
||||||
Player player;
|
Player player;
|
||||||
@@ -30,6 +31,7 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
int boardWidth;
|
int boardWidth;
|
||||||
int boardHeight;
|
int boardHeight;
|
||||||
int tileSize;
|
int tileSize;
|
||||||
|
int enemiesKilled;
|
||||||
Timer gameTimer;
|
Timer gameTimer;
|
||||||
HashMap<Integer, Boolean> pressedKeys;
|
HashMap<Integer, Boolean> pressedKeys;
|
||||||
boolean jumpPressed;
|
boolean jumpPressed;
|
||||||
@@ -74,6 +76,7 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
cameraX = 0;
|
cameraX = 0;
|
||||||
cameraY = 0;
|
cameraY = 0;
|
||||||
currentLevel = 0;
|
currentLevel = 0;
|
||||||
|
enemiesKilled = 0;
|
||||||
numbers = new ArrayList<>();
|
numbers = new ArrayList<>();
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
numbers.add((new ImageIcon("Sprites/Numbers/" + i + ".png")).getImage());
|
numbers.add((new ImageIcon("Sprites/Numbers/" + i + ".png")).getImage());
|
||||||
@@ -104,6 +107,24 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
// gameloop
|
// gameloop
|
||||||
public void gameLoop() {
|
public void gameLoop() {
|
||||||
if (currentLevel > totalLevels) return;
|
if (currentLevel > totalLevels) return;
|
||||||
|
|
||||||
|
// lvl 3 arena
|
||||||
|
if (currentLevel == 4) {
|
||||||
|
if (enemiesKilled < 100 && enemies.isEmpty()) {
|
||||||
|
Random rand = new Random();
|
||||||
|
int xOff = rand.nextInt(700);
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
xOff = rand.nextInt(700);
|
||||||
|
if (xOff + 80 <= player.x && player.x <= xOff + 140) xOff += 60;
|
||||||
|
enemies.add(new Enemy(100 + xOff, 280, 20, 20, currentLevel));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (enemiesKilled >= 100) {
|
||||||
|
collidables.removeIf(c -> c.y == 300 && c.x >= 440 && c.x <= 520);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
cameraX = player.x - boardWidth / 2;
|
cameraX = player.x - boardWidth / 2;
|
||||||
cameraX = Math.max(0, cameraX);
|
cameraX = Math.max(0, cameraX);
|
||||||
@@ -282,6 +303,7 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
for (Enemy e : new ArrayList<>(enemies)) {
|
for (Enemy e : new ArrayList<>(enemies)) {
|
||||||
if (p.collidesWith(e)) {
|
if (p.collidesWith(e)) {
|
||||||
enemies.remove(e);
|
enemies.remove(e);
|
||||||
|
enemiesKilled++;
|
||||||
projectiles.remove(p);
|
projectiles.remove(p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -292,6 +314,7 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
|
|
||||||
public void loadLevel(int level) {
|
public void loadLevel(int level) {
|
||||||
projectiles.clear();
|
projectiles.clear();
|
||||||
|
enemiesKilled = 0;
|
||||||
try {
|
try {
|
||||||
LevelLoader.load(tileSize, collidables, collectables, enemies, flag, player, level);
|
LevelLoader.load(tileSize, collidables, collectables, enemies, flag, player, level);
|
||||||
player.reset();
|
player.reset();
|
||||||
@@ -335,6 +358,9 @@ public class Platformer extends JPanel implements KeyListener, ActionListener {
|
|||||||
if (currentLevel == 2) {
|
if (currentLevel == 2) {
|
||||||
g.drawString("Take a leap of faith....", flag.x - 25, flag.y - 400);
|
g.drawString("Take a leap of faith....", flag.x - 25, flag.y - 400);
|
||||||
}
|
}
|
||||||
|
if (currentLevel == 4) {
|
||||||
|
g.drawString("Kill 100 of them...", 220, 200);
|
||||||
|
}
|
||||||
// flag counter
|
// flag counter
|
||||||
int amOnes = player.numAmendments % 10;
|
int amOnes = player.numAmendments % 10;
|
||||||
int amTens = player.numAmendments / 10;
|
int amTens = player.numAmendments / 10;
|
||||||
|
|||||||
BIN
Player.class
BIN
Player.class
Binary file not shown.
@@ -46,6 +46,10 @@ public class Player extends Collidable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(int level) {
|
public void setLevel(int level) {
|
||||||
|
if (level >= 2) {
|
||||||
|
this.icon = new ImageIcon("Sprites/Player/2.png");
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.icon = new ImageIcon("Sprites/Player/" + level + ".png");
|
this.icon = new ImageIcon("Sprites/Player/" + level + ".png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
Projectile.class
BIN
Projectile.class
Binary file not shown.
@@ -4,7 +4,8 @@ public class Projectile extends Collidable {
|
|||||||
int xVelo;
|
int xVelo;
|
||||||
|
|
||||||
public Projectile(int x, int y, int w, int h, int curLevel, int direction) {
|
public Projectile(int x, int y, int w, int h, int curLevel, int direction) {
|
||||||
super(x, y, w, h, new ImageIcon("Sprites/Projectiles/" + curLevel + ".png"));
|
super(
|
||||||
|
x, y, w, h, new ImageIcon("Sprites/Projectiles/" + ((curLevel == 1) ? "1" : "2") + ".png"));
|
||||||
xVelo = 10 * direction;
|
xVelo = 10 * direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user