Skip to content
Snippets Groups Projects
Commit 061a993f authored by aarnereime's avatar aarnereime
Browse files

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/inf112/skeleton/app/Game.java
#	src/main/java/inf112/skeleton/app/Player.java
parents dc0da923 c336c36e
No related branches found
No related tags found
No related merge requests found
Showing
with 145 additions and 382 deletions
package inf112.skeleton.app;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
public class Checkpoint implements IGameObject {
private int x, y, w, h;
Image checkpointImg = new Image("file:src/PlayerImage/checkpoint.png");
boolean drawText;
public Checkpoint(int X, int Y) {
this.x = X;
this.y = Y;
this.w = 40;
this.h = 60;
}
@Override
public int getHeight() {
return this.h;
}
@Override
public int getWidth() {
return this.w;
}
@Override
public int getX() {
return this.x;
}
@Override
public int getY() {
return this.y;
}
@Override
public int getSpeed() {
return 0;
}
@Override
public int getGravity() {
return 0;
}
public void drawCheckpoint(GraphicsContext gc, Player player) {
gc.drawImage(checkpointImg, (this.x - this.w/2.0) - player.getX() + player.screenX, this.y - this.h/2.0, this.w, this.h);
}
public void drawCheckpointText(GraphicsContext gc) {
int width = 240;
int height = 50;
double x = (900/2.0) - width/2.0;
double y = 100;
gc.setFill(Color.rgb(0, 0, 0, 0.8));
gc.fillRoundRect(x, y, width, height, 35, 35);
gc.setFill(Color.WHITE);
gc.setFont(new Font("Comic sans MS", 20));
gc.fillText("Checkpoint updated", x + 20, y + 30);
gc.restore();
}
}
package inf112.skeleton.app.Controller; package inf112.skeleton.app.Controller;
import javafx.scene.input.KeyCode;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import inf112.skeleton.app.model.Player; import inf112.skeleton.app.model.Player;
import javafx.scene.input.KeyCode;
public class KeyHandler { public class KeyHandler {
Player player; Player player;
......
package inf112.skeleton.app;
import javafx.scene.input.KeyCode;
public class KeyHandler {
Player player;
public KeyHandler(Player player){
this.player = player;
}
public void keyPressed(javafx.scene.input.KeyEvent evt) {
KeyCode key = evt.getCode();
if (key == KeyCode.LEFT) {
player.move_left = true;
}
if (key == KeyCode.RIGHT) {
player.move_right = true;
}
if ((key == KeyCode.UP || key == KeyCode.SPACE) && player.onGround) {
player.jump = true;
player.runCounter = 0;
}
}
public void keyReleased(javafx.scene.input.KeyEvent evt) {
KeyCode key = evt.getCode();
if (key == KeyCode.LEFT ) {
player.move_left = false;
player.runCounter = 0;
}
if (key == KeyCode.RIGHT) {
player.move_right = false;
player.runCounter = 0;
}
}
}
package inf112.skeleton.app;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
public class Tree implements IGameObject{
int x, y, w, h;
String type;
Image treeImg = new Image("file:src/PlayerImage/tree.png");
Image pineImg = new Image("file:src/PlayerImage/pine.png");
public Tree(int X, int Y, String type) {
this.x = X;
this.y = Y;
this.w = 200;
this.h = 230;
this.type = type;
}
public int getHeight() {
return this.h;
}
public int getWidth() {
return this.w;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
@Override
public int getSpeed() {
return 0;
}
@Override
public int getGravity() {
return 5;
}
public void drawTree(GraphicsContext gc, Player player) {
int tree_w = this.w;
int tree_h = this.h;
double tree_xPos = (this.x - tree_w / 2.0) - player.getX() + player.screenX;
double tree_yPos = (this.y - tree_h / 2.0);
if (this.type == "tree") {
gc.drawImage(treeImg, tree_xPos, tree_yPos, tree_w, tree_h);
}
else if (this.type == "pine") {
gc.drawImage(pineImg, tree_xPos, tree_yPos, tree_w, tree_h);
}
}
}
package inf112.skeleton.app;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
public class Waffle implements IGameObject {
private int x, y, w, h;
Image waffleImg = new Image("file:src/PlayerImage/waffle.png");
public Waffle(int X, int Y) {
this.x = X;
this.y = Y;
this.w = 50;
this.h = 50;
}
public int getHeight() {
return this.h;
}
public int getWidth() {
return this.w;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
@Override
public int getSpeed() {
return 0;
}
@Override
public int getGravity() {
return 0;
}
public void drawWaffle(GraphicsContext gc, Player player) {
int waffle_w = this.w;
int waffle_h = this.h;
double waffle_xPos = (this.x - waffle_w / 2.0) - player.getX() + player.screenX;
double waffle_yPos = (this.y - waffle_h / 2.0);
gc.drawImage(waffleImg, waffle_xPos, waffle_yPos, waffle_w, waffle_h);
}
public void drawWafflePoints(GraphicsContext gc, double x, double y, int w, int h) {
gc.drawImage(waffleImg, x - w/2.0, y - h/2.0, w, h);
}
public void drawWaffleText(GraphicsContext gc, double w, double h) {
int width = 400;
int height = 200;
double x = w/2 - width/2;
double y = h/3.5 - height/2;
gc.setFill(Color.rgb(0, 0, 0, 0.8));
gc.fillRoundRect(x, y, width, height, 35, 35);
gc.setFill(Color.WHITE);
gc.setFont(new Font("Comic sans MS", 20));
gc.fillText("Hi! Waffle Thursday is closed and due\n to an error in the system, the very\n last waffle is made for " +
"two people,\n you and Anya!!! Battle against Anya\n to secure the last waffle.", x + 20, y + 50);
gc.restore();
}
public void waffleCount(GraphicsContext gc, Player player) {
gc.setFill(Color.WHITE);
gc.setFont(Font.font("Verdana", FontWeight.BOLD, 35));
gc.fillText("x" + player.waffleScore, 65, 95);
gc.restore();
}
}
package inf112.skeleton.app; package inf112.skeleton.app;
import inf112.skeleton.app.Controller.IGameObject;
import inf112.skeleton.app.model.Player;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image; import javafx.scene.image.Image;
......
...@@ -49,7 +49,7 @@ public class Checkpoint implements IGameObject { ...@@ -49,7 +49,7 @@ public class Checkpoint implements IGameObject {
} }
public void drawCheckpoint(GraphicsContext gc, Player player) { public void drawCheckpoint(GraphicsContext gc, Player player) {
gc.drawImage(checkpointImg, (this.x - w/2.0) - player.getX() + player.screenX, y - h/2.0, w, h); gc.drawImage(checkpointImg, (this.x - this.w/2.0) - player.getX() + player.screenX, this.y - this.h/2.0, this.w, this.h);
} }
public void drawCheckpointText(GraphicsContext gc) { public void drawCheckpointText(GraphicsContext gc) {
......
...@@ -3,7 +3,6 @@ package inf112.skeleton.app.model; ...@@ -3,7 +3,6 @@ package inf112.skeleton.app.model;
import inf112.skeleton.app.Controller.IGameObject; import inf112.skeleton.app.Controller.IGameObject;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.paint.Paint;
public class Enemy implements IGameObject{ public class Enemy implements IGameObject{
int x, y, w, h, drawW, distance; int x, y, w, h, drawW, distance;
......
...@@ -3,7 +3,6 @@ package inf112.skeleton.app.model; ...@@ -3,7 +3,6 @@ package inf112.skeleton.app.model;
import inf112.skeleton.app.Controller.IGameObject; import inf112.skeleton.app.Controller.IGameObject;
import inf112.skeleton.app.view.Game; import inf112.skeleton.app.view.Game;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image; import javafx.scene.image.Image;
public class Player implements IGameObject{ public class Player implements IGameObject{
...@@ -46,7 +45,7 @@ public class Player implements IGameObject{ ...@@ -46,7 +45,7 @@ public class Player implements IGameObject{
screenX = game.height/2; screenX = game.height/2;
screenY = game.width/1.3; screenY = game.width/1.3;
} }
/** /**
* Denne kontruktøren brukes bare for testing! * Denne kontruktøren brukes bare for testing!
*/ */
...@@ -170,29 +169,29 @@ public class Player implements IGameObject{ ...@@ -170,29 +169,29 @@ public class Player implements IGameObject{
//draw moving right //draw moving right
if (move_right && onGround) { if (move_right && onGround) {
switch (runCounter) { switch (runCounter) {
case 0 -> this.image = r1; case 0 -> this.image = r1;
case 5 -> this.image = r2; case 5 -> this.image = r2;
case 10 -> this.image = r3; case 10 -> this.image = r3;
case 15 -> this.image = r4; case 15 -> this.image = r4;
case 20 -> this.image = r5; case 20 -> this.image = r5;
case 25 -> this.image = r6; case 25 -> this.image = r6;
case 30 -> this.image = r7; case 30 -> this.image = r7;
case 35 -> this.image = r8; case 35 -> this.image = r8;
} }
} }
//draw not moving //draw not moving
if (!move_left && !move_right && onGround) { if (!move_left && !move_right && onGround) {
switch (runCounter) { switch (runCounter) {
case 0 -> this.image = i1; case 0 -> this.image = i1;
case 5 -> this.image = i2; case 5 -> this.image = i2;
case 10 -> this.image = i3; case 10 -> this.image = i3;
case 15 -> this.image = i4; case 15 -> this.image = i4;
case 20 -> this.image = i5; case 20 -> this.image = i5;
case 25 -> this.image = i6; case 25 -> this.image = i6;
case 30 -> this.image = i7; case 30 -> this.image = i7;
case 35 -> this.image = i8; case 35 -> this.image = i8;
} }
} }
......
package inf112.skeleton.app.model; package inf112.skeleton.app.model;
import inf112.skeleton.app.Controller.IGameObject; import inf112.skeleton.app.Controller.IGameObject;
import javafx.scene.paint.Paint; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
public class Tree implements IGameObject{ public class Tree implements IGameObject{
int x, y, w, h; int x, y, w, h;
String type;
public Tree(int X, int Y, int W, int H) { Image treeImg = new Image("file:src/PlayerImage/tree.png");
Image pineImg = new Image("file:src/PlayerImage/pine.png");
public Tree(int X, int Y, String type) {
this.x = X; this.x = X;
this.y = Y; this.y = Y;
this.w = W; this.w = 200;
this.h = H; this.h = 230;
this.type = type;
} }
public int getHeight() { public int getHeight() {
...@@ -39,5 +45,21 @@ public class Tree implements IGameObject{ ...@@ -39,5 +45,21 @@ public class Tree implements IGameObject{
return 5; return 5;
} }
public void drawTree(GraphicsContext gc, Player player) {
int tree_w = this.w;
int tree_h = this.h;
double tree_xPos = (this.x - tree_w / 2.0) - player.getX() + player.screenX;
double tree_yPos = (this.y - tree_h / 2.0);
if (this.type == "tree") {
gc.drawImage(treeImg, tree_xPos, tree_yPos, tree_w, tree_h);
}
else if (this.type == "pine") {
gc.drawImage(pineImg, tree_xPos, tree_yPos, tree_w, tree_h);
}
}
} }
...@@ -4,19 +4,18 @@ import inf112.skeleton.app.Controller.IGameObject; ...@@ -4,19 +4,18 @@ import inf112.skeleton.app.Controller.IGameObject;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font; import javafx.scene.text.Font;
import javafx.scene.text.FontWeight; import javafx.scene.text.FontWeight;
public class Waffle implements IGameObject { public class Waffle implements IGameObject {
private int x, y, w, h; private int x, y, w, h;
Image waffleImg = new Image("file:src/PlayerImage/waffle.png"); Image waffleImg = new Image("file:src/PlayerImage/waffle.png");
public Waffle(int X, int Y, int W, int H) { public Waffle(int X, int Y) {
this.x = X; this.x = X;
this.y = Y; this.y = Y;
this.w = W; this.w = 50;
this.h = H; this.h = 50;
} }
public int getHeight() { public int getHeight() {
...@@ -45,6 +44,15 @@ public class Waffle implements IGameObject { ...@@ -45,6 +44,15 @@ public class Waffle implements IGameObject {
return 0; return 0;
} }
public void drawWaffle(GraphicsContext gc, Player player) {
int waffle_w = this.w;
int waffle_h = this.h;
double waffle_xPos = (this.x - waffle_w / 2.0) - player.getX() + player.screenX;
double waffle_yPos = (this.y - waffle_h / 2.0);
gc.drawImage(waffleImg, waffle_xPos, waffle_yPos, waffle_w, waffle_h);
}
public void drawWafflePoints(GraphicsContext gc, double x, double y, int w, int h) { public void drawWafflePoints(GraphicsContext gc, double x, double y, int w, int h) {
gc.drawImage(waffleImg, x - w/2.0, y - h/2.0, w, h); gc.drawImage(waffleImg, x - w/2.0, y - h/2.0, w, h);
......
package inf112.skeleton.app.model; package inf112.skeleton.app.model;
import inf112.skeleton.app.Controller.IGameObject; import inf112.skeleton.app.Controller.IGameObject;
import javafx.scene.paint.Paint; import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
public class Wall implements IGameObject{ public class Wall implements IGameObject{
private int x, y, w, h; private int x, y, w, h;
public String type; String type;
Image platformGrass = new Image("file:src/PlayerImage/grassplatform.png");
Image box = new Image("file:src/PlayerImage/box.png");
public Wall(int X, int Y, int W, int H, String type) { public Wall(int X, int Y, int W, int H, String type) {
this.x = X; this.x = X;
...@@ -41,4 +45,19 @@ public class Wall implements IGameObject{ ...@@ -41,4 +45,19 @@ public class Wall implements IGameObject{
return 0; return 0;
} }
public void drawWall(GraphicsContext gc, Player player) {
int walls_w = this.w;
int walls_h = this.h;
double walls_xPos = (this.x - walls_w / 2.0) - player.getX() + player.screenX;
double walls_yPos = (this.y - walls_h / 2.0);
if (this.type == "grass") {
gc.drawImage(platformGrass, walls_xPos, walls_yPos, walls_w, walls_h);
}
else if (this.type == "box") {
gc.drawImage(box, walls_xPos, walls_yPos, walls_w, walls_h);
}
}
} }
package inf112.skeleton.app.view; package inf112.skeleton.app.view;
import java.io.FileNotFoundException; import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random;
import inf112.skeleton.app.Controller.CollisionDetection; import inf112.skeleton.app.Controller.CollisionDetection;
import inf112.skeleton.app.Controller.KeyHandler; import inf112.skeleton.app.Controller.KeyHandler;
...@@ -15,23 +23,6 @@ import inf112.skeleton.app.model.Player; ...@@ -15,23 +23,6 @@ import inf112.skeleton.app.model.Player;
import inf112.skeleton.app.model.Tree; import inf112.skeleton.app.model.Tree;
import inf112.skeleton.app.model.Waffle; import inf112.skeleton.app.model.Waffle;
import inf112.skeleton.app.model.Wall; import inf112.skeleton.app.model.Wall;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.*;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.effect.Bloom;
import javafx.scene.effect.BoxBlur;
import javafx.scene.image.Image;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.*;
import javafx.scene.shape.ArcType;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
public class Game extends Application { public class Game extends Application {
private AnimationTimer timer; private AnimationTimer timer;
...@@ -43,22 +34,20 @@ public class Game extends Application { ...@@ -43,22 +34,20 @@ public class Game extends Application {
public double height = 600; public double height = 600;
public double width = 1000; public double width = 1000;
double moveSky = -0.1; double moveSky = 0.1;
private List<Wall> ListWalls = new ArrayList<>(); private List<Wall> ListWalls = new ArrayList<>();
private List<Waffle> ListWaffle = new ArrayList<>(); private List<Waffle> ListWaffle = new ArrayList<>();
private List<Enemy> ListEnemy = new ArrayList<>(); private List<Enemy> ListEnemy = new ArrayList<>();
private List<Tree> ListTrees = new ArrayList<>(); private List<Tree> ListTrees = new ArrayList<>();
private List<Checkpoint> ListCheckpoint = new ArrayList<>(); private List<Checkpoint> ListCheckpoint = new ArrayList<>();
public Player player; public Player player;
public Waffle waffle = new Waffle(1, 1, 1, 1); public Waffle wafflePoint = new Waffle(1, 1);
private Scene scene; private Scene scene;
Image hearts = new Image("file:src/PlayerImage/heart.png"); Image hearts = new Image("file:src/PlayerImage/heart.png");
Image waffleImg = new Image("file:src/PlayerImage/waffle.png"); Image waffleImg = new Image("file:src/PlayerImage/waffle.png");
Image platformGrass = new Image("file:src/PlayerImage/grassplatform.png");
Image treeImg = new Image("file:src/PlayerImage/tree.png");
Image box = new Image("file:src/PlayerImage/box.png");
Image background1 = new Image("file:src/PlayerImage/freecutetileset/FreeCuteTileset/BG1.png"); Image background1 = new Image("file:src/PlayerImage/freecutetileset/FreeCuteTileset/BG1.png");
Image background2 = new Image("file:src/PlayerImage/freecutetileset/FreeCuteTileset/BG2.png"); Image background2 = new Image("file:src/PlayerImage/freecutetileset/FreeCuteTileset/BG2.png");
...@@ -78,7 +67,7 @@ public class Game extends Application { ...@@ -78,7 +67,7 @@ public class Game extends Application {
} }
public Scene getScene() { public Scene getScene() {
return this.scene; return this.scene;
} }
@Override @Override
...@@ -147,6 +136,7 @@ public class Game extends Application { ...@@ -147,6 +136,7 @@ public class Game extends Application {
ListWalls.clear(); ListWalls.clear();
ListWaffle.clear(); ListWaffle.clear();
ListTrees.clear(); ListTrees.clear();
ListCheckpoint.clear();
player = new Player(this); player = new Player(this);
...@@ -156,8 +146,8 @@ public class Game extends Application { ...@@ -156,8 +146,8 @@ public class Game extends Application {
//SECTION 1 //SECTION 1
ListTrees.add(new Tree(296, 315, 200, 230)); ListTrees.add(new Tree(296, 315, "tree"));
ListTrees.add(new Tree(900, 385, 200, 230)); ListTrees.add(new Tree(900, 385, "tree"));
ListWalls.add(new Wall(200, 480, 100, 100, "grass")); ListWalls.add(new Wall(200, 480, 100, 100, "grass"));
ListWalls.add(new Wall(296, 480, 100, 100, "grass")); ListWalls.add(new Wall(296, 480, 100, 100, "grass"));
...@@ -170,8 +160,8 @@ public class Game extends Application { ...@@ -170,8 +160,8 @@ public class Game extends Application {
ListEnemy.add(new Enemy(700, 250, 200)); ListEnemy.add(new Enemy(700, 250, 200));
ListWaffle.add(new Waffle(300, 350, 50, 50)); ListWaffle.add(new Waffle(300, 350));
ListWaffle.add(new Waffle(1000, 400, 50, 50)); ListWaffle.add(new Waffle(1000, 400));
//BREAK //BREAK
...@@ -198,8 +188,8 @@ public class Game extends Application { ...@@ -198,8 +188,8 @@ public class Game extends Application {
idx4 += 96; idx4 += 96;
} }
ListTrees.add(new Tree(1880, 275, 200, 230)); ListTrees.add(new Tree(1880, 275, "tree"));
ListWaffle.add(new Waffle(2300, 420, 50, 50)); ListWaffle.add(new Waffle(2300, 400));
ListWalls.add(new Wall(2200, 360, 60, 60, "box")); ListWalls.add(new Wall(2200, 360, 60, 60, "box"));
//BREAK //BREAK
...@@ -215,15 +205,32 @@ public class Game extends Application { ...@@ -215,15 +205,32 @@ public class Game extends Application {
} }
ListCheckpoint.add(new Checkpoint(3600, 470)); ListCheckpoint.add(new Checkpoint(3600, 470));
ListTrees.add(new Tree(3500, 385, 200, 230)); ListTrees.add(new Tree(3500, 385, "pine"));
ListEnemy.add(new Enemy(3700, 250, 400)); ListEnemy.add(new Enemy(3700, 250, 400));
ListEnemy.add(new Enemy(3800, 250, 300)); ListEnemy.add(new Enemy(3800, 250, 300));
ListTrees.add(new Tree(4000, 385, "pine"));
ListTrees.add(new Tree(4100, 385, "pine"));
ListTrees.add(new Tree(4200, 385, "pine"));
//BREAK
ListWalls.add(new Wall(4400, 470, 60, 60, "box"));
ListWalls.add(new Wall(4410, 325, 60, 60, "box"));
ListWalls.add(new Wall(4720, 320, 60, 60, "box"));
int idx6 = 5000;
for (int i = 0; i < 10; i++) {
ListWalls.add(new Wall(idx6, 320, 60, 60, "box"));
idx6 += 60;
}
ListEnemy.add(new Enemy(5100, 200, 350));
ListWaffle.add(new Waffle(5300, 120));
} }
protected void step() { protected void step() {
//System.out.println(gameState);
if (gameState == playState) { if (gameState == playState) {
player.canMoveLeft = true; player.canMoveLeft = true;
...@@ -291,7 +298,7 @@ public class Game extends Application { ...@@ -291,7 +298,7 @@ public class Game extends Application {
if (cd.checkCollision(player, checkpoint, "left") || cd.checkCollision(player, checkpoint, "right") || if (cd.checkCollision(player, checkpoint, "left") || cd.checkCollision(player, checkpoint, "right") ||
cd.checkCollision(player, checkpoint, "up") || cd.checkCollision(player, checkpoint, "down")) { cd.checkCollision(player, checkpoint, "up") || cd.checkCollision(player, checkpoint, "down")) {
player.spawnX = checkpoint.getX(); player.spawnX = checkpoint.getX();
player.spawnY = checkpoint.getY() - player.getHeight(); player.spawnY = checkpoint.getY() - player.getHeight()/2;
checkpoint.drawText = true; checkpoint.drawText = true;
} }
else { else {
...@@ -328,8 +335,7 @@ public class Game extends Application { ...@@ -328,8 +335,7 @@ public class Game extends Application {
context.fillText("Press enter to play", x - 140, y + 80); context.fillText("Press enter to play", x - 140, y + 80);
context.fillText("Press h for how to play", x - 170, y + 130); context.fillText("Press h for how to play", x - 170, y + 130);
context.restore(); context.restore();
} } else if (gameState == deathState) {
else if(gameState == deathState) {
Color c = Color.rgb(245, 187, 131); Color c = Color.rgb(245, 187, 131);
context.setFill(c); context.setFill(c);
context.fillRect(0, 0, this.width, this.height); context.fillRect(0, 0, this.width, this.height);
...@@ -339,13 +345,12 @@ public class Game extends Application { ...@@ -339,13 +345,12 @@ public class Game extends Application {
context.setFill(Color.WHITE); context.setFill(Color.WHITE);
context.setFont(new Font("Comic sans MS", 60)); context.setFont(new Font("Comic sans MS", 60));
context.fillText("Game Over", x - 160 , y); context.fillText("Game Over", x - 160, y);
context.setFont(new Font("Comic sans MS", 30)); context.setFont(new Font("Comic sans MS", 30));
context.fillText("You died", x - 70, y + 70); context.fillText("You died", x - 70, y + 70);
context.fillText("Press enter to continue", x - 170, y + 120); context.fillText("Press enter to continue", x - 170, y + 120);
context.restore(); context.restore();
} } else if (gameState == howToPlayState) {
else if (gameState == howToPlayState) {
Color c = Color.rgb(245, 187, 131); Color c = Color.rgb(245, 187, 131);
context.setFill(c); context.setFill(c);
context.fillRect(0, 0, this.width, this.height); context.fillRect(0, 0, this.width, this.height);
...@@ -356,65 +361,41 @@ public class Game extends Application { ...@@ -356,65 +361,41 @@ public class Game extends Application {
context.setFill(Color.WHITE); context.setFill(Color.WHITE);
context.setFont(new Font("Comic sans MS", 30)); context.setFont(new Font("Comic sans MS", 30));
context.fillText("Reach the end of the map and \nacquire the final waffle to win.\n" + context.fillText("Reach the end of the map and \nacquire the final waffle to win.\n" +
"Jump on enemies to kill them.\n" + "Jump on enemies to kill them.\n" +
"Collide with wooden posts to\n" + "Collide with wooden posts to\n" +
"update your respawn location." , x - 210, y); "update your respawn location.", x - 210, y);
context.fillText("Press esc to go back", x - 150, y + 300); context.fillText("Press esc to go back", x - 150, y + 300);
context.restore(); context.restore();
} } else {
else {
context.drawImage(background1, 0, 0, this.width, this.height); context.drawImage(background1, 0, 0, this.width, this.height);
int bg2Index = (int) (-moveSky / this.width)-1; int bg2Index = (int) (-moveSky / this.width) - 1;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
context.drawImage(background2, this.width * (bg2Index + i) + moveSky, 0, this.width, this.height); context.drawImage(background2, this.width * (bg2Index + i) - moveSky, 0, this.width, this.height);
moveSky -= 0.1; moveSky += 0.1;
int bg3Index = (int) (player.getX()*0.15/this.width)-1; int bg3Index = (int) (player.getX() * 0.15 / this.width) - 1;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
context.drawImage(background3, this.width/2 + this.width*(bg3Index + i) - player.getX()*0.15 + player.screenX, 0, this.width, this.height); context.drawImage(background3, this.width / 2 + this.width * (bg3Index + i) - player.getX() * 0.15 + player.screenX, 0, this.width, this.height);
//TREE //TREE
for (Tree tree : ListTrees) { for (Tree tree : ListTrees) {
int tree_w = tree.getWidth(); tree.drawTree(context, player);
int tree_h = tree.getHeight();
double tree_xPos = (tree.getX() - tree_w / 2.0) - player.getX() + player.screenX;
double tree_yPos = (tree.getY() - tree_h / 2.0);
context.drawImage(treeImg, tree_xPos, tree_yPos, tree_w, tree_h);
} }
//WAFFLE DISPLAY //WAFFLE DISPLAY
context.drawImage(waffleImg, 10, 55, 50, 50); context.drawImage(waffleImg, 10, 55, 50, 50);
waffle.waffleCount(context, player); wafflePoint.waffleCount(context, player);
if (player.getX() < 200) { if (player.getX() < 200) {
waffle.drawWaffleText(context, this.width, this.height); wafflePoint.drawWaffleText(context, this.width, this.height);
} }
//WALLS //WALLS
for (Wall wall : ListWalls) { for (Wall wall : ListWalls) {
if (wall.type == "grass") { wall.drawWall(context, player);
int walls_w = wall.getWidth();
int walls_h = wall.getHeight();
double walls_xPos = (wall.getX() - walls_w / 2.0) - player.getX() + player.screenX;
double walls_yPos = (wall.getY() - walls_h / 2.0);
context.drawImage(platformGrass, walls_xPos, walls_yPos, walls_w, walls_h);
}
if (wall.type == "box") {
int walls_w = wall.getWidth();
int walls_h = wall.getHeight();
double walls_xPos = (wall.getX() - walls_w / 2.0) - player.getX() + player.screenX;
double walls_yPos = (wall.getY() - walls_h / 2.0);
context.drawImage(box, walls_xPos, walls_yPos, walls_w, walls_h);
}
} }
//ENEMY //ENEMY
for (Enemy enemy : ListEnemy) { for (Enemy enemy : ListEnemy) {
enemy.drawEnemy(context, player); enemy.drawEnemy(context, player);
...@@ -422,13 +403,7 @@ public class Game extends Application { ...@@ -422,13 +403,7 @@ public class Game extends Application {
//WAFFLE //WAFFLE
for (Waffle waffle : ListWaffle) { for (Waffle waffle : ListWaffle) {
int waffle_w = waffle.getWidth(); waffle.drawWaffle(context, player);
int waffle_h = waffle.getHeight();
double waffle_xPos = (waffle.getX() - waffle_w / 2.0) - player.getX() + player.screenX;
double waffle_yPos = (waffle.getY() - waffle_h / 2.0);
waffle.drawWafflePoints(context, waffle_xPos, waffle_yPos, waffle_w, waffle_h);
} }
for (Checkpoint checkpoint : ListCheckpoint) { for (Checkpoint checkpoint : ListCheckpoint) {
...@@ -452,6 +427,6 @@ public class Game extends Application { ...@@ -452,6 +427,6 @@ public class Game extends Application {
} }
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment