Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanda Ma committed Dec 16, 2014
1 parent 338e535 commit 90fdef2
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 83 deletions.
70 changes: 0 additions & 70 deletions src/game2/MysteryObj.java

This file was deleted.

20 changes: 14 additions & 6 deletions src/game2/Player.java
Expand Up @@ -6,6 +6,7 @@

package game2;
import java.util.*;
import javalib.colors.Yellow;
import javalib.worldimages.*;

/**
Expand All @@ -19,7 +20,9 @@ public class Player {
final int playerHeight = 50;
final int moveCase = 5;
final int doorSize = 100;


final static int myW = RunMaze.screenWidth;

int screenWidth;
int screenHeight;

Expand Down Expand Up @@ -69,7 +72,7 @@ public Player(int screenWidth, int screenHeight){
this.blue = 5;
this.yellow = 5;
this.inBattle = false;
this.eventNum = 5;
this.eventNum = 6;

}
public Player(int screenWidth, int screenHeight, Posn position, int entered,
Expand Down Expand Up @@ -185,7 +188,7 @@ public Player leavingRoom() {
boolean leftRightLeave = (this.position.y < this.screenHeight/2 - this.doorSize/2 + this.playerHeight/2)
&& (this.position.y > this.screenHeight/2 + this.doorSize/2 - this.playerHeight/2);

//if the opject is opened
//if the spacebar has been pressed
if (this.spacebar) {
//if it's trying to leave above
if (this.position.y - this.playerHeight/2 < 0) /*up, 1*/{
Expand Down Expand Up @@ -246,9 +249,9 @@ public Player leavingRoom() {
return edge4;
} else if (this.position.x + this.playerHeight/2 > this.screenHeight) /*right, 2*/ {
return edge2;
} else {
return this;
}
}

return this;
}


Expand All @@ -262,6 +265,11 @@ public Player onTick(){
return this;
}

public WorldImage playerImage() {
return new RectangleImage(this.position,
this.playerWidth , this.playerHeight, new Yellow());
}

}


74 changes: 67 additions & 7 deletions src/game2/RunMaze.java
Expand Up @@ -19,36 +19,96 @@
*/
public class RunMaze extends World {

final int screenWidth = 400;
final int screenHeight = 500;
final static int screenWidth = 400;
final static int screenHeight = 500;

MysteryObj mysteryObj;
Player player;

int level;

//for the start of the game
public RunMaze(){
new RunMaze(1, 5, 5, 5 new Player(screenWidth, screenHeight));
this(1, 5, 5, 5, new Player(screenWidth, screenHeight));
}

//for getting out of the battle
public RunMaze(int level, int red, int blue, int yellow, Player player) {
super();
this.level = level;
this.player = player.setShields(red, blue, yellow);
}

//for the duration of the maze
public RunMaze(Player player, int level){
super();
this.player = player;
this.level = level;
}

public WorldEnd worldEnds(){
if(this.player.level >= 10){
return new WorldEnd(true, new OverlayImages(this.makeImage(),
new TextImage(new Posn(screenWidth/2,screenHeight/2),
("You've defeated them all!"),
20, new White())));
} else {
return new WorldEnd(false, this.makeImage());
}
}

public World onKey(String key){
public World onKeyEvent(String key){
return new RunMaze(this.player.onKey(key), this.level);
}

public World onTick(){
\
if (this.player.inBattle) {
return new RunBattle(this.level, this.player.red, this.player.blue,
this.player.yellow, this.player);
} else {
return new RunMaze(this.player.onTick(), this.level);
}
}

private WorldImage background(){
return new RectangleImage(new Posn(screenWidth/2, screenHeight/2),
screenWidth, screenHeight, new Black());
}

private WorldImage eventImage(){
String eventCase;
if (this.player.eventNum == 0) {
eventCase = "Battle is on!";
} else if (this.player.eventNum == 1) {
eventCase = "Replenished Red Shield";
} else if (this.player.eventNum == 2) {
eventCase = "Replenished Blue Shield";
} else if (this.player.eventNum == 3) {
eventCase = "Replenished Blue Shield!";
} else if (this.player.eventNum == 4) {
eventCase = "Luck or not, you get nothing from this room";
} else if (this.player.eventNum == 5) {
eventCase = "You've hit the spacebar already, leave!";
} else {
eventCase = "You have to hit the spacebar";
}

return new TextImage(new Posn(this.screenWidth/2, 15),
(eventCase),10, new White());
}


public WorldImage makeImage(){
return new OverlayImages(background(),
new OverlayImages(player.playerImage(), eventImage()));
/*return new RectangleImage(new Posn(screenWidth/2, screenHeight/2),
screenWidth, screenHeight, new Black());*/
}



public static void main (String[] args) {
RunMaze game = new RunMaze();

game.bigBang(400, 500, 0.15);
}
}

0 comments on commit 90fdef2

Please sign in to comment.