Permalink
Browse files

Changed a lot of shit and it works

  • Loading branch information...
1 parent 5b3462f commit 7bab7ac094072236c3ec8812a98722c36c264c6e Javiy committed Feb 17, 2017
@@ -0,0 +1,44 @@
+package JaviyDemo;
+
+import guiPractice.components.Action;
+
+import java.awt.image.BufferedImage;
+
+public class Artifact implements ArtifactInterface{
+
+ private String description;
+ private int price;
+ private String imagePath;
+ private String name;
+ private Action action;
+
+ public Artifact(String desc, String name, int price, Action action, String path) {
+ this.description = desc;
+ this.price = price;
+ this.name = name;
+ this.action = action;
+ this.imagePath = path;
+ }
+
+ public Artifact buyItem(){
+ //action.act();
+ return this;
+ }
+
+ public String getDescription(){
+ return description;
+ }
+
+ public String getName(){
+ return name;
+ }
+
+ public int getPrice(){
+ return price;
+ }
+
+ public String getImagePath() {
+ return imagePath;
+ }
+
+}
@@ -0,0 +1,13 @@
+package JaviyDemo;
+
+import JaviyDemo.Artifact;
+
+public interface ArtifactInterface {
+ public Artifact buyItem();
+
+ public int getPrice();
+
+ public String getDescription();
+
+ public String getImagePath();
+}
@@ -0,0 +1,9 @@
+package JaviyDemo;
+
+public interface Game {
+ void decreaseLife();
+ void addBossSequence();
+ void speedTimer();
+ void freezeTimer();
+ void nothing();
+}
@@ -0,0 +1,50 @@
+package JaviyDemo;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+
+import guiPractice.components.Component;
+
+public class HitPoints extends Component{
+
+ public static int score;
+ public static int achieved;
+ public static int threshold;
+
+ public boolean newLevel = false;
+ private int seqLength = 0;
+ private int playerMaxSeq;
+
+ public static int playerHp = 100;
+ public static int maxHp = 100;
+
+ public HitPoints(int x, int y) {
+ super(x, y, 100, 200);
+ score = 0;
+
+ }
+
+ public void checkHp(int Hp){
+ if (playerHp <= maxHp){
+ playerHp = 0;
+ }
+ }
+ public void hpDecrease(int x){
+ playerHp = playerHp - 10;
+ update();
+ }
+
+ @Override
+ public void update(Graphics2D g) {
+ //hp
+ int hpBarHeight = 20;
+ g.setColor(Color.white);
+ g.fillRect(0, getHeight()/2+10, getWidth()-1, hpBarHeight - 1);
+ g.setColor(new Color(102, 179, 255));
+ if (playerHp > 0) g.fillRect(0, getHeight()/2+10, getWidth() * playerHp/maxHp, hpBarHeight);
+ else g.fillRect(0, getHeight()/2+10, 0, hpBarHeight);
+ g.setColor(Color.black);
+ g.drawRect(0, getHeight()/2+10, getWidth()-1, hpBarHeight - 1);
+ g.drawString("Hp = " + playerHp + "/" + maxHp + "", 5, getHeight()/2+25);
+ }
+}
@@ -0,0 +1,33 @@
+package JaviyDemo;
+
+import java.awt.Graphics2D;
+import java.util.ArrayList;
+import java.util.List;
+import guiPractice.components.TextArea;
+import guiPractice.components.Visible;
+import guiPractice.sampleGames.ClickGraphicsScreen;
+
+public class InventoryScreen extends ClickGraphicsScreen implements Runnable{
+
+ private TextArea title;
+ private ArrayList<Artifact> artifacts;
+ private Graphics2D g;
+
+ public InventoryScreen(int width, int height) {
+ super(width, height);
+ Thread app = new Thread(this);
+ app.start();
+ }
+
+ @Override
+ public void run() {
+ g.drawRect(100, 100, 100, 100);
+
+ }
+
+ public void initAllObjects(List<Visible> viewObjects) {
+ title = new TextArea(40,85,700,25, "Inventory");
+ viewObjects.add(title);
+ }
+
+}
@@ -0,0 +1,205 @@
+package JaviyDemo;
+
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.util.ArrayList;
+
+import guiPractice.components.Component;
+
+public class Monster extends Component implements MonsterName{
+
+ private static final int WIDTH = 300;
+ private static final int HEIGHT = 300;
+
+ public Monster(Game game) {
+ super(400,80,WIDTH,HEIGHT);
+ this.game = game;
+ String temp = getName();
+ while(wasNameUsed(temp)){
+ temp = getName();
+ }
+ names.add(temp);//adds the name of this monster to the history of all names ever created
+ name = temp;//sets the name of this monster to temp
+ initAbility();
+ update();
+ }
+
+ private void initAbility() {
+ if(element.equals("Poisonous")){
+ ability = new MonsterAbility() {
+
+ @Override
+ public void use() {
+ // TODO Auto-generated method stub
+ game.speedTimer();
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "Speeds up the timer";
+ }
+ };
+ }else if(element.equals("Pyro")){
+ ability = new MonsterAbility() {
+
+
+ @Override
+ public void use() {
+ // TODO Auto-generated method stub
+ game.decreaseLife();
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "Decreases health every 15 seconds you dont kill a monster";
+ }
+
+ };
+ }else if(element.equals("Godly")){
+ ability = new MonsterAbility() {
+
+
+ @Override
+ public void use() {
+ // TODO Auto-generated method stub
+ game.addBossSequence();;
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "Adds boss sequence";
+ }
+
+ };
+
+ }else if(element.equals("Frost")){
+ ability = new MonsterAbility() {
+
+
+ @Override
+ public void use() {
+ // TODO Auto-generated method stub
+ game.freezeTimer();
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "Freezes timer every 5 seconds you can't see the timer do down every second";
+ }
+
+ };
+ }else{
+ ability = new MonsterAbility() {
+
+
+ @Override
+ public void use() {
+ // TODO Auto-generated method stub
+ game.nothing();
+ }
+
+ @Override
+ public String getDescription() {
+ // TODO Auto-generated method stub
+ return "Does nothing";
+ }
+
+ };
+
+ }
+
+ }
+
+ public static void usablity(){
+ ability.use();
+ }
+
+ public static String description(){
+ return ability.getDescription();
+ }
+
+ private static String[] name1 = {"Terrifying","Big","Tiny","Dangerous","Angry","Cruel","Awesome","Friendly","Deathly","Lonely"};
+ private static String[] name2 = {"Calm","Hasty","Lazy","Casual","Caring","Emotional","Brave","Honest","Fluffy","Safe"};
+ private static String[] name3 = {"Beast","Fiend","Titan","Demon","Colossus","Savage","Monster","Animal","Thingy"};
+ private static ArrayList<String> names = new ArrayList<String>();
+// private static String[][] abilities = {{"Normal", "0"},{"Frost","1"},{"Pyro","2"},{"Poisonous","3"},{"Godly","4"}};
+ private static String[][] abilities = {{"Pyro", "0"},{"Pyro","1"},{"Pyro","2"},{"Pyro","3"},{"Pyro","4"}};
+ private static final int[] RANGE_1 = {0,56,76,91,99};
+ private static final int[] RANGE_2 = {55,75,90,98,100};
+
+ private String name;
+
+ private String element;
+ private String monsterType;
+
+ private Game game;
+ private static MonsterAbility ability;
+
+ //getter method for element
+ private static boolean wasNameUsed(String name){
+ if(names.size()<1)return false;
+ boolean isUsed = false;
+ for(int i = 0;i<names.size();i++){
+ if(names.get(i)==name){
+ isUsed = true;
+ break;
+ }else isUsed = false;
+ }
+ if(isUsed == true){
+ return false;
+ }
+ else return true;
+ }
+
+ private String abilityProbability(){
+ int random = (int)(Math.random()*RANGE_1.length);
+ int randomTwo = (int)(Math.random()*100);
+ for(int i = 0; i<RANGE_1.length;i++){
+ if(RANGE_1[i]<=randomTwo&&randomTwo<=RANGE_2[i]){
+ return abilities[i][0];
+ }
+ }
+ return element;
+ }
+
+
+ public String getName(){
+ name = " ";
+ String element = abilityProbability();
+ int r1 = (int)(Math.random()*name1.length);
+ int r2 = (int)(Math.random()*name2.length);
+ int r3 = (int)(Math.random()*name3.length);
+ for(int i=0;i<4;i++){
+ if(i==0)name += name1[r1] + " ";
+ else if(i==1){
+ name += element+ " ";
+ this.element = element;
+ }
+ else if(i==2)name += name2[r2]+ " ";
+ else{
+ name += name3[r3];
+ monsterType = name3[r3];
+ }
+ }
+ return name;
+ }
+
+
+ @Override
+ public void update(Graphics2D g) {
+ if(name!=null){
+ g.setColor(Color.black);
+ g.drawString(name, 0, 20);
+ }
+ }
+
+ //To do list
+ //Create a next level button to test everything out
+ //
+
+}
@@ -0,0 +1,6 @@
+package JaviyDemo;
+
+public interface MonsterAbility{
+ void use();
+ String getDescription();
+}
@@ -0,0 +1,7 @@
+package JaviyDemo;
+
+import guiPractice.components.Visible;
+
+public interface MonsterName extends Visible{
+ String getName();
+}
Oops, something went wrong.

0 comments on commit 7bab7ac

Please sign in to comment.