diff --git a/MathHero/.gitignore b/MathHero/.gitignore deleted file mode 100644 index 452bd8a..0000000 --- a/MathHero/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -bin/ -doc/ -*.class -*.jar diff --git a/MathHero/Makefile b/MathHero/Makefile deleted file mode 100644 index a74cbe9..0000000 --- a/MathHero/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -src=src/*.java -pkg=mathhero.jar -main=MathHero - - -all: - mkdir -p bin - javac ${src} -d bin/ - -package: all - ../package.sh ${pkg} ${main} - -doc: - javadoc ${src} -d doc/ - -play: all - java -cp bin/ ${main} - -clean: - rm -rf bin - rm -rf doc - rm -f ${pkg} diff --git a/MathHero/README.md b/MathHero/README.md deleted file mode 100644 index 4b8d932..0000000 --- a/MathHero/README.md +++ /dev/null @@ -1,15 +0,0 @@ -MathHero -======== - -Solve simple math problems until you die. (Like working as an accountant.) - - * To build: `make` - * To package: `make package` - * To get the docs: `make doc` - * To play: `make play` - -Instructions ------------- - -The problems will come at you. Type the answer and hit enter or they'll kill you. -When you die, you can use the key in the top right to return to the same level. Just type it once you start a new game, then hit enter. diff --git a/MathHero/src/World.java b/MathHero/src/World.java deleted file mode 100644 index edd3c7b..0000000 --- a/MathHero/src/World.java +++ /dev/null @@ -1,139 +0,0 @@ -import java.awt.*; -import java.util.*; - -public class World -{ - public Player player; - public Level[] levels; - public int level = 0; - public boolean win = false; - public boolean lose = false; - - public World(Player player, Level... levels) - { - this.player = player; - this.levels = levels; - } - - public void tryKey(int key) - { - for(int i = 0; i < levels.length; i++) - { - if(levels[i].key==key) - { - level = i; - i = levels.length; - } - } - } - - public Level getLevel() - { - return levels[level]; - } - - public void update() - { - if(!win && !lose) - { - getLevel().update(); - player.hit(getLevel().getHitting()); - if(player.dead()) - lose = true; - if(getLevel().finished()&& !lose) - { - player.heal(); - level++; - if(level==levels.length) - { - win = true; - level--; - } - } - } - } - - public void draw(Graphics g) - { - getLevel().drawEnemies(g); - player.draw(g); - g.setColor(Color.BLACK); - g.drawString("Level: "+(level+1),5,15); - g.drawString("Key: "+getLevel().key,Util.MAX_R*2-90,15); - if(win) - { - g.setColor(Color.GREEN); - g.setFont(new Font("Verdana",Font.BOLD,14)); - g.drawString("You WIN!",140,150); - } - if(lose) - { - g.setColor(Color.RED); - g.setFont(new Font("Verdana",Font.BOLD,14)); - g.drawString("You lose.",140,150); - } - } - - public static World getWorld() - { - Player player = new Player(); - - //Level 1 - Vector l1e = new Vector(); - for(int i = 0; i < 10; i ++) l1e.add(new Addition()); - Level l1 = new Level(2,1234567,l1e); - - //Level 2 - Vector l2e = new Vector(); - for(int i = 0; i < 8; i ++) l2e.add(new Addition()); - for(int i = 0; i < 5; i ++) l2e.add(new Multiplication()); - Level l2 = new Level(2,6394658,l2e); - - //Level 3 - Vector l3e = new Vector(); - for(int i = 0; i < 5; i ++) l3e.add(new Addition()); - for(int i = 0; i < 8; i ++) l3e.add(new Multiplication()); - Level l3 = new Level(3,1563826,l3e); - - //Level 4 - Vector l4e = new Vector(); - for(int i = 0; i < 7; i ++) l4e.add(new Addition()); - for(int i = 0; i < 7; i ++) l4e.add(new Multiplication()); - for(int i = 0; i < 3; i ++) l4e.add(new Subtraction()); - Level l4 = new Level(3,1927462,l4e); - - //Level 5 - Vector l5e = new Vector(); - for(int i = 0; i < 7; i ++) l5e.add(new Addition()); - for(int i = 0; i < 7; i ++) l5e.add(new Multiplication()); - for(int i = 0; i < 5; i ++) l5e.add(new Subtraction()); - for(int i = 0; i < 3; i ++) l5e.add(new Division()); - Level l5 = new Level(3,3728465,l5e); - - //Level 6 - Vector l6e = new Vector(); - for(int i = 0; i < 7; i ++) l6e.add(new Addition()); - for(int i = 0; i < 7; i ++) l6e.add(new Multiplication()); - for(int i = 0; i < 7; i ++) l6e.add(new Subtraction()); - for(int i = 0; i < 5; i ++) l6e.add(new Division()); - Level l6 = new Level(3,7384920,l6e); - - //Level 7 - Vector l7e = new Vector(); - for(int i = 0; i < 5; i ++) l7e.add(new BigAddition()); - for(int i = 0; i < 7; i ++) l7e.add(new Multiplication()); - for(int i = 0; i < 7; i ++) l7e.add(new Subtraction()); - for(int i = 0; i < 7; i ++) l7e.add(new Division()); - Level l7 = new Level(3,6374198,l7e); - - //Level 8 - Vector l8e = new Vector(); - for(int i = 0; i < 5; i ++) l8e.add(new BigAddition()); - for(int i = 0; i < 1; i ++) l8e.add(new BigMultiplication()); - for(int i = 0; i < 7; i ++) l8e.add(new Subtraction()); - for(int i = 0; i < 7; i ++) l8e.add(new Division()); - Level l8 = new Level(3,1738295,l8e); - - return new World(player,l1,l2,l3,l4,l5,l6,l7,l8); - } -} \ No newline at end of file diff --git a/MathHero2/pom.xml b/MathHero2/pom.xml new file mode 100644 index 0000000..d90fbf7 --- /dev/null +++ b/MathHero2/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + com.espol + MathHero2 + 1.0-SNAPSHOT + jar + + UTF-8 + 11 + 11 + + \ No newline at end of file diff --git a/MathHero/src/Addition.java b/MathHero2/src/main/java/com/espol/mathhero2/Addition.java similarity index 92% rename from MathHero/src/Addition.java rename to MathHero2/src/main/java/com/espol/mathhero2/Addition.java index 5d79d9c..9e0a67b 100644 --- a/MathHero/src/Addition.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Addition.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class Addition extends Enemy { protected String problem; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/AdditionEnemyFactory.java b/MathHero2/src/main/java/com/espol/mathhero2/AdditionEnemyFactory.java new file mode 100644 index 0000000..59b6ead --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/AdditionEnemyFactory.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.espol.mathhero2; + +public class AdditionEnemyFactory implements EnemyFactory { + @Override + public Enemy createSmallEnemy() { + return new Addition(); + } + + @Override + public Enemy createBigEnemy() { + return new BigAddition(); + } +} diff --git a/MathHero/src/BigAddition.java b/MathHero2/src/main/java/com/espol/mathhero2/BigAddition.java similarity index 92% rename from MathHero/src/BigAddition.java rename to MathHero2/src/main/java/com/espol/mathhero2/BigAddition.java index 8afbdb5..08b8dfb 100644 --- a/MathHero/src/BigAddition.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/BigAddition.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class BigAddition extends Enemy { protected String problem; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/BigDivision.java b/MathHero2/src/main/java/com/espol/mathhero2/BigDivision.java new file mode 100644 index 0000000..eba4363 --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/BigDivision.java @@ -0,0 +1,35 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.espol.mathhero2; + +/** + * + * @author DELL + */ +public class BigDivision extends Enemy { + protected String problem; + protected int solution; + + public BigDivision() + { + super(.9); + int n1 = (int)(Math.random()*9)+1; + int n2 = (int)(Math.random()*9)+1; + solution = n1; + problem = ""+(n1*n2)+"/"+n2; + radius = 8; + color = java.awt.Color.RED; + } + + public String getProblem() + { + return problem; + } + + public int getSolution() + { + return solution; + } +} diff --git a/MathHero/src/BigMultiplication.java b/MathHero2/src/main/java/com/espol/mathhero2/BigMultiplication.java similarity index 93% rename from MathHero/src/BigMultiplication.java rename to MathHero2/src/main/java/com/espol/mathhero2/BigMultiplication.java index 3767702..0de546a 100644 --- a/MathHero/src/BigMultiplication.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/BigMultiplication.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class BigMultiplication extends Enemy { protected String problem; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/BigSubtraction.java b/MathHero2/src/main/java/com/espol/mathhero2/BigSubtraction.java new file mode 100644 index 0000000..e587e15 --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/BigSubtraction.java @@ -0,0 +1,35 @@ +package com.espol.mathhero2; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author DELL + */ +public class BigSubtraction extends Enemy { + protected String problem; + protected int solution; + + public BigSubtraction() + { + super(.8); + int n1 = (int)(Math.random()*9)+1; + int n2 = (int)(Math.random()*9)+1; + solution = n1; + problem = ""+(n1+n2)+"-"+n2; + color = java.awt.Color.RED; + } + + public String getProblem() + { + return problem; + } + + public int getSolution() + { + return solution; + } +} diff --git a/MathHero/src/Division.java b/MathHero2/src/main/java/com/espol/mathhero2/Division.java similarity index 93% rename from MathHero/src/Division.java rename to MathHero2/src/main/java/com/espol/mathhero2/Division.java index 9a69e58..5985f06 100644 --- a/MathHero/src/Division.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Division.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class Division extends Enemy { protected String problem; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/DivisionEnemyFactory.java b/MathHero2/src/main/java/com/espol/mathhero2/DivisionEnemyFactory.java new file mode 100644 index 0000000..ea8d338 --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/DivisionEnemyFactory.java @@ -0,0 +1,20 @@ +package com.espol.mathhero2; + +public class DivisionEnemyFactory implements EnemyFactory { + + public DivisionEnemyFactory() { + } + + @Override + public Enemy createSmallEnemy() { + return new Division(); + } + + @Override + public Enemy createBigEnemy() { + + return new BigDivision(); + + } + +} diff --git a/MathHero/src/Enemy.java b/MathHero2/src/main/java/com/espol/mathhero2/Enemy.java similarity index 98% rename from MathHero/src/Enemy.java rename to MathHero2/src/main/java/com/espol/mathhero2/Enemy.java index 47b01a8..3086895 100644 --- a/MathHero/src/Enemy.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Enemy.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; import java.awt.*; public abstract class Enemy diff --git a/MathHero2/src/main/java/com/espol/mathhero2/EnemyFactory.java b/MathHero2/src/main/java/com/espol/mathhero2/EnemyFactory.java new file mode 100644 index 0000000..58b2b4a --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/EnemyFactory.java @@ -0,0 +1,14 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.espol.mathhero2; + +/** + * + * @author DELL + */ +public interface EnemyFactory { + Enemy createSmallEnemy(); + Enemy createBigEnemy(); +} diff --git a/MathHero2/src/main/java/com/espol/mathhero2/Game.java b/MathHero2/src/main/java/com/espol/mathhero2/Game.java new file mode 100644 index 0000000..488f15a --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/Game.java @@ -0,0 +1,7 @@ +package com.espol.mathhero2; +public class Game { + public static void main(String[] args) { + GameFacade gameFacade = new GameFacade(); + gameFacade.startGame(); + } +} diff --git a/MathHero/src/GameComponent.java b/MathHero2/src/main/java/com/espol/mathhero2/GameComponent.java similarity index 99% rename from MathHero/src/GameComponent.java rename to MathHero2/src/main/java/com/espol/mathhero2/GameComponent.java index fe0e685..cf4cc40 100644 --- a/MathHero/src/GameComponent.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/GameComponent.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; import java.util.*; import java.awt.*; import java.awt.image.*; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/GameFacade.java b/MathHero2/src/main/java/com/espol/mathhero2/GameFacade.java new file mode 100644 index 0000000..804d71a --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/GameFacade.java @@ -0,0 +1,13 @@ +package com.espol.mathhero2; +public class GameFacade { + + private MathHero mathHero; + + public GameFacade() { + this.mathHero = new MathHero(); + } + + public void startGame() { + this.mathHero.makeTestWindow(); + } +} \ No newline at end of file diff --git a/MathHero/src/Level.java b/MathHero2/src/main/java/com/espol/mathhero2/Level.java similarity index 97% rename from MathHero/src/Level.java rename to MathHero2/src/main/java/com/espol/mathhero2/Level.java index 5551475..7ed3df9 100644 --- a/MathHero/src/Level.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Level.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; import java.util.*; import java.awt.*; diff --git a/MathHero/src/ListeningGameComponent.java b/MathHero2/src/main/java/com/espol/mathhero2/ListeningGameComponent.java similarity index 99% rename from MathHero/src/ListeningGameComponent.java rename to MathHero2/src/main/java/com/espol/mathhero2/ListeningGameComponent.java index 76b65d9..6bcf58b 100644 --- a/MathHero/src/ListeningGameComponent.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/ListeningGameComponent.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; import java.util.*; import java.awt.*; import java.awt.image.*; diff --git a/MathHero/src/MathHero.java b/MathHero2/src/main/java/com/espol/mathhero2/MathHero.java similarity index 70% rename from MathHero/src/MathHero.java rename to MathHero2/src/main/java/com/espol/mathhero2/MathHero.java index a68bb0f..5a824f3 100644 --- a/MathHero/src/MathHero.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/MathHero.java @@ -1,34 +1,28 @@ +package com.espol.mathhero2; import java.awt.*; import java.awt.event.*; public class MathHero extends ListeningGameComponent { - protected World world; + protected WorldSingleton world; protected String typed; - public MathHero() - { - super(Util.MAX_R*2,Util.MAX_R*2); - world = World.getWorld(); + { super(Util.MAX_R*2,Util.MAX_R*2); + world = WorldSingleton.getInstance(); typed = ""; start(); } - public void update() { world.update(); } - public void draw(Graphics g) - { - world.draw(g); + { world.draw(g); g.setColor(Color.BLACK); g.drawString(typed,5,30); } - public void keyTyped(KeyEvent ke) - { - if(ke.getKeyChar()=='\n'&&typed.length()>0) + { if(ke.getKeyChar()=='\n'&&typed.length()>0) { if(typed.length()==7) world.tryKey(Integer.parseInt(typed)); @@ -39,9 +33,4 @@ public void keyTyped(KeyEvent ke) if(Character.isDigit(ke.getKeyChar())) typed=typed+ke.getKeyChar(); } - - public static void main(String[] args) - { - new MathHero().makeTestWindow(); - } } diff --git a/MathHero/src/Multiplication.java b/MathHero2/src/main/java/com/espol/mathhero2/Multiplication.java similarity index 92% rename from MathHero/src/Multiplication.java rename to MathHero2/src/main/java/com/espol/mathhero2/Multiplication.java index 3ff7680..5409b49 100644 --- a/MathHero/src/Multiplication.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Multiplication.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class Multiplication extends Enemy { protected String problem; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/MultiplicationEnemyFactory.java b/MathHero2/src/main/java/com/espol/mathhero2/MultiplicationEnemyFactory.java new file mode 100644 index 0000000..e0ae14b --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/MultiplicationEnemyFactory.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.espol.mathhero2; + +public class MultiplicationEnemyFactory implements EnemyFactory { + @Override + public Enemy createSmallEnemy() { + return new Multiplication(); + } + + @Override + public Enemy createBigEnemy() { + return new BigMultiplication(); + } +} diff --git a/MathHero/src/Player.java b/MathHero2/src/main/java/com/espol/mathhero2/Player.java similarity index 97% rename from MathHero/src/Player.java rename to MathHero2/src/main/java/com/espol/mathhero2/Player.java index 975de75..0c33945 100644 --- a/MathHero/src/Player.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Player.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; import java.awt.*; public class Player diff --git a/MathHero/src/Subtraction.java b/MathHero2/src/main/java/com/espol/mathhero2/Subtraction.java similarity index 93% rename from MathHero/src/Subtraction.java rename to MathHero2/src/main/java/com/espol/mathhero2/Subtraction.java index 912735b..6978c60 100644 --- a/MathHero/src/Subtraction.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Subtraction.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class Subtraction extends Enemy { protected String problem; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/SubtractionEnemyFactory.java b/MathHero2/src/main/java/com/espol/mathhero2/SubtractionEnemyFactory.java new file mode 100644 index 0000000..c137868 --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/SubtractionEnemyFactory.java @@ -0,0 +1,27 @@ +package com.espol.mathhero2; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author DELL + */ +public class SubtractionEnemyFactory implements EnemyFactory { + + public SubtractionEnemyFactory() { + } + + @Override + public Enemy createSmallEnemy() { + return new Subtraction(); + } + + @Override + public Enemy createBigEnemy() { + return new BigSubtraction(); + } + +} diff --git a/MathHero/src/Util.java b/MathHero2/src/main/java/com/espol/mathhero2/Util.java similarity index 89% rename from MathHero/src/Util.java rename to MathHero2/src/main/java/com/espol/mathhero2/Util.java index edda859..528c237 100644 --- a/MathHero/src/Util.java +++ b/MathHero2/src/main/java/com/espol/mathhero2/Util.java @@ -1,3 +1,4 @@ +package com.espol.mathhero2; public class Util { public static final int MAX_R = 250; diff --git a/MathHero2/src/main/java/com/espol/mathhero2/WorldSingleton.java b/MathHero2/src/main/java/com/espol/mathhero2/WorldSingleton.java new file mode 100644 index 0000000..64432d8 --- /dev/null +++ b/MathHero2/src/main/java/com/espol/mathhero2/WorldSingleton.java @@ -0,0 +1,167 @@ +package com.espol.mathhero2; +import com.espol.mathhero2.SubtractionEnemyFactory; +import com.espol.mathhero2.DivisionEnemyFactory; +import com.espol.mathhero2.AdditionEnemyFactory; +import com.espol.mathhero2.EnemyFactory; +import com.espol.mathhero2.MultiplicationEnemyFactory; + +import java.awt.*; +import java.util.*; + +public class WorldSingleton +{ + public Player player; + public ArrayList levels; + public int level = 0; + public boolean win = false; + public boolean lose = false; + private static WorldSingleton instance = null; + + public static WorldSingleton getInstance() { + if (instance == null) { + // add logic to create levels and player + instance = new WorldSingleton(); + } + return instance; + } + + private WorldSingleton() + { + + this.player = new Player(); + this.levels = new ArrayList<>(); + + // Creamos las fábricas de enemigos + EnemyFactory additionFactory = new AdditionEnemyFactory(); + EnemyFactory multiplicationFactory = new MultiplicationEnemyFactory(); + EnemyFactory subtractionFactory = new SubtractionEnemyFactory(); + EnemyFactory divisionFactory = new DivisionEnemyFactory(); + + //Level 1 + Vector l1e = new Vector(); + for(int i = 0; i < 10; i ++) l1e.add(additionFactory.createSmallEnemy()); + Level l1 = new Level(2,1234567,l1e); + + //Level 2 + Vector l2e = new Vector(); + for(int i = 0; i < 8; i ++) l2e.add(additionFactory.createSmallEnemy()); + for(int i = 0; i < 5; i ++) l2e.add(multiplicationFactory.createSmallEnemy()); + Level l2 = new Level(2,6394658,l2e); + + //Level 3 + Vector l3e = new Vector(); + for(int i = 0; i < 5; i ++) l3e.add(additionFactory.createSmallEnemy()); + for(int i = 0; i < 8; i ++) l3e.add(multiplicationFactory.createSmallEnemy()); + Level l3 = new Level(3,1563826,l3e); + + //Level 4 + Vector l4e = new Vector(); + for(int i = 0; i < 7; i ++) l4e.add(additionFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l4e.add(multiplicationFactory.createSmallEnemy()); + for(int i = 0; i < 3; i ++) l4e.add(subtractionFactory.createSmallEnemy()); + Level l4 = new Level(3,1927462,l4e); + + //Level 5 + Vector l5e = new Vector(); + for(int i = 0; i < 7; i ++) l5e.add(additionFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l5e.add(multiplicationFactory.createSmallEnemy()); + for(int i = 0; i < 5; i ++) l5e.add(subtractionFactory.createSmallEnemy()); + for(int i = 0; i < 3; i ++) l5e.add(divisionFactory.createSmallEnemy()); + Level l5 = new Level(3,3728465,l5e); + + //Level 6 + Vector l6e = new Vector(); + for(int i = 0; i < 7; i ++) l6e.add(additionFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l6e.add(multiplicationFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l6e.add(subtractionFactory.createSmallEnemy()); + for(int i = 0; i < 5; i ++) l6e.add(divisionFactory.createSmallEnemy()); + Level l6 = new Level(3,7384920,l6e); + + //Level 7 + Vector l7e = new Vector(); + for(int i = 0; i < 5; i ++) l7e.add(additionFactory.createBigEnemy()); + for(int i = 0; i < 7; i ++) l7e.add(multiplicationFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l7e.add(subtractionFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l7e.add(divisionFactory.createSmallEnemy()); + Level l7 = new Level(3,6374198,l7e); + + //Level 8 + Vector l8e = new Vector(); + for(int i = 0; i < 5; i ++) l8e.add(additionFactory.createBigEnemy()); + for(int i = 0; i < 1; i ++) l8e.add(multiplicationFactory.createBigEnemy()); + for(int i = 0; i < 7; i ++) l8e.add(subtractionFactory.createSmallEnemy()); + for(int i = 0; i < 7; i ++) l8e.add(divisionFactory.createSmallEnemy()); + Level l8 = new Level(3,1738295,l8e); + levels.add(l1); + levels.add(l2); + levels.add(l3); + levels.add(l4); + levels.add(l5); + levels.add(l6); + levels.add(l7); + levels.add(l8); + + + } + + public void tryKey(int key) + { + for(int i = 0; i < levels.size(); i++) + { + if(levels.get(i).key==key) + { + level = i; + i = levels.size(); + } + } + } + + public Level getLevel() + { + return levels.get(level); + } + + public void update() + { + if(!win && !lose) + { + getLevel().update(); + player.hit(getLevel().getHitting()); + if(player.dead()) + lose = true; + if(getLevel().finished()&& !lose) + { + player.heal(); + level++; + if(level==levels.size()) + { + win = true; + level--; + } + } + } + } + + public void draw(Graphics g) + { + getLevel().drawEnemies(g); + player.draw(g); + g.setColor(Color.BLACK); + g.drawString("Level: "+(level+1),5,15); + g.drawString("Key: "+getLevel().key,Util.MAX_R*2-90,15); + if(win) + { + g.setColor(Color.GREEN); + g.setFont(new Font("Verdana",Font.BOLD,14)); + g.drawString("You WIN!",140,150); + } + if(lose) + { + g.setColor(Color.RED); + g.setFont(new Font("Verdana",Font.BOLD,14)); + g.drawString("You lose.",140,150); + } + } + + +} \ No newline at end of file diff --git a/MathHero2/target/classes/.netbeans_automatic_build b/MathHero2/target/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/MathHero2/target/maven-archiver/pom.properties b/MathHero2/target/maven-archiver/pom.properties new file mode 100644 index 0000000..6d881d5 --- /dev/null +++ b/MathHero2/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Sun Aug 06 19:41:26 COT 2023 +groupId=com.espol +artifactId=MathHero2 +version=1.0-SNAPSHOT diff --git a/MathHero2/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/MathHero2/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..a36a696 --- /dev/null +++ b/MathHero2/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,24 @@ +com\espol\mathhero2\Addition.class +com\espol\mathhero2\DivisionEnemyFactory.class +com\espol\mathhero2\SubtractionEnemyFactory.class +com\espol\mathhero2\Util.class +com\espol\mathhero2\BigSubtraction.class +com\espol\mathhero2\AdditionEnemyFactory.class +com\espol\mathhero2\MathHero.class +com\espol\mathhero2\BigAddition.class +com\espol\mathhero2\ListeningGameComponent.class +com\espol\mathhero2\MultiplicationEnemyFactory.class +com\espol\mathhero2\GameComponent.class +com\espol\mathhero2\Enemy.class +com\espol\mathhero2\Level.class +com\espol\mathhero2\BigMultiplication.class +com\espol\mathhero2\Player.class +com\espol\mathhero2\BigDivision.class +com\espol\mathhero2\Game.class +com\espol\mathhero2\GameComponent$1.class +com\espol\mathhero2\Subtraction.class +com\espol\mathhero2\Division.class +com\espol\mathhero2\EnemyFactory.class +com\espol\mathhero2\GameFacade.class +com\espol\mathhero2\Multiplication.class +com\espol\mathhero2\WorldSingleton.class diff --git a/MathHero2/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/MathHero2/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a7c653e --- /dev/null +++ b/MathHero2/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,23 @@ +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\AdditionEnemyFactory.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\BigMultiplication.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\BigSubtraction.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\EnemyFactory.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\GameComponent.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\GameFacade.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Enemy.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\SubtractionEnemyFactory.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\BigAddition.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\BigDivision.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\MathHero.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\MultiplicationEnemyFactory.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Player.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Level.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\DivisionEnemyFactory.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Addition.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Division.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\ListeningGameComponent.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Multiplication.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Subtraction.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Game.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\Util.java +C:\Users\DELL\Desktop\MathHero2\src\main\java\com\espol\mathhero2\WorldSingleton.java diff --git a/MathHero2/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/MathHero2/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/MathHero2/target/test-classes/.netbeans_automatic_build b/MathHero2/target/test-classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29