Nah this doesnt work
This commit is contained in:
parent
5a51e43a4f
commit
a082f594b1
@ -9,6 +9,7 @@ public class Character implements Drawable {
|
|||||||
int color;
|
int color;
|
||||||
boolean collidable;
|
boolean collidable;
|
||||||
float x, y;
|
float x, y;
|
||||||
|
float real_x, real_y;
|
||||||
|
|
||||||
Character (Fenster window, String type) {
|
Character (Fenster window, String type) {
|
||||||
this.window = window;
|
this.window = window;
|
||||||
@ -43,10 +44,10 @@ public class Character implements Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(float x, float y) {
|
public void draw(float x, float y) {
|
||||||
this.x = x;
|
this.real_x = x * window.tilewidth/2;
|
||||||
this.y = y;
|
this.real_y = y * window.tilewidth/2;
|
||||||
window.fill(color);
|
window.fill(color);
|
||||||
window.textSize(20);
|
window.textSize(20);
|
||||||
window.text(type, x * window.tilewidth/2, y * window.tilewidth/2);
|
window.text(type, real_x, real_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import processing.core.PApplet;
|
|||||||
/**
|
/**
|
||||||
* Enemy which is Interactable in the way, that we can damage him. He also has health so he is also healable.
|
* Enemy which is Interactable in the way, that we can damage him. He also has health so he is also healable.
|
||||||
*/
|
*/
|
||||||
public class Enemy extends Character implements Health, Interactable {
|
public class Enemy extends Fightable implements Health, Interactable {
|
||||||
int health;
|
int health;
|
||||||
int maxHealth = 20;
|
int maxHealth = 20;
|
||||||
|
|
||||||
@ -44,6 +44,5 @@ public class Enemy extends Character implements Health, Interactable {
|
|||||||
public void interact() {
|
public void interact() {
|
||||||
window.inGame = false;
|
window.inGame = false;
|
||||||
window.inFight = true;
|
window.inFight = true;
|
||||||
window.player.damageEnemy(5, this);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ public class Fight extends Bubble {
|
|||||||
float enemy_x = 600;
|
float enemy_x = 600;
|
||||||
float enemy_y = 300;
|
float enemy_y = 300;
|
||||||
|
|
||||||
boolean animating = false;
|
Skill running_move;
|
||||||
|
|
||||||
Fight(Fenster window, Player player, Enemy enemy) {
|
Fight(Fenster window, Player player, Enemy enemy) {
|
||||||
super(window);
|
super(window);
|
||||||
@ -37,53 +37,11 @@ public class Fight extends Bubble {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void attack() {
|
public void attack() {
|
||||||
animating = true;
|
running_move = player.skills.get(0);
|
||||||
|
player.skills.get(0).use(enemy);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
boolean ani_hit = false;
|
|
||||||
void animating_attack() {
|
|
||||||
int numPoints = 10;
|
|
||||||
float startanimate_x;
|
|
||||||
float startanimate_y;
|
|
||||||
float stopanimate_x;
|
|
||||||
float stopanimate_y;
|
|
||||||
if (i == 5 && ani_hit == false) {
|
|
||||||
ani_hit = true;
|
|
||||||
}
|
|
||||||
if (!ani_hit) {
|
|
||||||
startanimate_x = 600;
|
|
||||||
startanimate_y = 300;
|
|
||||||
stopanimate_x = 200;
|
|
||||||
stopanimate_y = 500;
|
|
||||||
} else {
|
|
||||||
startanimate_x = 200;
|
|
||||||
startanimate_y = 500;
|
|
||||||
stopanimate_x = 600;
|
|
||||||
stopanimate_y = 300;
|
|
||||||
}
|
|
||||||
if (i < 10) {
|
|
||||||
float interpolationAmount = window.map(i, 0, numPoints - 1, 0, 1);
|
|
||||||
|
|
||||||
float interpolatedX = window.lerp(startanimate_x, stopanimate_x, interpolationAmount);
|
|
||||||
float interpolatedY = window.lerp(startanimate_y, stopanimate_y, interpolationAmount);
|
|
||||||
|
|
||||||
player_x = interpolatedX;
|
|
||||||
player_y = interpolatedY;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
void animation_cleanup() {
|
|
||||||
if (!ani_hit && player_x == 600 && player_y == 300) {
|
|
||||||
animating = false;
|
|
||||||
i = 0;
|
|
||||||
ani_hit = false;
|
|
||||||
|
|
||||||
player_x = 600;
|
|
||||||
player_y = 300;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void draw() {
|
public void draw() {
|
||||||
|
|
||||||
@ -95,8 +53,8 @@ public class Fight extends Bubble {
|
|||||||
drawEnemy();
|
drawEnemy();
|
||||||
window.fill(0);
|
window.fill(0);
|
||||||
}
|
}
|
||||||
if (animating) {
|
if (running_move != null) {
|
||||||
animating_attack();
|
running_move.draw();
|
||||||
}
|
}
|
||||||
if (enemy.health <= 0) {
|
if (enemy.health <= 0) {
|
||||||
window.inFight = false;
|
window.inFight = false;
|
||||||
|
|||||||
11
src/Fightable.java
Normal file
11
src/Fightable.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
public abstract class Fightable extends Character {
|
||||||
|
|
||||||
|
public Fightable(Fenster window) {
|
||||||
|
super(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void damage(int damage);
|
||||||
|
|
||||||
|
public abstract void heal(int healing);
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,12 +1,16 @@
|
|||||||
import processing.core.PApplet;
|
import processing.core.PApplet;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the main player of the game we can move around with and interact.
|
* This is the main player of the game we can move around with and interact.
|
||||||
*/
|
*/
|
||||||
public class Player extends Character implements Health {
|
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>();
|
||||||
|
|
||||||
Player(Fenster window) {
|
Player(Fenster window) {
|
||||||
super(window);
|
super(window);
|
||||||
@ -14,10 +18,8 @@ public class Player extends Character implements Health {
|
|||||||
this.x = 4;
|
this.x = 4;
|
||||||
this.y = 4;
|
this.y = 4;
|
||||||
this.health = maxHealth;
|
this.health = maxHealth;
|
||||||
}
|
|
||||||
|
|
||||||
public void damageEnemy(int damage, Enemy enemy) {
|
this.skills.add(new Tritt(window, this));
|
||||||
enemy.damage(damage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void damage(int damage) {
|
public void damage(int damage) {
|
||||||
|
|||||||
22
src/Skill.java
Normal file
22
src/Skill.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
public class Skill {
|
||||||
|
Fenster window;
|
||||||
|
Fightable user;
|
||||||
|
Fightable target;
|
||||||
|
static int power = 5;
|
||||||
|
int numPoints = 10;
|
||||||
|
|
||||||
|
boolean animating = false;
|
||||||
|
|
||||||
|
Skill(Fenster window, Fightable user) {
|
||||||
|
this.window = window;
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
public void use(Fightable target){
|
||||||
|
target.damage(power);
|
||||||
|
};
|
||||||
|
public void animate() {};
|
||||||
|
|
||||||
|
public boolean draw() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
69
src/Tritt.java
Normal file
69
src/Tritt.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
public class Tritt extends Skill {
|
||||||
|
Fenster window;
|
||||||
|
Fightable user;
|
||||||
|
Fightable target;
|
||||||
|
boolean animating = false;
|
||||||
|
|
||||||
|
Tritt(Fenster window, Fightable user) {
|
||||||
|
super(window, user);
|
||||||
|
System.out.println(user);
|
||||||
|
}
|
||||||
|
public void use(Fightable target){
|
||||||
|
target.damage(power);
|
||||||
|
this.target = target;
|
||||||
|
};
|
||||||
|
public void animate(){
|
||||||
|
};
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
boolean ani_hit = false;
|
||||||
|
void animating_attack() {
|
||||||
|
float startanimate_x;
|
||||||
|
float startanimate_y;
|
||||||
|
float stopanimate_x;
|
||||||
|
float stopanimate_y;
|
||||||
|
if (i == 10 && ani_hit == false) {
|
||||||
|
ani_hit = true;
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
if (!ani_hit) {
|
||||||
|
startanimate_x = 600;
|
||||||
|
startanimate_y = 300;
|
||||||
|
stopanimate_x = 200;
|
||||||
|
stopanimate_y = 500;
|
||||||
|
} else {
|
||||||
|
startanimate_x = 200;
|
||||||
|
startanimate_y = 500;
|
||||||
|
stopanimate_x = 600;
|
||||||
|
stopanimate_y = 300;
|
||||||
|
}
|
||||||
|
if (i < 10) {
|
||||||
|
float interpolationAmount = window.map(i, 0, numPoints - 1, 0, 1);
|
||||||
|
|
||||||
|
float interpolatedX = window.lerp(startanimate_x, stopanimate_x, interpolationAmount);
|
||||||
|
float interpolatedY = window.lerp(startanimate_y, stopanimate_y, interpolationAmount);
|
||||||
|
|
||||||
|
user.real_x = interpolatedX;
|
||||||
|
user.real_y = interpolatedY;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void animation_cleanup() {
|
||||||
|
if (!ani_hit && user.real_x == 600 && user.real_y == 300) {
|
||||||
|
animating = false;
|
||||||
|
i = 0;
|
||||||
|
ani_hit = false;
|
||||||
|
|
||||||
|
user.real_x = 600;
|
||||||
|
user.real_y = 300;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean draw() {
|
||||||
|
System.out.println(2);
|
||||||
|
animating_attack();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user