formatting
This commit is contained in:
BIN
Amendment.class
Normal file
BIN
Amendment.class
Normal file
Binary file not shown.
@@ -1,10 +1,8 @@
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
public class Amendment extends Collectable {
|
||||||
|
|
||||||
public class Amendment extends Collectable{
|
public Amendment(int x, int y, int w, int h) {
|
||||||
|
super(x, y, w, h, new ImageIcon("Sprites/Amendment.png"));
|
||||||
public Amendment(int x, int y, int w, int h){
|
}
|
||||||
super(x,y,w,h,new ImageIcon("Sprites/Amendment.png"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
BIN
Brick.class
Normal file
BIN
Brick.class
Normal file
Binary file not shown.
@@ -2,7 +2,7 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
public class Brick extends Tile {
|
public class Brick extends Tile {
|
||||||
|
|
||||||
public Brick(int x, int y, int w, int h){
|
public Brick(int x, int y, int w, int h) {
|
||||||
super(x,y,w,h,new ImageIcon("Sprites/Bricks/Brick.png"));
|
super(x, y, w, h, new ImageIcon("Sprites/Bricks/Brick.png"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Collectable.class
Normal file
BIN
Collectable.class
Normal file
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Collectable extends Collidable{
|
public class Collectable extends Collidable {
|
||||||
public Collectable(int x, int y, int w, int h,ImageIcon i){
|
public Collectable(int x, int y, int w, int h, ImageIcon i) {
|
||||||
super(x,y,w,h,i);
|
super(x, y, w, h, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Collidable.class
Normal file
BIN
Collidable.class
Normal file
Binary file not shown.
@@ -1,30 +1,30 @@
|
|||||||
|
import java.awt.Graphics;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import java.awt.Graphics;
|
|
||||||
|
|
||||||
public class Collidable extends Sprite{
|
public class Collidable extends Sprite {
|
||||||
int x,y,width,height;
|
int x, y, width, height;
|
||||||
Rectangle rect;
|
Rectangle rect;
|
||||||
|
|
||||||
public Collidable(int x1, int y1, int w, int h, ImageIcon icon){
|
public Collidable(int x1, int y1, int w, int h, ImageIcon icon) {
|
||||||
super(icon);
|
super(icon);
|
||||||
x = x1;
|
x = x1;
|
||||||
y = y1;
|
y = y1;
|
||||||
width = w;
|
width = w;
|
||||||
height = h;
|
height = h;
|
||||||
rect = new Rectangle(x1,y1,w,h);
|
rect = new Rectangle(x1, y1, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Graphics g){
|
public void draw(Graphics g) {
|
||||||
sprite = icon.getImage();
|
sprite = icon.getImage();
|
||||||
g.drawImage(sprite, x, y, width, height, null);
|
g.drawImage(sprite, x, y, width, height, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean collidesWith(Collidable other) {
|
public boolean collidesWith(Collidable other) {
|
||||||
return this.rect.intersects(other.rect);
|
return this.rect.intersects(other.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCollide(Collidable other){
|
public void onCollide(Collidable other) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Display.class
Normal file
BIN
Display.class
Normal file
Binary file not shown.
29
Display.java
29
Display.java
@@ -1,21 +1,20 @@
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public class Display {
|
public class Display {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int boardWidth = 800;
|
int boardWidth = 800;
|
||||||
int boardHeight = 800;
|
int boardHeight = 600;
|
||||||
int tileSize = 20;
|
int tileSize = 20;
|
||||||
|
|
||||||
JFrame game = new JFrame();
|
JFrame game = new JFrame();
|
||||||
game.setSize(boardWidth, boardHeight);
|
game.setSize(boardWidth, boardHeight);
|
||||||
game.setVisible(true);
|
game.setVisible(true);
|
||||||
game.setLocationRelativeTo(null);
|
game.setLocationRelativeTo(null);
|
||||||
game.setResizable(false);
|
game.setResizable(false);
|
||||||
|
|
||||||
|
Platformer platformer = new Platformer(boardWidth, boardHeight, tileSize);
|
||||||
Platformer platformer = new Platformer(boardWidth, boardHeight, tileSize);
|
game.add(platformer);
|
||||||
game.add(platformer);
|
game.pack();
|
||||||
game.pack();
|
platformer.requestFocus();
|
||||||
platformer.requestFocus();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BIN
Enemy.class
Normal file
BIN
Enemy.class
Normal file
Binary file not shown.
92
Enemy.java
92
Enemy.java
@@ -1,53 +1,53 @@
|
|||||||
import javax.swing.ImageIcon;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
public class Enemy extends Collidable{
|
import javax.swing.ImageIcon;
|
||||||
int xVelo, yVelo;
|
|
||||||
boolean alive;
|
|
||||||
|
|
||||||
public Enemy(int x, int y, int w, int h, int level){
|
public class Enemy extends Collidable {
|
||||||
super(x,y,w,h,new ImageIcon("Sprites/Enemies/" + level + ".png"));
|
int xVelo, yVelo;
|
||||||
xVelo = 2;
|
boolean alive;
|
||||||
yVelo = 0;
|
|
||||||
alive = true;
|
public Enemy(int x, int y, int w, int h, int level) {
|
||||||
|
super(x, y, w, h, new ImageIcon("Sprites/Enemies/" + level + ".png"));
|
||||||
|
xVelo = 2;
|
||||||
|
yVelo = 0;
|
||||||
|
alive = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveX(int moveX) {
|
||||||
|
this.x += moveX;
|
||||||
|
this.rect.x = this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveY(int moveY) {
|
||||||
|
this.y += moveY;
|
||||||
|
this.rect.y = this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void patrol(ArrayList<Collidable> collidables) {
|
||||||
|
moveX(xVelo);
|
||||||
|
|
||||||
|
for (Collidable c : collidables) {
|
||||||
|
if (this.collidesWith(c)) {
|
||||||
|
xVelo = -xVelo;
|
||||||
|
moveX(xVelo * 2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveX(int moveX){
|
// check edge detection - is there ground below next step?
|
||||||
this.x += moveX;
|
boolean edgeAhead = true;
|
||||||
this.rect.x = this.x;
|
int nextX = this.x + xVelo;
|
||||||
}
|
for (Collidable c : collidables) {
|
||||||
|
if (c instanceof Tile) {
|
||||||
public void moveY(int moveY){
|
Tile t = (Tile) c;
|
||||||
this.y += moveY;
|
// check if tile is below enemy's next position
|
||||||
this.rect.y = this.y;
|
if (nextX + this.width > t.x && nextX < t.x + t.width && t.y == this.y + this.height) {
|
||||||
}
|
edgeAhead = false;
|
||||||
|
break;
|
||||||
public void patrol(ArrayList<Collidable> collidables){
|
|
||||||
moveX(xVelo);
|
|
||||||
|
|
||||||
for (Collidable c : collidables){
|
|
||||||
if (this.collidesWith(c)){
|
|
||||||
xVelo = -xVelo;
|
|
||||||
moveX(xVelo * 2);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check edge detection - is there ground below next step?
|
|
||||||
boolean edgeAhead = true;
|
|
||||||
int nextX = this.x + xVelo;
|
|
||||||
for (Collidable c : collidables) {
|
|
||||||
if (c instanceof Tile) {
|
|
||||||
Tile t = (Tile) c;
|
|
||||||
// check if tile is below enemy's next position
|
|
||||||
if (nextX + this.width > t.x && nextX < t.x + t.width &&
|
|
||||||
t.y == this.y + this.height) {
|
|
||||||
edgeAhead = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (edgeAhead) {
|
|
||||||
xVelo = -xVelo;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (edgeAhead) {
|
||||||
|
xVelo = -xVelo;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BIN
Flag.class
Normal file
BIN
Flag.class
Normal file
Binary file not shown.
20
Flag.java
20
Flag.java
@@ -1,15 +1,15 @@
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Flag extends Collidable {
|
public class Flag extends Collidable {
|
||||||
public Flag(int x, int y, int w, int h) {
|
public Flag(int x, int y, int w, int h) {
|
||||||
super(x, y, w, h, new ImageIcon("Sprites/Flag.png"));
|
super(x, y, w, h, new ImageIcon("Sprites/Flag.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPosition(int x, int y, int w, int h) {
|
public void setPosition(int x, int y, int w, int h) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.width = w;
|
this.width = w;
|
||||||
this.height = h;
|
this.height = h;
|
||||||
this.rect.setBounds(x, y, w, h);
|
this.rect.setBounds(x, y, w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
LevelLoader.class
Normal file
BIN
LevelLoader.class
Normal file
Binary file not shown.
@@ -1,41 +1,59 @@
|
|||||||
import java.util.*;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class LevelLoader {
|
public class LevelLoader {
|
||||||
static int enemyWidth[] = {0,31,20,20,20,20,20,29,29,20,20};
|
static int enemyWidth[] = {0, 31, 20, 20, 20, 20, 20, 29, 29, 20, 20};
|
||||||
static int enemyHeight[] = {0,20,20,20,20,20,20,20,20,20,20};
|
static int enemyHeight[] = {0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20};
|
||||||
|
|
||||||
public static void load(int tileSize,
|
public static void load(
|
||||||
ArrayList<Collidable> collidables,
|
int tileSize,
|
||||||
ArrayList<Collectable> collectables,
|
ArrayList<Collidable> collidables,
|
||||||
ArrayList<Enemy> enemies,
|
ArrayList<Collectable> collectables,
|
||||||
Flag flag,
|
ArrayList<Enemy> enemies,
|
||||||
Player player, int level) throws IOException {
|
Flag flag,
|
||||||
collidables.clear();
|
Player player,
|
||||||
collectables.clear();
|
int level)
|
||||||
enemies.clear();
|
throws IOException {
|
||||||
|
collidables.clear();
|
||||||
|
collectables.clear();
|
||||||
|
enemies.clear();
|
||||||
|
|
||||||
/*left wall*/ collidables.add(new Brick(-20,0,20,2000));
|
/*left wall*/ collidables.add(new Brick(-20, 0, 20, 2000));
|
||||||
|
|
||||||
BufferedReader br = new BufferedReader(new FileReader("Levels/level" + level + ".txt"));
|
BufferedReader br = new BufferedReader(new FileReader("Levels/level" + level + ".txt"));
|
||||||
String line;
|
String line;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
for (int col = 0; col < line.length(); col++) {
|
for (int col = 0; col < line.length(); col++) {
|
||||||
char c = line.charAt(col);
|
char c = line.charAt(col);
|
||||||
int x = col * tileSize;
|
int x = col * tileSize;
|
||||||
int y = row * tileSize;
|
int y = row * tileSize;
|
||||||
switch(c) {
|
switch (c) {
|
||||||
case 'B': collidables.add(new Brick(x, y, tileSize, tileSize)); break;
|
case 'B':
|
||||||
case 'Q': collidables.add(new PowerBrick(x, y, tileSize, tileSize, 1)); break;
|
collidables.add(new Brick(x, y, tileSize, tileSize));
|
||||||
case 'A': collectables.add(new Amendment(x, y, tileSize, tileSize)); break;
|
break;
|
||||||
case 'F': flag.setPosition(x, y, tileSize, tileSize); break;
|
case 'Q':
|
||||||
case 'P': player.x = x; player.y = y; player.rect.x = x; player.rect.y = y; break;
|
collidables.add(new PowerBrick(x, y, tileSize, tileSize, 1));
|
||||||
case 'E': enemies.add(new Enemy(x,y,enemyWidth[level],enemyHeight[level],level)); break;
|
break;
|
||||||
}
|
case 'A':
|
||||||
}
|
collectables.add(new Amendment(x, y, tileSize, tileSize));
|
||||||
row++;
|
break;
|
||||||
|
case 'F':
|
||||||
|
flag.setPosition(x, y, tileSize, tileSize);
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
player.x = x;
|
||||||
|
player.y = y;
|
||||||
|
player.rect.x = x;
|
||||||
|
player.rect.y = y;
|
||||||
|
break;
|
||||||
|
case 'E':
|
||||||
|
enemies.add(new Enemy(x, y, enemyWidth[level], enemyHeight[level], level));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
br.close();
|
}
|
||||||
|
row++;
|
||||||
}
|
}
|
||||||
|
br.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -31,9 +31,9 @@
|
|||||||
.................................................................
|
.................................................................
|
||||||
.
|
.
|
||||||
.
|
.
|
||||||
.................................................
|
............E.....................................
|
||||||
........BBBBB.............A....................................................................
|
........BBBBB.............A....................................................................
|
||||||
.........................QBQQQQQBBBB
|
.........................QBQQQQQBBBB
|
||||||
....................................................................................................
|
....................................................................................................
|
||||||
.P.............E..............E...................E............................................................F..
|
.P............................E...................E............................................................F..
|
||||||
BBBBBBBBBBBBBBBBBB...BBBBBBBBBBBBBBBBB...BBBBBBBBBBBBBBBBBBB...BBBBBBB......................................BBBBBBBBBBBBBBBBBBBB
|
BBBBBBBBBBBBBBBBBB...BBBBBBBBBBBBBBBBB...BBBBBBBBBBBBBBBBBBB...BBBBBBB......................................BBBBBBBBBBBBBBBBBBBB
|
||||||
BIN
Platformer.class
Normal file
BIN
Platformer.class
Normal file
Binary file not shown.
875
Platformer.java
875
Platformer.java
@@ -1,489 +1,474 @@
|
|||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.io.*;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class Platformer extends JPanel implements KeyListener, ActionListener {
|
||||||
|
|
||||||
public class Platformer extends JPanel implements KeyListener, ActionListener{
|
// constants
|
||||||
|
static final int GRAVITY = 1;
|
||||||
|
static final Color playerColor = Color.RED;
|
||||||
|
static final Color tileColor = Color.BLUE;
|
||||||
|
static final Color SKY = new Color(135, 206, 235);
|
||||||
|
static final int FRICTION = 1;
|
||||||
|
static final int MAXYVELO = 15;
|
||||||
|
static final int MAXXVELO = 5;
|
||||||
|
static final int totalLevels = 10;
|
||||||
|
static int[] numAm = {4, 5, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
//constants
|
// game objects
|
||||||
static final int GRAVITY = 1;
|
Player player;
|
||||||
static final Color playerColor = Color.RED;
|
ArrayList<Collidable> collidables;
|
||||||
static final Color tileColor = Color.BLUE;
|
ArrayList<Collectable> collectables;
|
||||||
static final Color SKY = new Color(135, 206, 235);
|
Flag flag;
|
||||||
static final int FRICTION = 1;
|
ArrayList<Enemy> enemies;
|
||||||
static final int MAXYVELO = 15;
|
ArrayList<Projectile> projectiles;
|
||||||
static final int MAXXVELO = 5;
|
|
||||||
static final int totalLevels = 10;
|
|
||||||
static int[] numAm = {4,5,0,0,0,0,0,0,0,0};
|
|
||||||
|
|
||||||
//game objects
|
// game vars
|
||||||
Player player;
|
int boardWidth;
|
||||||
ArrayList<Collidable> collidables;
|
int boardHeight;
|
||||||
ArrayList<Collectable> collectables;
|
int tileSize;
|
||||||
Flag flag;
|
Timer gameTimer;
|
||||||
ArrayList<Enemy> enemies;
|
HashMap<Integer, Boolean> pressedKeys;
|
||||||
ArrayList<Projectile> projectiles;
|
boolean jumpPressed;
|
||||||
|
int cameraX, cameraY;
|
||||||
|
int currentLevel;
|
||||||
|
boolean allCollected;
|
||||||
|
boolean gameOver;
|
||||||
|
boolean gameStarted;
|
||||||
|
Image heart, emptyHeart, slash, amendmentImg, powerImg, pressRImg, endImg, winImg, titleImg;
|
||||||
|
ArrayList<Image> numbers;
|
||||||
|
|
||||||
//game vars
|
public Platformer(int boardWidth, int boardHeight, int tileSize) {
|
||||||
int boardWidth;
|
// setup game
|
||||||
int boardHeight;
|
this.boardWidth = boardWidth;
|
||||||
int tileSize;
|
this.boardHeight = boardHeight;
|
||||||
Timer gameTimer;
|
this.tileSize = tileSize;
|
||||||
HashMap<Integer,Boolean> pressedKeys;
|
setPreferredSize(new Dimension(this.boardWidth, this.boardHeight));
|
||||||
boolean jumpPressed;
|
addKeyListener(this);
|
||||||
int cameraX, cameraY;
|
this.setFocusable(true);
|
||||||
int currentLevel;
|
this.setLayout(null);
|
||||||
boolean allCollected;
|
|
||||||
boolean gameOver;
|
|
||||||
boolean gameStarted;
|
|
||||||
Image heart,emptyHeart,slash,amendmentImg,powerImg,pressRImg,endImg,winImg,titleImg;
|
|
||||||
ArrayList<Image> numbers;
|
|
||||||
|
|
||||||
|
pressedKeys = new HashMap<>();
|
||||||
|
jumpPressed = false;
|
||||||
|
gameOver = false;
|
||||||
|
gameStarted = false;
|
||||||
|
setBackground(SKY);
|
||||||
|
|
||||||
public Platformer(int boardWidth, int boardHeight, int tileSize){
|
// setup objects
|
||||||
//setup game
|
heart = new ImageIcon("Sprites/Hearts/heart.png").getImage();
|
||||||
this.boardWidth = boardWidth;
|
titleImg = new ImageIcon("Sprites/Title.png").getImage();
|
||||||
this.boardHeight = boardHeight;
|
emptyHeart = new ImageIcon("Sprites/Hearts/emptyHeart.png").getImage();
|
||||||
this.tileSize = tileSize;
|
endImg = new ImageIcon("Sprites/end.png").getImage();
|
||||||
setPreferredSize(new Dimension(this.boardWidth, this.boardHeight));
|
pressRImg = new ImageIcon("Sprites/PressR.png").getImage();
|
||||||
addKeyListener(this);
|
winImg = new ImageIcon("Sprites/win.png").getImage();
|
||||||
this.setFocusable(true);
|
gameTimer = new Timer(15, this);
|
||||||
this.setLayout(null);
|
player = new Player(-20, 0, tileSize, tileSize);
|
||||||
|
collidables = new ArrayList<>();
|
||||||
|
collectables = new ArrayList<>();
|
||||||
|
enemies = new ArrayList<>();
|
||||||
|
projectiles = new ArrayList<>();
|
||||||
|
flag = new Flag(-20, 0, tileSize, tileSize);
|
||||||
|
cameraX = 0;
|
||||||
|
cameraY = 0;
|
||||||
|
currentLevel = 0;
|
||||||
|
numbers = new ArrayList<>();
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
numbers.add((new ImageIcon("Sprites/Numbers/" + i + ".png")).getImage());
|
||||||
|
slash = new ImageIcon("Sprites/Numbers/Slash.png").getImage();
|
||||||
|
amendmentImg = new ImageIcon("Sprites/Amendment.png").getImage();
|
||||||
|
powerImg = new ImageIcon("Sprites/Powerup1.png").getImage();
|
||||||
|
|
||||||
|
gameTimer.start();
|
||||||
|
|
||||||
pressedKeys = new HashMap<>();
|
// if i wanna add a button
|
||||||
jumpPressed = false;
|
/*JButton gameStart = new JButton("Start Game");
|
||||||
gameOver = false;
|
gameStart.addActionListener(e -> {
|
||||||
gameStarted = false;
|
loadLevel(currentLevel);
|
||||||
setBackground(SKY);
|
|
||||||
|
|
||||||
//setup objects
|
|
||||||
heart = new ImageIcon("Sprites/Hearts/heart.png").getImage();
|
|
||||||
titleImg = new ImageIcon("Sprites/Title.png").getImage();
|
|
||||||
emptyHeart = new ImageIcon("Sprites/Hearts/emptyHeart.png").getImage();
|
|
||||||
endImg = new ImageIcon("Sprites/end.png").getImage();
|
|
||||||
pressRImg = new ImageIcon("Sprites/PressR.png").getImage();
|
|
||||||
winImg = new ImageIcon("Sprites/win.png").getImage();
|
|
||||||
gameTimer = new Timer(15,this);
|
|
||||||
player = new Player(-20,0,tileSize,tileSize);
|
|
||||||
collidables = new ArrayList<>();
|
|
||||||
collectables = new ArrayList<>();
|
|
||||||
enemies = new ArrayList<>();
|
|
||||||
projectiles = new ArrayList<>();
|
|
||||||
flag = new Flag(-20,0,tileSize,tileSize);
|
|
||||||
cameraX = 0;
|
|
||||||
cameraY = 0;
|
|
||||||
currentLevel = 0;
|
|
||||||
numbers = new ArrayList<>();
|
|
||||||
for (int i =0; i < 10; i++) numbers.add((new ImageIcon("Sprites/Numbers/" + i + ".png")).getImage());
|
|
||||||
slash = new ImageIcon("Sprites/Numbers/Slash.png").getImage();
|
|
||||||
amendmentImg = new ImageIcon("Sprites/Amendment.png").getImage();
|
|
||||||
powerImg = new ImageIcon("Sprites/Powerup1.png").getImage();
|
|
||||||
|
|
||||||
gameTimer.start();
|
gameTimer.start();
|
||||||
|
this.remove(gameStart);
|
||||||
|
this.revalidate();
|
||||||
|
this.repaint();
|
||||||
|
});
|
||||||
|
gameStart.setBorderPainted(false);
|
||||||
|
gameStart.setFocusPainted(false);
|
||||||
|
gameStart.setBounds(193,200,114,15);
|
||||||
|
gameStart.setForeground(new Color(52, 152, 219));
|
||||||
|
this.add(gameStart);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// gameloop
|
||||||
|
public void gameLoop() {
|
||||||
|
if (currentLevel > totalLevels) return;
|
||||||
|
// camera
|
||||||
|
cameraX = player.x - boardWidth / 2;
|
||||||
|
cameraX = Math.max(0, cameraX);
|
||||||
|
cameraY = player.y - boardHeight / 2;
|
||||||
|
// cameraY = Math.max(0, cameraY);
|
||||||
|
|
||||||
//if i wanna add a button
|
// win
|
||||||
/*JButton gameStart = new JButton("Start Game");
|
allCollected = player.numAmendments >= numAm[currentLevel - 1];
|
||||||
gameStart.addActionListener(e -> {
|
if (player.collidesWith(flag) && allCollected) {
|
||||||
loadLevel(currentLevel);
|
currentLevel++;
|
||||||
gameTimer.start();
|
player.health = 3;
|
||||||
this.remove(gameStart);
|
if (currentLevel > totalLevels) {
|
||||||
this.revalidate();
|
gameTimer.stop();
|
||||||
this.repaint();
|
System.out.println("You win!");
|
||||||
});
|
return;
|
||||||
gameStart.setBorderPainted(false);
|
} else {
|
||||||
gameStart.setFocusPainted(false);
|
loadLevel(currentLevel);
|
||||||
gameStart.setBounds(193,200,114,15);
|
}
|
||||||
gameStart.setForeground(new Color(52, 152, 219));
|
return;
|
||||||
this.add(gameStart);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//gameloop
|
// keys
|
||||||
public void gameLoop(){
|
if (Math.abs(player.xVelo) < MAXXVELO) {
|
||||||
if (currentLevel > totalLevels) return;
|
if (isKeyPressed(KeyEvent.VK_D) || isKeyPressed(KeyEvent.VK_RIGHT)) {
|
||||||
//camera
|
player.xVelo += 1;
|
||||||
cameraX = player.x - boardWidth / 2;
|
} else if (isKeyPressed(KeyEvent.VK_A) || isKeyPressed(KeyEvent.VK_LEFT)) {
|
||||||
cameraX = Math.max(0, cameraX);
|
player.xVelo -= 1;
|
||||||
cameraY = player.y - boardHeight / 2;
|
}
|
||||||
//cameraY = Math.max(0, cameraY);
|
}
|
||||||
|
if (!isKeyPressed(KeyEvent.VK_D)
|
||||||
|
&& !isKeyPressed(KeyEvent.VK_RIGHT)
|
||||||
|
&& !isKeyPressed(KeyEvent.VK_A)
|
||||||
|
&& !isKeyPressed(KeyEvent.VK_LEFT)) { // friction
|
||||||
|
if (player.xVelo > 0) {
|
||||||
|
player.xVelo = Math.max(0, player.xVelo - FRICTION);
|
||||||
|
} else if (player.xVelo < 0) {
|
||||||
|
player.xVelo = Math.min(0, player.xVelo + FRICTION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// jump
|
||||||
|
boolean jumpKeyDown = (isKeyPressed(KeyEvent.VK_W) || isKeyPressed(KeyEvent.VK_UP));
|
||||||
//win
|
if (jumpKeyDown && !jumpPressed) {
|
||||||
allCollected = player.numAmendments >= numAm[currentLevel-1];
|
if (player.onGround) {
|
||||||
if (player.collidesWith(flag) && allCollected) {
|
player.yVelo = -15;
|
||||||
currentLevel++;
|
|
||||||
player.health = 3;
|
|
||||||
if (currentLevel > totalLevels) {
|
|
||||||
gameTimer.stop();
|
|
||||||
System.out.println("You win!");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
loadLevel(currentLevel);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//keys
|
|
||||||
if (Math.abs(player.xVelo) < MAXXVELO){
|
|
||||||
if(isKeyPressed(KeyEvent.VK_D) || isKeyPressed(KeyEvent.VK_RIGHT)){
|
|
||||||
player.xVelo += 1;
|
|
||||||
}
|
|
||||||
else if(isKeyPressed(KeyEvent.VK_A) || isKeyPressed(KeyEvent.VK_LEFT)){
|
|
||||||
player.xVelo -= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!isKeyPressed(KeyEvent.VK_D) && !isKeyPressed(KeyEvent.VK_RIGHT) && !isKeyPressed(KeyEvent.VK_A) && !isKeyPressed(KeyEvent.VK_LEFT)){ //friction
|
|
||||||
if (player.xVelo > 0){
|
|
||||||
player.xVelo = Math.max(0, player.xVelo - FRICTION);
|
|
||||||
}
|
|
||||||
else if (player.xVelo < 0){
|
|
||||||
player.xVelo = Math.min(0, player.xVelo + FRICTION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//jump
|
|
||||||
boolean jumpKeyDown = (isKeyPressed(KeyEvent.VK_W) || isKeyPressed(KeyEvent.VK_UP));
|
|
||||||
if(jumpKeyDown && !jumpPressed){
|
|
||||||
if(player.onGround){
|
|
||||||
player.yVelo = -15;
|
|
||||||
player.onGround = false;
|
|
||||||
jumpPressed = true;
|
|
||||||
player.airJumps = 0;
|
|
||||||
}
|
|
||||||
else if (player.curPower == 1 && player.airJumps < 1){
|
|
||||||
player.yVelo = -15;
|
|
||||||
player.airJumps++;
|
|
||||||
jumpPressed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!jumpKeyDown){
|
|
||||||
jumpPressed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//gravity
|
|
||||||
if (player.yVelo < MAXYVELO){
|
|
||||||
player.yVelo += GRAVITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
//fall out of world
|
|
||||||
if (player.y > boardHeight){
|
|
||||||
loadLevel(currentLevel);
|
|
||||||
player.health--;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Collectable c : collectables){
|
|
||||||
if (c instanceof Powerup){
|
|
||||||
Powerup pu = (Powerup) c;
|
|
||||||
if (pu.yVelo < MAXYVELO && !pu.onGround){
|
|
||||||
pu.yVelo += GRAVITY;
|
|
||||||
}
|
|
||||||
pu.moveY(pu.yVelo);
|
|
||||||
for (Collidable col : collidables) {
|
|
||||||
if (pu.collidesWith(col)) {
|
|
||||||
pu.yVelo = 0;
|
|
||||||
pu.onGround = true;
|
|
||||||
pu.y = ((Tile)col).y - pu.height;
|
|
||||||
pu.rect.y = pu.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (player.collidesWith(pu)) {
|
|
||||||
player.curPower = pu.id;
|
|
||||||
player.powerTimer = Player.POWER_DURATION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (c instanceof Amendment){
|
|
||||||
Amendment am = (Amendment) c;
|
|
||||||
if (player.collidesWith(am)){
|
|
||||||
player.numAmendments++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
collectables.removeIf(c -> player.collidesWith(c));
|
|
||||||
|
|
||||||
//update x
|
|
||||||
player.moveX(player.xVelo);
|
|
||||||
|
|
||||||
//collision with all tiles x
|
|
||||||
for (Collidable c : collidables) {
|
|
||||||
if (player.collidesWith(c)) {
|
|
||||||
player.onCollideX(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//update y
|
|
||||||
player.moveY(player.yVelo);
|
|
||||||
//assume not on ground
|
|
||||||
player.onGround = false;
|
player.onGround = false;
|
||||||
|
jumpPressed = true;
|
||||||
//collision with all tiles y
|
player.airJumps = 0;
|
||||||
for (Collidable c : collidables) {
|
} else if (player.curPower == 1 && player.airJumps < 1) {
|
||||||
if (player.collidesWith(c)) {
|
player.yVelo = -15;
|
||||||
player.onCollideY(c,collectables);
|
player.airJumps++;
|
||||||
}
|
jumpPressed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!jumpKeyDown) {
|
||||||
|
jumpPressed = false;
|
||||||
//Powerup timer
|
|
||||||
if (player.curPower > 0) {
|
|
||||||
player.powerTimer--;
|
|
||||||
if (player.powerTimer <= 0) {
|
|
||||||
player.curPower = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//update facing
|
|
||||||
if (player.xVelo > 0) player.facing = 1;
|
|
||||||
else if (player.xVelo < 0) player.facing = -1;
|
|
||||||
|
|
||||||
// shoot cooldown
|
|
||||||
if (player.shootCooldown > 0) player.shootCooldown--;
|
|
||||||
|
|
||||||
// invincibility timer
|
|
||||||
if (player.invincibleTimer > 0) player.invincibleTimer--;
|
|
||||||
|
|
||||||
//shoot
|
|
||||||
//projectiles
|
|
||||||
if (isKeyPressed(KeyEvent.VK_SPACE) && player.shootCooldown == 0){
|
|
||||||
int projX = player.facing == 1 ? player.x + player.width : player.x - 10;
|
|
||||||
projectiles.add(new Projectile(projX,player.y,tileSize,10,currentLevel,player.facing));
|
|
||||||
player.shootCooldown = Player.SHOOT_COOLDOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
projectiles.removeIf(p -> p.x < -50 + cameraX || p.x > boardWidth + cameraX + 200);
|
|
||||||
for (Projectile p : new ArrayList<>(projectiles)) {
|
|
||||||
p.move();
|
|
||||||
// projectile hits tile
|
|
||||||
for (Collidable c : collidables) {
|
|
||||||
if (p.collidesWith(c)) {
|
|
||||||
projectiles.remove(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// update enemies
|
|
||||||
for (Enemy e : enemies) {
|
|
||||||
e.patrol(collidables);
|
|
||||||
// enemy hits player
|
|
||||||
if (player.collidesWith(e)) {
|
|
||||||
player.takeDamage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//die
|
|
||||||
if (player.health <= 0) {
|
|
||||||
System.out.print("Game Over - You Died!");
|
|
||||||
gameOver = true;
|
|
||||||
gameTimer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
//projectile hits enemy
|
|
||||||
for (Projectile p : new ArrayList<>(projectiles)){
|
|
||||||
for (Enemy e : new ArrayList<>(enemies)){
|
|
||||||
if (p.collidesWith(e)) {
|
|
||||||
enemies.remove(e);
|
|
||||||
projectiles.remove(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enemies.removeIf(e -> !e.alive);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadLevel(int level) {
|
// gravity
|
||||||
projectiles.clear();
|
if (player.yVelo < MAXYVELO) {
|
||||||
try {
|
player.yVelo += GRAVITY;
|
||||||
LevelLoader.load(tileSize, collidables, collectables, enemies, flag, player, level);
|
|
||||||
player.reset();
|
|
||||||
player.setLevel(level);
|
|
||||||
cameraX = 0;
|
|
||||||
cameraY = 0;
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("Could not load level " + level);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//paintComponent
|
// fall out of world
|
||||||
public void paintComponent(Graphics g){
|
if (player.y > 2000) {
|
||||||
super.paintComponent(g);
|
loadLevel(currentLevel);
|
||||||
draw(g);
|
player.health--;
|
||||||
}
|
}
|
||||||
|
|
||||||
//draw function
|
for (Collectable c : collectables) {
|
||||||
public void draw(Graphics g){
|
if (c instanceof Powerup) {
|
||||||
//gameover screen
|
Powerup pu = (Powerup) c;
|
||||||
if (gameOver){
|
if (pu.yVelo < MAXYVELO && !pu.onGround) {
|
||||||
g.drawImage(endImg, boardWidth/2 - 100, boardHeight/2 - 150, null);
|
pu.yVelo += GRAVITY;
|
||||||
g.drawImage(pressRImg, boardWidth/2 - 80, boardHeight/2, null);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
pu.moveY(pu.yVelo);
|
||||||
g.translate(-cameraX, -cameraY);
|
for (Collidable col : collidables) {
|
||||||
|
if (pu.collidesWith(col)) {
|
||||||
if (currentLevel > totalLevels) {
|
pu.yVelo = 0;
|
||||||
g.drawImage(winImg, boardWidth/2 - 100, boardHeight/2 - 50, null);
|
pu.onGround = true;
|
||||||
g.drawImage(pressRImg, boardWidth/2 - 80, boardHeight/2 + 60, null);
|
pu.y = ((Tile) col).y - pu.height;
|
||||||
return;
|
pu.rect.y = pu.y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (player.collidesWith(pu)) {
|
||||||
player.draw(g);
|
player.curPower = pu.id;
|
||||||
for (Collidable c : collidables) c.draw(g);
|
player.powerTimer = Player.POWER_DURATION;
|
||||||
for (Collectable c : collectables) c.draw(g);
|
|
||||||
for (Enemy e : enemies) e.draw(g);
|
|
||||||
for (Projectile p : projectiles) p.draw(g);
|
|
||||||
flag.draw(g);
|
|
||||||
|
|
||||||
//flag counter
|
|
||||||
int amOnes = player.numAmendments % 10;
|
|
||||||
int amTens = player.numAmendments / 10;
|
|
||||||
|
|
||||||
if (currentLevel > 0 && player.numAmendments < numAm[currentLevel-1]){
|
|
||||||
if (amTens > 0) g.drawImage(numbers.get(amTens),flag.x-20,flag.y-30,null);
|
|
||||||
g.drawImage(numbers.get(amOnes),flag.x+5,flag.y-30,null);
|
|
||||||
g.drawImage(slash,flag.x+28,flag.y-32,null);
|
|
||||||
g.drawImage(numbers.get(numAm[currentLevel-1]),flag.x+55,flag.y-30,null);
|
|
||||||
g.drawImage(amendmentImg,flag.x+85,flag.y-30,null);
|
|
||||||
}
|
}
|
||||||
|
} else if (c instanceof Amendment) {
|
||||||
g.translate(cameraX, cameraY);
|
Amendment am = (Amendment) c;
|
||||||
|
if (player.collidesWith(am)) {
|
||||||
|
player.numAmendments++;
|
||||||
int modAmt = 2000;
|
|
||||||
int curTime = (int) System.currentTimeMillis() % modAmt;
|
|
||||||
curTime = Math.abs(curTime);
|
|
||||||
|
|
||||||
//start screen
|
|
||||||
int startTime = 0;
|
|
||||||
if (curTime >= 0 && curTime <= modAmt/4-1) startTime = 0;
|
|
||||||
else if (curTime >= modAmt/4 && curTime <= modAmt/2-1) startTime = 1;
|
|
||||||
else if (curTime >= modAmt/2 && curTime <= modAmt*3/4-1) startTime = 2;
|
|
||||||
else if (curTime >= modAmt*3/4 && curTime <= modAmt-1) startTime = 3;
|
|
||||||
|
|
||||||
if (currentLevel == 0){
|
|
||||||
g.drawImage(titleImg, boardWidth/2 - 150, boardHeight/2 - 200, null);
|
|
||||||
|
|
||||||
g.drawString("An American Identity Project", boardWidth/2 - 75, boardHeight/2-40);
|
|
||||||
String text = "Press P to Start!";
|
|
||||||
int xBase = 340;
|
|
||||||
int yBase = 400;
|
|
||||||
int spacing = 8;
|
|
||||||
for (int i = 0; i < text.length(); i++) {
|
|
||||||
char c = text.charAt(i);
|
|
||||||
|
|
||||||
// x moves linearly
|
|
||||||
int x = xBase + (i * spacing);
|
|
||||||
|
|
||||||
// y uses a sine wave
|
|
||||||
// Math.sin takes radians. We use (startTime + i) to give each letter a different phase.
|
|
||||||
double waveOffset = Math.sin(startTime + i * 0.5) * 10;
|
|
||||||
int y = yBase + (int)waveOffset;
|
|
||||||
|
|
||||||
g.drawString(String.valueOf(c), x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
collectables.removeIf(c -> player.collidesWith(c));
|
||||||
|
|
||||||
if (currentLevel > 0){
|
// update x
|
||||||
|
player.moveX(player.xVelo);
|
||||||
|
|
||||||
//draw hearts:
|
// collision with all tiles x
|
||||||
int heartTime = 0;
|
for (Collidable c : collidables) {
|
||||||
if (curTime >= 0 && curTime <= modAmt/2-1) heartTime = 1;
|
if (player.collidesWith(c)) {
|
||||||
else if (curTime >= modAmt/2 && curTime <= modAmt-1) heartTime = 0;
|
player.onCollideX(c);
|
||||||
for (int i = 0; i < player.health; i++){
|
}
|
||||||
g.drawImage(heart,(((i+1) * 20)-10)+heartTime,10+heartTime * 2,null);
|
|
||||||
}
|
|
||||||
for (int i =0; i < 3 - player.health; i++){
|
|
||||||
g.drawImage(emptyHeart,(50 - (i * 20)) + heartTime,10+heartTime * 2,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
//draw amendments counter in top right
|
|
||||||
|
|
||||||
if (amTens > 0) g.drawImage(numbers.get(amTens),315,10,null);
|
|
||||||
g.drawImage(numbers.get(amOnes),340,10,null);
|
|
||||||
g.drawImage(slash,363,12,null);
|
|
||||||
g.drawImage(numbers.get(numAm[currentLevel-1]),390,10,null);
|
|
||||||
g.drawImage(amendmentImg,420,10,null);
|
|
||||||
|
|
||||||
|
|
||||||
//draw powerup timer
|
|
||||||
if (player.curPower == 1){
|
|
||||||
int secs = player.powerTimer/66;
|
|
||||||
int tens = secs/10;
|
|
||||||
int ones = secs%10;
|
|
||||||
if (tens > 0){
|
|
||||||
g.drawImage(numbers.get(tens),184,10,null);
|
|
||||||
}
|
|
||||||
g.drawImage(numbers.get(ones),205,10,null);
|
|
||||||
g.drawImage(powerImg,220,10,null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//is key pressed
|
// update y
|
||||||
public boolean isKeyPressed(int key){
|
player.moveY(player.yVelo);
|
||||||
return pressedKeys.getOrDefault(key,false);
|
// assume not on ground
|
||||||
|
player.onGround = false;
|
||||||
|
|
||||||
|
// collision with all tiles y
|
||||||
|
for (Collidable c : collidables) {
|
||||||
|
if (player.collidesWith(c)) {
|
||||||
|
player.onCollideY(c, collectables);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//every tick
|
// Powerup timer
|
||||||
@Override
|
if (player.curPower > 0) {
|
||||||
public void actionPerformed(ActionEvent e){
|
player.powerTimer--;
|
||||||
if (gameStarted) {
|
if (player.powerTimer <= 0) {
|
||||||
gameLoop();
|
player.curPower = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update facing
|
||||||
|
if (player.xVelo > 0) player.facing = 1;
|
||||||
|
else if (player.xVelo < 0) player.facing = -1;
|
||||||
|
|
||||||
|
// shoot cooldown
|
||||||
|
if (player.shootCooldown > 0) player.shootCooldown--;
|
||||||
|
|
||||||
|
// invincibility timer
|
||||||
|
if (player.invincibleTimer > 0) player.invincibleTimer--;
|
||||||
|
|
||||||
|
// shoot
|
||||||
|
// projectiles
|
||||||
|
if (isKeyPressed(KeyEvent.VK_SPACE) && player.shootCooldown == 0) {
|
||||||
|
int projX = player.facing == 1 ? player.x + player.width : player.x - 10;
|
||||||
|
projectiles.add(new Projectile(projX, player.y, tileSize, 10, currentLevel, player.facing));
|
||||||
|
player.shootCooldown = Player.SHOOT_COOLDOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
projectiles.removeIf(p -> p.x < -50 + cameraX || p.x > boardWidth + cameraX + 200);
|
||||||
|
for (Projectile p : new ArrayList<>(projectiles)) {
|
||||||
|
p.move();
|
||||||
|
// projectile hits tile
|
||||||
|
for (Collidable c : collidables) {
|
||||||
|
if (p.collidesWith(c)) {
|
||||||
|
projectiles.remove(p);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update enemies
|
||||||
|
for (Enemy e : enemies) {
|
||||||
|
e.patrol(collidables);
|
||||||
|
// enemy hits player
|
||||||
|
if (player.collidesWith(e)) {
|
||||||
|
player.takeDamage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// die
|
||||||
|
if (player.health <= 0) {
|
||||||
|
System.out.print("Game Over - You Died!");
|
||||||
|
gameOver = true;
|
||||||
|
gameTimer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// projectile hits enemy
|
||||||
|
for (Projectile p : new ArrayList<>(projectiles)) {
|
||||||
|
for (Enemy e : new ArrayList<>(enemies)) {
|
||||||
|
if (p.collidesWith(e)) {
|
||||||
|
enemies.remove(e);
|
||||||
|
projectiles.remove(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
enemies.removeIf(e -> !e.alive);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadLevel(int level) {
|
||||||
|
projectiles.clear();
|
||||||
|
try {
|
||||||
|
LevelLoader.load(tileSize, collidables, collectables, enemies, flag, player, level);
|
||||||
|
player.reset();
|
||||||
|
player.setLevel(level);
|
||||||
|
cameraX = 0;
|
||||||
|
cameraY = 0;
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("Could not load level " + level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// paintComponent
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
draw(g);
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw function
|
||||||
|
public void draw(Graphics g) {
|
||||||
|
// gameover screen
|
||||||
|
if (gameOver) {
|
||||||
|
g.drawImage(endImg, boardWidth / 2 - 100, boardHeight / 2 - 150, null);
|
||||||
|
g.drawImage(pressRImg, boardWidth / 2 - 80, boardHeight / 2, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLevel > totalLevels) {
|
||||||
|
g.drawImage(winImg, boardWidth / 2 - 100, boardHeight / 2 - 50, null);
|
||||||
|
g.drawImage(pressRImg, boardWidth / 2 - 80, boardHeight / 2 + 60, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g.translate(-cameraX, -cameraY);
|
||||||
|
|
||||||
|
player.draw(g);
|
||||||
|
for (Collidable c : collidables) c.draw(g);
|
||||||
|
for (Collectable c : collectables) c.draw(g);
|
||||||
|
for (Enemy e : enemies) e.draw(g);
|
||||||
|
for (Projectile p : projectiles) p.draw(g);
|
||||||
|
flag.draw(g);
|
||||||
|
|
||||||
|
// flag counter
|
||||||
|
int amOnes = player.numAmendments % 10;
|
||||||
|
int amTens = player.numAmendments / 10;
|
||||||
|
|
||||||
|
if (currentLevel > 0 && player.numAmendments < numAm[currentLevel - 1]) {
|
||||||
|
if (amTens > 0) g.drawImage(numbers.get(amTens), flag.x - 20, flag.y - 30, null);
|
||||||
|
g.drawImage(numbers.get(amOnes), flag.x + 5, flag.y - 30, null);
|
||||||
|
g.drawImage(slash, flag.x + 28, flag.y - 32, null);
|
||||||
|
g.drawImage(numbers.get(numAm[currentLevel - 1]), flag.x + 55, flag.y - 30, null);
|
||||||
|
g.drawImage(amendmentImg, flag.x + 85, flag.y - 30, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
g.translate(cameraX, cameraY);
|
||||||
|
|
||||||
|
int modAmt = 2000;
|
||||||
|
int curTime = (int) System.currentTimeMillis() % modAmt;
|
||||||
|
curTime = Math.abs(curTime);
|
||||||
|
|
||||||
|
// start screen
|
||||||
|
int startTime = 0;
|
||||||
|
if (curTime >= 0 && curTime <= modAmt / 4 - 1) startTime = 0;
|
||||||
|
else if (curTime >= modAmt / 4 && curTime <= modAmt / 2 - 1) startTime = 1;
|
||||||
|
else if (curTime >= modAmt / 2 && curTime <= modAmt * 3 / 4 - 1) startTime = 2;
|
||||||
|
else if (curTime >= modAmt * 3 / 4 && curTime <= modAmt - 1) startTime = 3;
|
||||||
|
|
||||||
|
if (currentLevel == 0) {
|
||||||
|
g.drawImage(titleImg, boardWidth / 2 - 150, boardHeight / 2 - 200, null);
|
||||||
|
|
||||||
|
g.drawString("An American Identity Project", boardWidth / 2 - 75, boardHeight / 2 - 40);
|
||||||
|
String text = "Press P to Start!";
|
||||||
|
int xBase = 340;
|
||||||
|
int yBase = 400;
|
||||||
|
int spacing = 8;
|
||||||
|
for (int i = 0; i < text.length(); i++) {
|
||||||
|
char c = text.charAt(i);
|
||||||
|
|
||||||
|
// x moves linearly
|
||||||
|
int x = xBase + (i * spacing);
|
||||||
|
|
||||||
|
// y uses a sine wave
|
||||||
|
// Math.sin takes radians. We use (startTime + i) to give each letter a different phase.
|
||||||
|
double waveOffset = Math.sin(startTime + i * 0.5) * 10;
|
||||||
|
int y = yBase + (int) waveOffset;
|
||||||
|
|
||||||
|
g.drawString(String.valueOf(c), x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentLevel > 0) {
|
||||||
|
|
||||||
|
// draw hearts:
|
||||||
|
int heartTime = 0;
|
||||||
|
if (curTime >= 0 && curTime <= modAmt / 2 - 1) heartTime = 1;
|
||||||
|
else if (curTime >= modAmt / 2 && curTime <= modAmt - 1) heartTime = 0;
|
||||||
|
for (int i = 0; i < player.health; i++) {
|
||||||
|
g.drawImage(heart, (((i + 1) * 20) - 10) + heartTime, 10 + heartTime * 2, null);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 3 - player.health; i++) {
|
||||||
|
g.drawImage(emptyHeart, (50 - (i * 20)) + heartTime, 10 + heartTime * 2, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// draw amendments counter in top right
|
||||||
|
|
||||||
|
if (amTens > 0) g.drawImage(numbers.get(amTens), 315, 10, null);
|
||||||
|
g.drawImage(numbers.get(amOnes), 340, 10, null);
|
||||||
|
g.drawImage(slash, 363, 12, null);
|
||||||
|
g.drawImage(numbers.get(numAm[currentLevel - 1]), 390, 10, null);
|
||||||
|
g.drawImage(amendmentImg, 420, 10, null);
|
||||||
|
|
||||||
|
// draw powerup timer
|
||||||
|
if (player.curPower == 1) {
|
||||||
|
int secs = player.powerTimer / 66;
|
||||||
|
int tens = secs / 10;
|
||||||
|
int ones = secs % 10;
|
||||||
|
if (tens > 0) {
|
||||||
|
g.drawImage(numbers.get(tens), 184, 10, null);
|
||||||
|
}
|
||||||
|
g.drawImage(numbers.get(ones), 205, 10, null);
|
||||||
|
g.drawImage(powerImg, 220, 10, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// is key pressed
|
||||||
|
public boolean isKeyPressed(int key) {
|
||||||
|
return pressedKeys.getOrDefault(key, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// every tick
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (gameStarted) {
|
||||||
|
gameLoop();
|
||||||
|
}
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for key presses
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_P) {
|
||||||
|
if (currentLevel == 0) {
|
||||||
|
currentLevel = 1;
|
||||||
|
loadLevel(currentLevel);
|
||||||
|
gameStarted = true;
|
||||||
|
}
|
||||||
|
gameTimer.start();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_R) {
|
||||||
|
if (gameOver) {
|
||||||
|
gameTimer.stop();
|
||||||
|
loadLevel(1);
|
||||||
|
currentLevel = 1;
|
||||||
|
jumpPressed = false;
|
||||||
|
player.health = 3;
|
||||||
|
gameOver = false;
|
||||||
repaint();
|
repaint();
|
||||||
|
gameTimer.start();
|
||||||
|
gameStarted = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for key presses
|
if (e.getKeyCode() == KeyEvent.VK_O) {
|
||||||
@Override
|
currentLevel++;
|
||||||
public void keyPressed(KeyEvent e){
|
loadLevel(currentLevel);
|
||||||
if (e.getKeyCode() == KeyEvent.VK_P){
|
|
||||||
if(currentLevel == 0) {
|
|
||||||
currentLevel = 1;
|
|
||||||
loadLevel(currentLevel);
|
|
||||||
gameStarted = true;
|
|
||||||
}
|
|
||||||
gameTimer.start();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.getKeyCode() == KeyEvent.VK_R){
|
|
||||||
if (gameOver) {
|
|
||||||
gameTimer.stop();
|
|
||||||
loadLevel(1);
|
|
||||||
currentLevel = 1;
|
|
||||||
jumpPressed = false;
|
|
||||||
player.health=3;
|
|
||||||
gameOver = false;
|
|
||||||
repaint();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.getKeyCode() == KeyEvent.VK_O){
|
|
||||||
currentLevel++;
|
|
||||||
loadLevel(currentLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
pressedKeys.put(e.getKeyCode(),true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
pressedKeys.put(e.getKeyCode(), true);
|
||||||
public void keyReleased(KeyEvent e){
|
}
|
||||||
pressedKeys.put(e.getKeyCode(),false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//dont need
|
@Override
|
||||||
@Override
|
public void keyReleased(KeyEvent e) {
|
||||||
public void keyTyped(KeyEvent e){
|
pressedKeys.put(e.getKeyCode(), false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// dont need
|
||||||
|
@Override
|
||||||
|
public void keyTyped(KeyEvent e) {}
|
||||||
}
|
}
|
||||||
BIN
Player.class
Normal file
BIN
Player.class
Normal file
Binary file not shown.
193
Player.java
193
Player.java
@@ -1,109 +1,108 @@
|
|||||||
import javax.swing.ImageIcon;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Player extends Collidable {
|
public class Player extends Collidable {
|
||||||
|
|
||||||
static final int JUMP_HEIGHT = 10;
|
static final int JUMP_HEIGHT = 10;
|
||||||
static final int POWER_DURATION = 2000; // 2000 ticks ≈ 30 seconds
|
static final int POWER_DURATION = 2000; // 2000 ticks ≈ 30 seconds
|
||||||
static final int I_FRAMES = 67; // ~1 second
|
static final int I_FRAMES = 67; // ~1 second
|
||||||
static final int SHOOT_COOLDOWN = 33; //~0.5 second
|
static final int SHOOT_COOLDOWN = 33; // ~0.5 second
|
||||||
|
|
||||||
int health;
|
int health;
|
||||||
int yVelo;
|
int yVelo;
|
||||||
int xVelo;
|
int xVelo;
|
||||||
boolean onGround;
|
boolean onGround;
|
||||||
int curPower;
|
int curPower;
|
||||||
int powerTimer;
|
int powerTimer;
|
||||||
int airJumps;
|
int airJumps;
|
||||||
int facing; // 1 is right -1 is left
|
int facing; // 1 is right -1 is left
|
||||||
int invincibleTimer;
|
int invincibleTimer;
|
||||||
int shootCooldown;
|
int shootCooldown;
|
||||||
int numAmendments;
|
int numAmendments;
|
||||||
|
|
||||||
public Player(int x, int y, int w, int h){
|
public Player(int x, int y, int w, int h) {
|
||||||
super(x,y,w,h,new ImageIcon("Sprites/Player/1.png"));
|
super(x, y, w, h, new ImageIcon("Sprites/Player/1.png"));
|
||||||
xVelo = 0;
|
xVelo = 0;
|
||||||
yVelo = 0;
|
yVelo = 0;
|
||||||
onGround = false;
|
onGround = false;
|
||||||
curPower = 0;
|
curPower = 0;
|
||||||
powerTimer = 0;
|
powerTimer = 0;
|
||||||
|
airJumps = 0;
|
||||||
|
invincibleTimer = 0;
|
||||||
|
shootCooldown = 0;
|
||||||
|
health = 3;
|
||||||
|
facing = 1;
|
||||||
|
numAmendments = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveX(int moveX) {
|
||||||
|
this.x += moveX;
|
||||||
|
this.rect.x = this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveY(int moveY) {
|
||||||
|
this.y += moveY;
|
||||||
|
this.rect.y = this.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(int level) {
|
||||||
|
this.icon = new ImageIcon("Sprites/Player/" + level + ".png");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCollideX(Collidable other) {
|
||||||
|
if (other instanceof Tile) {
|
||||||
|
Tile t = (Tile) other;
|
||||||
|
int playerCenterX = this.x + this.width / 2;
|
||||||
|
int tileCenterX = t.x + t.width / 2;
|
||||||
|
if (playerCenterX > tileCenterX) { // player on right side of tiile
|
||||||
|
this.x = t.x + t.width;
|
||||||
|
} else { // player on left side of tile
|
||||||
|
this.x = t.x - this.width;
|
||||||
|
}
|
||||||
|
this.xVelo = 0;
|
||||||
|
this.rect.x = this.x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onCollideY(Collidable other, ArrayList<Collectable> collectables) {
|
||||||
|
if (other instanceof Tile) {
|
||||||
|
Tile t = (Tile) other;
|
||||||
|
if (this.yVelo >= 0) { // falling down, land on top of tile
|
||||||
|
this.y = t.y - this.height;
|
||||||
|
onGround = true;
|
||||||
airJumps = 0;
|
airJumps = 0;
|
||||||
invincibleTimer = 0;
|
} else { // moving up, hit underside of tile
|
||||||
shootCooldown = 0;
|
this.y = t.y + t.height;
|
||||||
health = 3;
|
if (other instanceof PowerBrick) {
|
||||||
facing = 1;
|
PowerBrick pb = (PowerBrick) other;
|
||||||
numAmendments = 0;
|
if (!pb.hit) {
|
||||||
}
|
pb.spawnPower(collectables);
|
||||||
|
}
|
||||||
public void moveX(int moveX){
|
|
||||||
this.x += moveX;
|
|
||||||
this.rect.x = this.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void moveY(int moveY){
|
|
||||||
this.y += moveY;
|
|
||||||
this.rect.y = this.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLevel(int level){
|
|
||||||
this.icon = new ImageIcon("Sprites/Player/" + level + ".png");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCollideX(Collidable other){
|
|
||||||
if (other instanceof Tile){
|
|
||||||
Tile t = (Tile) other;
|
|
||||||
int playerCenterX = this.x + this.width / 2;
|
|
||||||
int tileCenterX = t.x + t.width / 2;
|
|
||||||
if (playerCenterX > tileCenterX) { //player on right side of tiile
|
|
||||||
this.x = t.x + t.width;
|
|
||||||
}
|
|
||||||
else { //player on left side of tile
|
|
||||||
this.x = t.x - this.width;
|
|
||||||
}
|
|
||||||
this.xVelo = 0;
|
|
||||||
this.rect.x = this.x;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
this.yVelo = 0;
|
||||||
|
this.rect.y = this.y;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onCollideY(Collidable other, ArrayList<Collectable> collectables){
|
public void takeDamage() {
|
||||||
if (other instanceof Tile){
|
if (invincibleTimer <= 0) {
|
||||||
Tile t = (Tile) other;
|
health--;
|
||||||
if (this.yVelo >= 0) { // falling down, land on top of tile
|
invincibleTimer = I_FRAMES;
|
||||||
this.y = t.y - this.height;
|
|
||||||
onGround = true;
|
|
||||||
airJumps = 0;
|
|
||||||
}
|
|
||||||
else { // moving up, hit underside of tile
|
|
||||||
this.y = t.y + t.height;
|
|
||||||
if (other instanceof PowerBrick){
|
|
||||||
PowerBrick pb = (PowerBrick) other;
|
|
||||||
if(!pb.hit){
|
|
||||||
pb.spawnPower(collectables);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.yVelo = 0;
|
|
||||||
this.rect.y = this.y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void takeDamage() {
|
public void reset() {
|
||||||
if (invincibleTimer <= 0) {
|
this.rect.x = this.x;
|
||||||
health--;
|
this.rect.y = this.y;
|
||||||
invincibleTimer = I_FRAMES;
|
this.xVelo = this.yVelo = 0;
|
||||||
}
|
this.curPower = 0;
|
||||||
}
|
this.powerTimer = 0;
|
||||||
|
this.airJumps = 0;
|
||||||
public void reset(){
|
this.onGround = false;
|
||||||
this.rect.x = this.x;
|
this.invincibleTimer = 0;
|
||||||
this.rect.y = this.y;
|
this.shootCooldown = 0;
|
||||||
this.xVelo = this.yVelo = 0;
|
this.facing = 1;
|
||||||
this.curPower = 0;
|
this.numAmendments = 0;
|
||||||
this.powerTimer = 0;
|
}
|
||||||
this.airJumps = 0;
|
|
||||||
this.onGround = false;
|
|
||||||
this.invincibleTimer = 0;
|
|
||||||
this.shootCooldown = 0;
|
|
||||||
this.facing = 1;
|
|
||||||
this.numAmendments = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BIN
PowerBrick.class
Normal file
BIN
PowerBrick.class
Normal file
Binary file not shown.
@@ -1,24 +1,24 @@
|
|||||||
import javax.swing.ImageIcon;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class PowerBrick extends Tile{
|
public class PowerBrick extends Tile {
|
||||||
int id;
|
int id;
|
||||||
boolean hit;
|
boolean hit;
|
||||||
|
|
||||||
public PowerBrick(int x, int y, int w, int h, int id) {
|
public PowerBrick(int x, int y, int w, int h, int id) {
|
||||||
super(x, y, w, h, new ImageIcon("Sprites/Bricks/PowerBrick.png"));
|
super(x, y, w, h, new ImageIcon("Sprites/Bricks/PowerBrick.png"));
|
||||||
this.id = id;
|
this.id = id;
|
||||||
hit = false;
|
hit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spawnPower(ArrayList<Collectable> powerups){
|
public void spawnPower(ArrayList<Collectable> powerups) {
|
||||||
this.icon = new ImageIcon("Sprites/Bricks/EmptyBrick.png");
|
this.icon = new ImageIcon("Sprites/Bricks/EmptyBrick.png");
|
||||||
hit = true;
|
hit = true;
|
||||||
powerups.add(new Powerup(this.x, this.y - this.height, this.width, this.height, 1));
|
powerups.add(new Powerup(this.x, this.y - this.height, this.width, this.height, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset(){
|
public void reset() {
|
||||||
hit = false;
|
hit = false;
|
||||||
this.icon = new ImageIcon("Sprites/Bricks/PowerBrick.png");
|
this.icon = new ImageIcon("Sprites/Bricks/PowerBrick.png");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Powerup.class
Normal file
BIN
Powerup.class
Normal file
Binary file not shown.
35
Powerup.java
35
Powerup.java
@@ -1,23 +1,24 @@
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Powerup extends Collectable{
|
public class Powerup extends Collectable {
|
||||||
int yVelo, xVelo, id;
|
int yVelo, xVelo, id;
|
||||||
boolean onGround;
|
boolean onGround;
|
||||||
|
|
||||||
public Powerup(int x, int y, int w, int h, int id){
|
public Powerup(int x, int y, int w, int h, int id) {
|
||||||
super(x,y,w,h,new ImageIcon("Sprites/Powerup" + id + ".png"));
|
super(x, y, w, h, new ImageIcon("Sprites/Powerup" + id + ".png"));
|
||||||
xVelo = 0; yVelo = -7;
|
xVelo = 0;
|
||||||
onGround = false;
|
yVelo = -7;
|
||||||
this.id = id;
|
onGround = false;
|
||||||
}
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public void moveX(int moveX){
|
public void moveX(int moveX) {
|
||||||
this.x += moveX;
|
this.x += moveX;
|
||||||
this.rect.x = this.x;
|
this.rect.x = this.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void moveY(int moveY){
|
public void moveY(int moveY) {
|
||||||
this.y += moveY;
|
this.y += moveY;
|
||||||
this.rect.y = this.y;
|
this.rect.y = this.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Projectile.class
Normal file
BIN
Projectile.class
Normal file
Binary file not shown.
@@ -1,15 +1,15 @@
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Projectile extends Collidable {
|
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 + ".png"));
|
||||||
xVelo = 10 * direction;
|
xVelo = 10 * direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(){
|
public void move() {
|
||||||
this.x += xVelo;
|
this.x += xVelo;
|
||||||
this.rect.x = this.x;
|
this.rect.x = this.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Sprite.class
Normal file
BIN
Sprite.class
Normal file
Binary file not shown.
16
Sprite.java
16
Sprite.java
@@ -1,12 +1,12 @@
|
|||||||
import javax.swing.ImageIcon;
|
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
public class Sprite{
|
public class Sprite {
|
||||||
ImageIcon icon;
|
ImageIcon icon;
|
||||||
Image sprite;
|
Image sprite;
|
||||||
|
|
||||||
public Sprite(ImageIcon i){
|
public Sprite(ImageIcon i) {
|
||||||
icon = i;
|
icon = i;
|
||||||
sprite = i.getImage();
|
sprite = i.getImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BIN
Tile.class
Normal file
BIN
Tile.class
Normal file
Binary file not shown.
@@ -2,9 +2,7 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
public class Tile extends Collidable {
|
public class Tile extends Collidable {
|
||||||
|
|
||||||
public Tile(int x, int y, int w, int h,ImageIcon i){
|
public Tile(int x, int y, int w, int h, ImageIcon i) {
|
||||||
super(x,y,w,h,i);
|
super(x, y, w, h, i);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user