before pos refactor

This commit is contained in:
Makussu 2024-06-07 15:06:35 +02:00
parent 1d9e03af7a
commit 8e1f740c95
7 changed files with 101 additions and 9 deletions

13
src/AuraBubble.java Normal file
View File

@ -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);
}
}

70
src/AuraFight.java Normal file
View File

@ -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;
}
}
}

View File

@ -10,6 +10,9 @@ public class Character implements Drawable {
boolean collidable; boolean collidable;
float x, y; float x, y;
float real_x, real_y; float real_x, real_y;
int experience = 0;
int level = 1;
float damage_mult = (float) (1 + level * 0.4);
int textsize = 20; int textsize = 20;
Character (Fenster window, String type) { Character (Fenster window, String type) {

View File

@ -33,7 +33,7 @@ public class Fight extends Bubble {
player.textsize = 150; player.textsize = 150;
player.draw(0, 0); 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() { void drawEnemy() {
@ -41,11 +41,10 @@ public class Fight extends Bubble {
window.fill(enemy.color); window.fill(enemy.color);
window.text(enemy.type, enemy_x, enemy_y); 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() { public void attack() {
running_move = player.skill; running_move = player.skill;
running_move.use(enemy); running_move.use(enemy);
} }
@ -53,7 +52,6 @@ public class Fight extends Bubble {
public void draw() { public void draw() {
if (opened) { if (opened) {
window.fill(255); window.fill(255);
window.rectMode(window.CENTER); window.rectMode(window.CENTER);
@ -66,9 +64,11 @@ public class Fight extends Bubble {
//System.out.println("move is running"); //System.out.println("move is running");
running_move.draw(); running_move.draw();
} }
if (enemy.health <= 0) { if (enemy.health <= 0 && opened) {
window.inFight = false; window.inFight = false;
window.inGame = true; window.inGame = true;
player.experience += 20;
opened = false;
} }
} }
} }

View File

@ -10,6 +10,7 @@ public class Player extends Fightable implements Health {
int x, y; int x, y;
int health; int health;
int maxHealth = 20; int maxHealth = 20;
List<Skill> skills = new ArrayList<Skill>(); List<Skill> skills = new ArrayList<Skill>();
Skill skill = new Tritt(window, this); Skill skill = new Tritt(window, this);

View File

@ -9,7 +9,7 @@ public class Tritt extends Skill {
} }
public void use(Fightable target){ public void use(Fightable target){
System.out.println("using tritt"); System.out.println("using tritt");
target.damage(power); target.damage((int) (power * user.damage_mult));
this.target = target; this.target = target;
animate(); animate();
}; };

View File

@ -2,9 +2,9 @@ import processing.core.PApplet;
import processing.core.PShape; import processing.core.PShape;
public class UI { public class UI {
PApplet window; Fenster window;
UI(PApplet window) { UI(Fenster window) {
this.window = window; this.window = window;
} }
@ -23,8 +23,13 @@ public class UI {
window.rect(x - barlength/2, y, healthLength, 5); window.rect(x - barlength/2, y, healthLength, 5);
} }
public void exp(int exp) {
window.text(exp, 50, 100);
}
public void draw() { public void draw() {
bottomBar(400, 700); bottomBar(400, 700);
healthBar(50, 50, window.player.health, window.player.maxHealth);
exp(window.player.experience);
} }
} }