From 8e1f740c95c7d3155cf9533c4af0d03d5782ddbd Mon Sep 17 00:00:00 2001 From: Makussu Date: Fri, 7 Jun 2024 15:06:35 +0200 Subject: [PATCH] before pos refactor --- src/AuraBubble.java | 13 +++++++++ src/AuraFight.java | 70 +++++++++++++++++++++++++++++++++++++++++++++ src/Character.java | 3 ++ src/Fight.java | 10 +++---- src/Player.java | 1 + src/Tritt.java | 2 +- src/UI.java | 11 +++++-- 7 files changed, 101 insertions(+), 9 deletions(-) create mode 100644 src/AuraBubble.java create mode 100644 src/AuraFight.java diff --git a/src/AuraBubble.java b/src/AuraBubble.java new file mode 100644 index 0000000..8f9eed0 --- /dev/null +++ b/src/AuraBubble.java @@ -0,0 +1,13 @@ +public class AuraBubble { + Fenster window; + float x, y; + public AuraBubble(Fenster window, float x, float y) { + this.window = window; + this.x = x; + this.y = y; + } + + public void draw() { + window.circle(x, y, 50); + } +} diff --git a/src/AuraFight.java b/src/AuraFight.java new file mode 100644 index 0000000..6d3888a --- /dev/null +++ b/src/AuraFight.java @@ -0,0 +1,70 @@ +public class AuraFight extends Bubble{ + Player player; + Enemy enemy; + + float player_x = 200; + float player_y = 500; + + float enemy_x = 600; + float enemy_y = 300; + + boolean pos_set = false; + + Skill running_move; + + AuraFight(Fenster window, Player player, Enemy enemy) { + super(window); + System.out.println(player); + this.player = player; + this.enemy = enemy; + this.opened = true; + } + + void drawPlayer() { + if (!pos_set) { + player.real_x = player_x; + player.real_y = player_y; + pos_set = true; + } + player.textsize = 150; + player.draw(0, 0); + + window.ui.healthBar(player_x, player_y-100, player.health, player.maxHealth); + } + + void drawEnemy() { + window.textSize(150); + window.fill(enemy.color); + window.text(enemy.type, enemy_x, enemy_y); + + window.ui.healthBar(enemy_x, enemy_y-100, enemy.health, enemy.maxHealth); + } + + public void attack() { + running_move = player.skill; + running_move.use(enemy); + } + + + + public void draw() { + if (opened) { + window.fill(255); + window.rectMode(window.CENTER); + window.rect(window.width/2, window.height/2, 700, 500); + drawPlayer(); + drawEnemy(); + window.fill(0); + } + if (running_move != null) { + //System.out.println("move is running"); + running_move.draw(); + } + if (enemy.health <= 0 && opened) { + window.inFight = false; + window.inGame = true; + player.experience += 20; + opened = false; + } + } +} diff --git a/src/Character.java b/src/Character.java index 7ace486..c7f432b 100644 --- a/src/Character.java +++ b/src/Character.java @@ -10,6 +10,9 @@ public class Character implements Drawable { boolean collidable; float x, y; float real_x, real_y; + int experience = 0; + int level = 1; + float damage_mult = (float) (1 + level * 0.4); int textsize = 20; Character (Fenster window, String type) { diff --git a/src/Fight.java b/src/Fight.java index 76b0bf5..87d6174 100644 --- a/src/Fight.java +++ b/src/Fight.java @@ -33,7 +33,7 @@ public class Fight extends Bubble { player.textsize = 150; player.draw(0, 0); - window.ui.healthBar(player_x, player_y-60, player.health, player.maxHealth); + window.ui.healthBar(player_x, player_y-100, player.health, player.maxHealth); } void drawEnemy() { @@ -41,11 +41,10 @@ public class Fight extends Bubble { window.fill(enemy.color); window.text(enemy.type, enemy_x, enemy_y); - window.ui.healthBar(enemy_x, enemy_y-60, enemy.health, enemy.maxHealth); + window.ui.healthBar(enemy_x, enemy_y-100, enemy.health, enemy.maxHealth); } public void attack() { - running_move = player.skill; running_move.use(enemy); } @@ -53,7 +52,6 @@ public class Fight extends Bubble { public void draw() { - if (opened) { window.fill(255); window.rectMode(window.CENTER); @@ -66,9 +64,11 @@ public class Fight extends Bubble { //System.out.println("move is running"); running_move.draw(); } - if (enemy.health <= 0) { + if (enemy.health <= 0 && opened) { window.inFight = false; window.inGame = true; + player.experience += 20; + opened = false; } } } diff --git a/src/Player.java b/src/Player.java index 2b9e63f..57410fb 100644 --- a/src/Player.java +++ b/src/Player.java @@ -10,6 +10,7 @@ public class Player extends Fightable implements Health { int x, y; int health; int maxHealth = 20; + List skills = new ArrayList(); Skill skill = new Tritt(window, this); diff --git a/src/Tritt.java b/src/Tritt.java index b870155..50282ab 100644 --- a/src/Tritt.java +++ b/src/Tritt.java @@ -9,7 +9,7 @@ public class Tritt extends Skill { } public void use(Fightable target){ System.out.println("using tritt"); - target.damage(power); + target.damage((int) (power * user.damage_mult)); this.target = target; animate(); }; diff --git a/src/UI.java b/src/UI.java index 2f4a88f..dbfcef8 100644 --- a/src/UI.java +++ b/src/UI.java @@ -2,9 +2,9 @@ import processing.core.PApplet; import processing.core.PShape; public class UI { - PApplet window; + Fenster window; - UI(PApplet window) { + UI(Fenster window) { this.window = window; } @@ -23,8 +23,13 @@ public class UI { window.rect(x - barlength/2, y, healthLength, 5); } + public void exp(int exp) { + window.text(exp, 50, 100); + } + public void draw() { bottomBar(400, 700); - + healthBar(50, 50, window.player.health, window.player.maxHealth); + exp(window.player.experience); } }