Commit fe25bb21 authored by Yuhan Chen's avatar Yuhan Chen
Browse files

New update

parent 68f4e565
...@@ -4,10 +4,10 @@ Lewisburg, PA ...@@ -4,10 +4,10 @@ Lewisburg, PA
### Course Info ### Course Info
Instructor: Prof. Dancy Instructor: Prof. Dancy
Semester: SP21 Semester: SP21
## Team Information: Baba is us ## Team Information: Rule.Baba is us
Anh Tran, Nguyen Nguyen, Christiaan Smith, Yuhan Chen Anh Tran, Nguyen Nguyen, Christiaan Smith, Yuhan Chen
## Project Information ## Project Information
Final Project: Baba is you Final Project: Rule.Baba is you
## Project description: ## Project description:
<br>The original Baba is You game is a level-based puzzle game, where the game rules are present as blocks you can interact with. By manipulating them, the user can change the game rules in order to find out a way to get to the “win” condition. The game never gives you an answer on how to approach each puzzle, the only rules you follow are those that are shown on the screen by the blocks when pushed together to form sentences for example the three blocks pushed together. For example, forming “BABA” + “IS” + “YOU”, would give the player control to move the BABA object on the screen. If these blocks are disconnected, then their rule no longer applies to the game environment until they are reconnected. <br>The original Rule.Baba is You game is a level-based puzzle game, where the game rules are present as blocks you can interact with. By manipulating them, the user can change the game rules in order to find out a way to get to the “win” condition. The game never gives you an answer on how to approach each puzzle, the only rules you follow are those that are shown on the screen by the blocks when pushed together to form sentences for example the three blocks pushed together. For example, forming “BABA” + “IS” + “YOU”, would give the player control to move the BABA object on the screen. If these blocks are disconnected, then their rule no longer applies to the game environment until they are reconnected.
<br>There are three different kinds of blocks to make rules in the game, Ones representing Objects in the level, ones representing actions, and ones used to connect these together. There are many many different rule blocks in the original game, so as to reduce the complexity of the project to a more manageable level, we will be creating smaller grid maps, and use a smaller list of possible rule blocks. We can also reduce the number of levels needed to maybe 4 or 5 to make it simpler to implement. <br>There are three different kinds of blocks to make rules in the game, Ones representing Objects in the level, ones representing actions, and ones used to connect these together. There are many many different rule blocks in the original game, so as to reduce the complexity of the project to a more manageable level, we will be creating smaller grid maps, and use a smaller list of possible rule blocks. We can also reduce the number of levels needed to maybe 4 or 5 to make it simpler to implement.
Baba image is downloaded from "https://twitter.com/babaisyou_" Rule.Baba image is downloaded from "https://twitter.com/babaisyou_"
\ No newline at end of file \ No newline at end of file
...@@ -113,7 +113,7 @@ public class BabaIsYouGameGUI extends Application { ...@@ -113,7 +113,7 @@ public class BabaIsYouGameGUI extends Application {
// * @param boardHeight height of the board generated // * @param boardHeight height of the board generated
// * @param boardWidth width of the board generated // * @param boardWidth width of the board generated
// */ // */
// public BabaIsYouGameGUI(GeneralObject[] objList, int boardHeight, int boardWidth){ // public BabaIsYouGameGUI(Rule.GeneralObject[] objList, int boardHeight, int boardWidth){
// //
// } // }
...@@ -135,7 +135,7 @@ public class BabaIsYouGameGUI extends Application { ...@@ -135,7 +135,7 @@ public class BabaIsYouGameGUI extends Application {
//Setting the scene //Setting the scene
stage.setScene(scene); stage.setScene(scene);
stage.setTitle("Baba Is You"); stage.setTitle("Rule.Baba Rule.Is You");
stage.show(); stage.show();
//Timeline for character animation //Timeline for character animation
...@@ -322,8 +322,8 @@ public class BabaIsYouGameGUI extends Application { ...@@ -322,8 +322,8 @@ public class BabaIsYouGameGUI extends Application {
} }
/** /**
* Check if Baba-Is-Pass is viable. Return true if so. * Check if Rule.Baba-Rule.Is-Pass is viable. Return true if so.
* @return true if Baba-Is-Pass, false otherwise * @return true if Rule.Baba-Rule.Is-Pass, false otherwise
*/ */
private boolean isPassable(){ private boolean isPassable(){
if (babaObj.getX() == (isObj.getX()-SQUARE_SIZE) && (isObj.getX() == (passObj.getX()-SQUARE_SIZE)) if (babaObj.getX() == (isObj.getX()-SQUARE_SIZE) && (isObj.getX() == (passObj.getX()-SQUARE_SIZE))
......
...@@ -57,10 +57,10 @@ public class BabaIsYouGameGUIModel { ...@@ -57,10 +57,10 @@ public class BabaIsYouGameGUIModel {
/** List of objects */ /** List of objects */
private ArrayList<Point> objs; private ArrayList<Point> objs;
// private ArrayList<GeneralObject> entityList; // private ArrayList<Rule.GeneralObject> entityList;
// private ArrayList<GeneralObject> nameWordList; // private ArrayList<Rule.GeneralObject> nameWordList;
// private ArrayList<GeneralObject> connectorWordList = new ArrayList<GeneralObject>(); // private ArrayList<Rule.GeneralObject> connectorWordList = new ArrayList<Rule.GeneralObject>();
// private ArrayList<GeneralObject> ruleWordList = new ArrayList<GeneralObject>(); // private ArrayList<Rule.GeneralObject> ruleWordList = new ArrayList<Rule.GeneralObject>();
/** The in-game scene */ /** The in-game scene */
protected static Scene scene; protected static Scene scene;
...@@ -70,15 +70,15 @@ public class BabaIsYouGameGUIModel { ...@@ -70,15 +70,15 @@ public class BabaIsYouGameGUIModel {
} }
// private void generateObjsFromList(GeneralObject[] objList) { // private void generateObjsFromList(Rule.GeneralObject[] objList) {
// for (int i=0; i<objList.length; i++){ // for (int i=0; i<objList.length; i++){
// if (objList[i].getType().equals("Entity")) // if (objList[i].getType().equals("Rule.Entity"))
// entityList.add(objList[i]); // entityList.add(objList[i]);
// else if (objList[i].getType().equals("NameWord")) // else if (objList[i].getType().equals("Rule.NameWord"))
// nameWordList.add(objList[i]); // nameWordList.add(objList[i]);
// else if (objList[i].getType().equals("RuleWord")) // else if (objList[i].getType().equals("Rule.RuleWord"))
// ruleWordList.add(objList[i]); // ruleWordList.add(objList[i]);
// else if (objList[i].getType().equals("ConnectorWord")) // else if (objList[i].getType().equals("Rule.ConnectorWord"))
// connectorWordList.add(objList[i]); // connectorWordList.add(objList[i]);
// //
// } // }
...@@ -139,8 +139,8 @@ public class BabaIsYouGameGUIModel { ...@@ -139,8 +139,8 @@ public class BabaIsYouGameGUIModel {
/** /**
* Check if Baba-Is-Pass is viable. Return true if so. * Check if Rule.Baba-Rule.Is-Pass is viable. Return true if so.
* @return true if Baba-Is-Pass, false otherwise * @return true if Rule.Baba-Rule.Is-Pass, false otherwise
*/ */
public boolean isPassable(){ public boolean isPassable(){
if (babaObj.getX() == (isObj.getX()-SQUARE_SIZE) && (isObj.getX() == (passObj.getX()-SQUARE_SIZE)) if (babaObj.getX() == (isObj.getX()-SQUARE_SIZE) && (isObj.getX() == (passObj.getX()-SQUARE_SIZE))
...@@ -151,8 +151,8 @@ public class BabaIsYouGameGUIModel { ...@@ -151,8 +151,8 @@ public class BabaIsYouGameGUIModel {
} }
/** /**
* Check if Baba-Is-Win is viable. Return true if so. * Check if Rule.Baba-Rule.Is-Rule.Win is viable. Return true if so.
* @return true if Baba-Is-Pass, false otherwise * @return true if Rule.Baba-Rule.Is-Pass, false otherwise
*/ */
public boolean isNextLvl(){ public boolean isNextLvl(){
if (babaObj.getX() == (isObj.getX()-SQUARE_SIZE) && (isObj.getX() == (winObj.getX()-SQUARE_SIZE)) if (babaObj.getX() == (isObj.getX()-SQUARE_SIZE) && (isObj.getX() == (winObj.getX()-SQUARE_SIZE))
......
/* ***************************************** package Rule;/* *****************************************
* CSCI205 - Software Engineering and Design * CSCI205 - Software Engineering and Design
* Spring 2021 * Spring 2021
* Instructor: Prof. Chris Dancy * Instructor: Prof. Chris Dancy
...@@ -19,21 +19,17 @@ ...@@ -19,21 +19,17 @@
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import java.util.Objects;
public class Baba extends NameWordImpl { public class Baba extends NameWordImpl {
private int x; public int x;
private int y; public int y;
public String name = "Baba"; public String name = "Baba";
javafx.scene.image.Image image = new javafx.scene.image.Image(getClass().getResource("/image/Baba.png").toExternalForm(), 40, 40, false, false); javafx.scene.image.Image image = new javafx.scene.image.Image(getClass().getResource("/image/Baba.png").toExternalForm(), 40, 40, false, false);
public Baba(int x, int y) { public Baba(int x, int y) {
this.x = x; setCoordinate(x,y);
this.y = y;
} }
@Override @Override
...@@ -47,6 +43,8 @@ public class Baba extends NameWordImpl { ...@@ -47,6 +43,8 @@ public class Baba extends NameWordImpl {
@Override public boolean isPushable() {return true;} @Override public boolean isPushable() {return true;}
public boolean isPassable() {return false;}
} }
/* ***************************************** package Rule;/* *****************************************
* CSCI205 - Software Engineering and Design * CSCI205 - Software Engineering and Design
* Spring 2021 * Spring 2021
* Instructor: Prof. Chris Dancy * Instructor: Prof. Chris Dancy
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* Project: CSCI205SP21finalproject * Project: CSCI205SP21finalproject
* Package: PACKAGE_NAME * Package: PACKAGE_NAME
* Class: ConnectorWord * Class: Rule.ConnectorWord
* *
* Description: THIS IS A DESCRIPTION Y’ALL AND I NEED TO CHANGE THIS! * Description: THIS IS A DESCRIPTION Y’ALL AND I NEED TO CHANGE THIS!
* *
......
/* ***************************************** package Rule;/* *****************************************
* CSCI205 - Software Engineering and Design * CSCI205 - Software Engineering and Design
* Spring 2021 * Spring 2021
* Instructor: Prof. Chris Dancy * Instructor: Prof. Chris Dancy
...@@ -10,19 +10,18 @@ ...@@ -10,19 +10,18 @@
* *
* Project: CSCI205SP21finalproject * Project: CSCI205SP21finalproject
* Package: PACKAGE_NAME * Package: PACKAGE_NAME
* Class: DemoRule * Class: Rule.DemoRuleOne
* *
* Description: Includes all rules and win conditions to the demo * Description: Includes all rules and win conditions to the demo
* *
* **************************************** * ****************************************
*/ */
import javafx.scene.Scene;
import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCode;
import java.util.ArrayList; import java.util.ArrayList;
public class DemoRule { public class DemoRuleOne {
/** The width of the board */ /** The width of the board */
private static final int WIDTH = 800; private static final int WIDTH = 800;
/** The height of the board */ /** The height of the board */
...@@ -45,8 +44,8 @@ public class DemoRule { ...@@ -45,8 +44,8 @@ public class DemoRule {
public static NameWordImpl player = new NameWordImpl(); public static NameWordImpl player = new NameWordImpl();
//TODO: initialize the player to baba //TODO: initialize the player to baba
//ruleBaba represents the rule "Baba is win" //ruleBaba represents the rule "Rule.Baba is win"
//ruleRock represents the rule "Rock is win" //ruleRock represents the rule "Rule.Rock is win"
public static boolean ruleBaba = false; public static boolean ruleBaba = false;
public static boolean ruleRock = false; public static boolean ruleRock = false;
...@@ -133,54 +132,10 @@ public class DemoRule { ...@@ -133,54 +132,10 @@ public class DemoRule {
objs.add(winObj); objs.add(winObj);
} }
/**
* The current object that player manipulate can be moved only when the objects can be moved
* and cannot touch the boundary of the board
* @return whether the object is pushable
*/
public static boolean isPushable(KeyCode key) {
GeneralObject boundaryObj = player;
if (player.isPushable() == false) {return false;}
switch (key) {
case DOWN:
while (!atObjectLocation(boundaryObj).equals(boundaryObj)) {
if (boundaryObj.getY() == HEIGHT) {
return false;
}
boundaryObj = atObjectLocation(boundaryObj);
}
return true;
case UP:
while (!nearObjectDown(boundaryObj).equals(boundaryObj)) {
if (boundaryObj.getY() == 0) {
return false;
}
boundaryObj = nearObjectDown(boundaryObj);
}
return true;
case RIGHT:
while (!atObjectLocation(boundaryObj).equals(boundaryObj)) {
if (boundaryObj.getX() == WIDTH) {
return false;
}
boundaryObj = atObjectLocation(boundaryObj);
}
return true;
case LEFT:
while (!atObjectLocation(boundaryObj).equals(boundaryObj)) {
if (boundaryObj.getX() == 0) {
return false;
}
boundaryObj = atObjectLocation(boundaryObj);
}
return true;
}
return true;
}
public static void moveCharacter(KeyCode code) { public static void moveCharacter(KeyCode code) {
GeneralObject generalObject = player; GeneralObject generalObject = player;
if (isPushable(code)) { if (player.isPushable()) {
if (code == KeyCode.UP) { if (code == KeyCode.UP) {
player.move(0,-SQUARE_SIZE); player.move(0,-SQUARE_SIZE);
while(!atObjectLocation(generalObject).equals(generalObject)){ while(!atObjectLocation(generalObject).equals(generalObject)){
...@@ -214,7 +169,7 @@ public class DemoRule { ...@@ -214,7 +169,7 @@ public class DemoRule {
/** /**
* The character that the player manipulate is changed in two condition: * The character that the player manipulate is changed in two condition:
* "Baba is rock" or "Rock is baba" * "Rule.Baba is rock" or "Rule.Rock is baba"
*/ */
public static void changeCharacter() { public static void changeCharacter() {
if (player.equals(babaObj)) { if (player.equals(babaObj)) {
...@@ -229,7 +184,7 @@ public class DemoRule { ...@@ -229,7 +184,7 @@ public class DemoRule {
if (nearObjectLeft(rockObj).equals(isObj) && nearObjectRight(babaObj).equals(isObj)) { if (nearObjectLeft(rockObj).equals(isObj) && nearObjectRight(babaObj).equals(isObj)) {
player = babaObj; player = babaObj;
} }
if (nearObjectUp(babaObj).equals(isObj) && nearObjectDown(babaObj).equals((isObj))) { if (nearObjectUp(rockObj).equals(isObj) && nearObjectDown(babaObj).equals((isObj))) {
player = babaObj; player = babaObj;
} }
} }
...@@ -237,7 +192,7 @@ public class DemoRule { ...@@ -237,7 +192,7 @@ public class DemoRule {
/** /**
* Two win condition: * Two win condition:
* if the character that player moves is the one that has set up in the rule, then win * if the character that player manipulates is the one that has set up in the rule, then win
* if the character that player moves is adjacent to the NameObject that has set up in the rule, then win * if the character that player moves is adjacent to the NameObject that has set up in the rule, then win
* @return win or not yet * @return win or not yet
*/ */
...@@ -267,15 +222,19 @@ public class DemoRule { ...@@ -267,15 +222,19 @@ public class DemoRule {
* The rule is only established when "baba is win" or " rock is win" is connected * The rule is only established when "baba is win" or " rock is win" is connected
*/ */
public static void ruleChange() { public static void ruleChange() {
ruleBaba = false;
ruleRock = false;
if (nearObjectLeft(babaObj).equals(isObj) && nearObjectRight(winObj).equals(isObj)) { if (nearObjectLeft(babaObj).equals(isObj) && nearObjectRight(winObj).equals(isObj)) {
ruleBaba = true; ruleBaba = true;
} }
if (nearObjectLeft(rockObj).equals(isObj) && nearObjectRight(babaObj).equals(isObj)) { if (nearObjectUp(babaObj).equals(isObj) && nearObjectDown(winObj).equals(isObj)) {
ruleBaba = true;
}
if (nearObjectLeft(rockObj).equals(isObj) && nearObjectRight(winObj).equals(isObj)) {
ruleRock = true; ruleRock = true;
} }
else { if (nearObjectUp(rockObj).equals(isObj) && nearObjectDown(winObj).equals(isObj)) {
ruleBaba = false; ruleRock = true;
ruleRock = false;
} }
} }
} }
\ No newline at end of file
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2021
* Instructor: Prof. Chris Dancy
*
* Name: Yuhan Chen
* Section: YOUR SECTION
* Date: 5/18/2021
* Time: 2:30 AM
*
* Project: CSCI205SP21finalproject
* Package: Rule
* Class: DemoRuleThree
*
* Description: THIS IS A DESCRIPTION Y’ALL AND I NEED TO CHANGE THIS!
*
* ****************************************
*/
package Rule;
import javafx.scene.input.KeyCode;
import java.util.ArrayList;
public class DemoRuleThree {
/** The width of the board */
private static final int WIDTH = 800;
/** The height of the board */
private static final int HEIGHT = 800;
/** The number of rows of the board */
private static final int ROWS = 20;
/** The number of columns of the board */
private static final int COLUMNS = 20;
/** The size of a square */
private static final int SQUARE_SIZE = WIDTH/ROWS;
//Generate objects for the demo
public static Baba babaObj = new Baba(400,520);
public static Is isObjOne = new Is(240,200);
public static Is isObjTwo = new Is(480,520);
public static Win winObj = new Win(400,240);
public static WallText wallTextOne = new WallText(520,520);
public static WallText wallTextTwo = new WallText(200,200);
public static Stop stopObj = new Stop(280,200);
public static Wall wallKeyObj = new Wall(760, 400);
public static ArrayList<Wall> wallObjs = new ArrayList<Wall>(20);
//Generate Rule.Wall objects
public static void setWallObjs(ArrayList<Wall> wallObjs) {
for (int i = 0; i < 760; i += 40) {
wallObjs.add(new Wall(i, 400));
}
}
// Generate a character that player currently moved
public static NameWordImpl player = new NameWordImpl();
//ruleStop represents the rule "baba is wall"
//ruleWin represents the rule "wall win"
public static boolean ruleWall = false;
public static boolean ruleWin = false;
//Create a list for all objects
public static ArrayList<GeneralObject> objs = new ArrayList<GeneralObject>();
//Set the object list
public static void setObjs(ArrayList<GeneralObject> objs) {
objs.add(babaObj);
objs.add(wallTextOne);
objs.add(wallTextTwo);
objs.add(isObjOne);
objs.add(isObjTwo);
objs.add(winObj);
objs.add(stopObj);
objs.add(wallKeyObj);
objs.addAll(wallObjs);
}
/**
* Check if the character is on the right a normal object
* @return the normal object
*/
public static GeneralObject atObjectLocation(GeneralObject generalObject){
for (GeneralObject obj: objs) {
if(!obj.equals(generalObject)) {
if (generalObject.getX() == (obj.getX()) && generalObject.getY() == obj.getY())
return obj;
}
}
return generalObject;
}
/**
* Check if the character is on the right a normal object
* @return the normal object
*/
public static GeneralObject nearObjectRight(GeneralObject generalObject){
for (GeneralObject obj: objs) {
if(!obj.equals(generalObject)) {
if (generalObject.getX() == (obj.getX()+ SQUARE_SIZE) && generalObject.getY() == obj.getY())
return obj;
}
}
return generalObject;
}
/**
* Check if the character is on the right a normal object
* @return the normal object
*/
public static GeneralObject nearObjectLeft(GeneralObject generalObject){
for (GeneralObject obj: objs) {
if(!obj.equals(generalObject)) {
if (generalObject.getX() == (obj.getX() - SQUARE_SIZE) && generalObject.getY() == obj.getY())
return obj;
}
}
return generalObject;
}
/**
* Check if the character is above a normal object
* @return the normal object
*/
public static GeneralObject nearObjectUp(GeneralObject generalObject){
for (GeneralObject obj: objs) {
if (!obj.equals(generalObject)) {
if ((generalObject.getX() == obj.getX()) && (generalObject.getY() == obj.getY()-SQUARE_SIZE))
return obj;
}
}
return generalObject;
}
/**
* Check if the character is below a normal object
* @return the normal object
*/
public static GeneralObject nearObjectDown(GeneralObject generalObject){
for (GeneralObject obj: objs) {
if (!obj.equals(generalObject)) {
if ((generalObject.getX() == obj.getX()) && (generalObject.getY() == obj.getY()+SQUARE_SIZE))
return obj;
}
}
return generalObject;
}
public static boolean isPassable(KeyCode code) {
switch (code) {
case DOWN:
if (!nearObjectUp(player).equals(player)) {
if (nearObjectUp(player).isPassable()) {
return true;
}
else {return false;}
}
else {return true;}
case UP:
if (!nearObjectDown(player).equals(player)) {
if (nearObjectDown(player).isPassable()) {
return true;
}
else {return false;}
}
else {return true;}
case RIGHT:
if (!nearObjectLeft(player).equals(player)) {
if (nearObjectLeft(player).isPassable()) {
return true;
}
else {return false;}
}
else {return true;}
case LEFT:
if (!nearObjectRight(player).equals(player)) {
if (nearObjectRight(player).isPassable()) {
return true;
}
else {return false;}
}
else {return false;}
}
return false;
}
public static void moveCharacter(KeyCode code) {
GeneralObject generalObject = player;
if (player.isPushable()) {