first nice working version
This commit is contained in:
parent
7fdb3880cb
commit
8e294e75ac
@ -1,5 +1,5 @@
|
||||
public class AniShrink extends Animation {
|
||||
int numPoints = 100;
|
||||
int numPoints = 50;
|
||||
public AniShrink(Fenster window, Character player) {
|
||||
super(window, player);
|
||||
}
|
||||
@ -8,7 +8,7 @@ public class AniShrink extends Animation {
|
||||
if (frame_count < numPoints) {
|
||||
animating = true;
|
||||
player.textsize = shrink(from_size, to_size);
|
||||
System.out.println(player.pos.x);
|
||||
// System.out.println(player.pos.x);
|
||||
} else {
|
||||
player.textsize = to_size;
|
||||
animating = false;
|
||||
|
||||
19
src/Animation.java
Normal file
19
src/Animation.java
Normal file
@ -0,0 +1,19 @@
|
||||
import processing.core.PVector;
|
||||
|
||||
public class Animation {
|
||||
Fenster window;
|
||||
Character player;
|
||||
int frame_count = 0;
|
||||
int numPoints = 7;
|
||||
boolean animating = false;
|
||||
|
||||
public Animation(Fenster window, Character player){
|
||||
this.player = player;
|
||||
this.window = window;
|
||||
}
|
||||
|
||||
public boolean animate(float from_x, float from_y, float to_x, float to_y) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,80 @@
|
||||
import processing.core.PVector;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class AuraBubble {
|
||||
Fenster window;
|
||||
Random rand = new Random();
|
||||
boolean won;
|
||||
boolean popped = false;
|
||||
float x, y;
|
||||
public AuraBubble(Fenster window, float x, float y) {
|
||||
float extent = 100;
|
||||
|
||||
int color;
|
||||
public AuraBubble(Fenster window) {
|
||||
this.window = window;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
x = rand.nextFloat((720- 80) + 1) + 80;
|
||||
y = rand.nextFloat((620 - 180) + 1) + 180;
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
window.circle(x, y, 50);
|
||||
void change_color() {
|
||||
if (extent < 50) {
|
||||
color = window.color(151, 190, 90);
|
||||
} else {
|
||||
color = window.color(255, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void hit_check() {
|
||||
PVector pos = new PVector(x, y);
|
||||
PVector mouse = new PVector(window.mouseX, window.mouseY);
|
||||
|
||||
if (pos.dist(mouse) < extent && extent < 50) {
|
||||
pop();
|
||||
won = true;
|
||||
} else {
|
||||
pop();
|
||||
won = false;
|
||||
}
|
||||
}
|
||||
|
||||
void run_out_check() {
|
||||
if (extent < 1) {
|
||||
won = false;
|
||||
popped = true;
|
||||
}
|
||||
}
|
||||
void shrink(float speed) {
|
||||
if (extent > 0) {
|
||||
extent = extent - speed;
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
x = rand.nextFloat(800);
|
||||
y = rand.nextFloat(800);
|
||||
extent = 100;
|
||||
}
|
||||
void pop() {
|
||||
popped = true;
|
||||
}
|
||||
public void bubble() {
|
||||
window.noStroke();
|
||||
window.fill(color);
|
||||
window.circle(x, y, extent);
|
||||
window.stroke(0);
|
||||
}
|
||||
|
||||
|
||||
public boolean draw() {
|
||||
if (!popped) {
|
||||
change_color();
|
||||
bubble();
|
||||
shrink(1.5f);
|
||||
run_out_check();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
src/AuraFail.java
Normal file
21
src/AuraFail.java
Normal file
@ -0,0 +1,21 @@
|
||||
import processing.core.PVector;
|
||||
|
||||
public class AuraFail extends AuraBubble {
|
||||
public AuraFail(Fenster window) {
|
||||
super(window);
|
||||
}
|
||||
|
||||
void change_color() {
|
||||
color = window.color(255, 0, 0);
|
||||
}
|
||||
|
||||
public void hit_check() {
|
||||
PVector pos = new PVector(x, y);
|
||||
PVector mouse = new PVector(window.mouseX, window.mouseY);
|
||||
|
||||
|
||||
pop();
|
||||
won = false;
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
public class AuraFight extends Bubble{
|
||||
Player player;
|
||||
Enemy enemy;
|
||||
|
||||
AuraBubble my_aura = new AuraBubble(window);
|
||||
float player_x = 200;
|
||||
float player_y = 500;
|
||||
|
||||
@ -14,17 +14,14 @@ public class AuraFight extends Bubble{
|
||||
|
||||
AuraFight(Fenster window, Player player, Enemy enemy) {
|
||||
super(window);
|
||||
System.out.println(player);
|
||||
// System.out.println(player);
|
||||
this.player = player;
|
||||
this.enemy = enemy;
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
void drawPlayer() {
|
||||
if (!pos_set) {
|
||||
player.pos.set(player_x, player_y);
|
||||
pos_set = true;
|
||||
}
|
||||
player.pos.set(player_x, player_y);
|
||||
player.textsize = 150;
|
||||
player.draw();
|
||||
|
||||
@ -39,13 +36,11 @@ public class AuraFight extends Bubble{
|
||||
window.ui.healthBar(enemy_x, enemy_y-100, enemy.health, enemy.maxHealth);
|
||||
}
|
||||
|
||||
public void attack() {
|
||||
running_move = player.skill;
|
||||
running_move.use(enemy);
|
||||
boolean getRandomBoolean() {
|
||||
return Math.random() > 0.1;
|
||||
//I tried another approaches here, still the same result
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void draw() {
|
||||
if (opened) {
|
||||
window.fill(255);
|
||||
@ -53,17 +48,28 @@ public class AuraFight extends Bubble{
|
||||
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 (!my_aura.draw()) {
|
||||
if (my_aura.won) {
|
||||
enemy.damage(5);
|
||||
} else {
|
||||
player.damage(5);
|
||||
}
|
||||
if (getRandomBoolean()) {
|
||||
my_aura = new AuraBubble(window);
|
||||
} else {
|
||||
my_aura = new AuraFail(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enemy.health <= 0 && opened) {
|
||||
window.inFight = false;
|
||||
window.inGame = true;
|
||||
window.fightScreen.isState = false;
|
||||
window.gameScreen.isState = true;
|
||||
player.experience += 20;
|
||||
opened = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void hit_check() {
|
||||
my_aura.hit_check();
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,12 +42,23 @@ public class Bubble {
|
||||
return opened;
|
||||
}
|
||||
|
||||
public boolean toggle_without_open() {
|
||||
if (this.opened && this.index < text.size()-1) {
|
||||
this.index = this.index + 1;
|
||||
} else if (this.opened && this.index < text.size()){
|
||||
close();
|
||||
} else {
|
||||
open();
|
||||
}
|
||||
return opened;
|
||||
}
|
||||
|
||||
public void content(List<String> text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public void draw(float x, float y, int textsize) {
|
||||
if (window.inGame) {
|
||||
if (window.gameScreen.active()) {
|
||||
this.real_x = x * window.tilewidth / 2;
|
||||
this.real_y = y * window.tilewidth / 2;
|
||||
} else {
|
||||
@ -55,12 +66,13 @@ public class Bubble {
|
||||
this.real_y = y;
|
||||
}
|
||||
if (opened) {
|
||||
float text_width = 200;
|
||||
window.fill(255);
|
||||
window.rect(x * window.tilewidth/2, y * window.tilewidth/2, 300, 50);
|
||||
window.rect(x * window.tilewidth/2 - text_width/2, y * window.tilewidth/2, 300, 50);
|
||||
window.fill(0);
|
||||
window.textSize(textsize);
|
||||
window.textAlign(window.CENTER);
|
||||
window.text(text.get(index), real_x, real_y, window.textWidth(text.get(index)), 50);
|
||||
window.textAlign(window.CENTER, window.CENTER);
|
||||
window.text(text.get(index), real_x-text_width/2, real_y, window.textWidth(text.get(index)), 50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class Character implements Drawable {
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
if (window.inGame) {
|
||||
if (window.gameScreen.active()) {
|
||||
pos.sync_grid();
|
||||
}
|
||||
window.fill(color);
|
||||
|
||||
69
src/DeathScreen.java
Normal file
69
src/DeathScreen.java
Normal file
@ -0,0 +1,69 @@
|
||||
import processing.core.PVector;
|
||||
|
||||
public class DeathScreen implements State {
|
||||
Fenster window;
|
||||
|
||||
int all_gamma = 0;
|
||||
int rect_gamma = 0;
|
||||
boolean all_fade = true;
|
||||
boolean isState = false;
|
||||
|
||||
DeathScreen(Fenster window) {
|
||||
this.window = window;
|
||||
}
|
||||
public boolean active() {
|
||||
return isState;
|
||||
}
|
||||
|
||||
void restart_text() {
|
||||
|
||||
}
|
||||
void restart_rect() {
|
||||
window.fill(0, rect_gamma);
|
||||
window.textSize(35);
|
||||
window.text("restart", window.width /2, window.height/4*3);
|
||||
if (all_gamma > 40) {
|
||||
rect_gamma++;
|
||||
}
|
||||
}
|
||||
public boolean draw() {
|
||||
if(isState) {
|
||||
window.fill(window.color(255, 0, 0), all_gamma);
|
||||
window.rect(0, 0, 800, 800);
|
||||
window.textSize(15);
|
||||
window.fill(0, all_gamma);
|
||||
window.text(" \n" +
|
||||
"@@@ @@@ @@@@@@ @@@ @@@ @@@@@@@ @@@ @@@@@@@@ @@@@@@@ \n" +
|
||||
"@@@ @@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@ @@@@@@@@ @@@@@@@@ \n" +
|
||||
"@@! !@@ @@! @@@ @@! @@@ @@! @@@ @@! @@! @@! @@@ \n" +
|
||||
"!@! @!! !@! @!@ !@! @!@ !@! @!@ !@! !@! !@! @!@ \n" +
|
||||
" !@!@! @!@ !@! @!@ !@! @!@ !@! !!@ @!!!:! @!@ !@! \n" +
|
||||
" @!!! !@! !!! !@! !!! !@! !!! !!! !!!!!: !@! !!! \n" +
|
||||
" !!: !!: !!! !!: !!! !!: !!! !!: !!: !!: !!! \n" +
|
||||
" :!: :!: !:! :!: !:! :!: !:! :!: :!: :!: !:! \n" +
|
||||
" :: ::::: :: ::::: :: :::: :: :: :: :::: :::: :: \n" +
|
||||
" : : : : : : : :: : : : : :: :: :: : :", window.width /2, window.height/4);
|
||||
restart_rect();
|
||||
if (all_fade) {
|
||||
all_gamma = all_gamma + 5;
|
||||
}
|
||||
if (all_gamma == 255) {
|
||||
all_fade = false;
|
||||
}
|
||||
}
|
||||
return isState;
|
||||
}
|
||||
|
||||
public void mousePressed() {
|
||||
if (isState) {
|
||||
PVector mouse = new PVector(window.mouseX, window.mouseY);
|
||||
PVector rect = new PVector(window.width / 2, window.height / 4 * 3);
|
||||
System.out.println("mouse pressed");
|
||||
if (mouse.dist(rect) < 40) {
|
||||
window.reset();
|
||||
System.out.println("reset");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -34,13 +34,13 @@ public class Enemy extends Fightable implements Health, Interactable {
|
||||
public void draw() {
|
||||
window.fill(color);
|
||||
window.text(type, pos.get().x, pos.get().y);
|
||||
if (window.inFight) {
|
||||
if (window.fightScreen.isState) {
|
||||
window.ui.healthBar(pos.get().x, pos.get().y - 15, health, maxHealth);
|
||||
}
|
||||
}
|
||||
|
||||
public void interact() {
|
||||
window.inGame = false;
|
||||
window.inFight = true;
|
||||
window.gameScreen.isState = false;
|
||||
window.fightScreen.isState = true;
|
||||
}
|
||||
}
|
||||
|
||||
176
src/Fenster.java
176
src/Fenster.java
@ -8,24 +8,22 @@ import java.util.Arrays;
|
||||
|
||||
public class Fenster extends PApplet {
|
||||
|
||||
Player player = new Player(this);
|
||||
Tiles tiles = new Tiles(this, 40.0f);
|
||||
Character old_player_cell;
|
||||
int old_player_x;
|
||||
int old_player_y;
|
||||
Player player;
|
||||
Tiles tiles;
|
||||
|
||||
float tilewidth = 40.0f;
|
||||
|
||||
// STATES
|
||||
boolean inFight = false;
|
||||
boolean inGame = false;
|
||||
boolean inMenu = false;
|
||||
boolean inDialog = false;
|
||||
boolean starting = true;
|
||||
StartScreen startScreen;
|
||||
GameScreen gameScreen;
|
||||
FightScreen fightScreen;
|
||||
DeathScreen deathScreen;
|
||||
|
||||
boolean gametitel = true;
|
||||
|
||||
Fight myfight;
|
||||
AniShrink startingAnimation = new AniShrink(this, player);
|
||||
Bubble startingDialog = new Bubble(this, Arrays.asList("Das bist du...", "In einer gefährlichen Welt", "Wirst du überleben?"));
|
||||
|
||||
AuraFight auraFight;
|
||||
int gametitel_gamma = 255;
|
||||
boolean gametitel_fade = false;
|
||||
|
||||
@ -34,12 +32,9 @@ public class Fenster extends PApplet {
|
||||
public void settings() {
|
||||
size(800, 800);
|
||||
|
||||
|
||||
classSetup();
|
||||
tiles.settings();
|
||||
|
||||
|
||||
|
||||
|
||||
//this.text("lol", 0, 0);
|
||||
//this.rect(4.0f, 4.0f, 4.0f, 4.0f);
|
||||
}
|
||||
@ -53,38 +48,34 @@ public class Fenster extends PApplet {
|
||||
|
||||
myfight = new Fight(this, player, (Enemy) tiles.get(10, 10));
|
||||
|
||||
// start the first dialog
|
||||
startingDialog.open();
|
||||
startScreen.setup();
|
||||
startScreen.isState = true;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw() {
|
||||
background(255);
|
||||
System.out.println(frameRate);
|
||||
|
||||
|
||||
if (starting) {
|
||||
if (startingDialog.opened) {
|
||||
startingDialog.draw(200, 200, 40);
|
||||
player.pos.set(400, 400);
|
||||
player.textsize = 200;
|
||||
player.draw();
|
||||
} else {
|
||||
if (!startingAnimation.animate(200, 20)) {
|
||||
starting = false;
|
||||
inGame = true;
|
||||
} else {
|
||||
tiles.draw();
|
||||
System.out.println("startscreen");
|
||||
player.draw();
|
||||
}
|
||||
|
||||
if(!startScreen.draw()) {
|
||||
if(!gameScreen.active() && !fightScreen.active()) {
|
||||
gameScreen.isState = true;
|
||||
}
|
||||
}
|
||||
|
||||
gameScreen.draw();
|
||||
fightScreen.draw();
|
||||
deathScreen.draw();
|
||||
|
||||
|
||||
|
||||
if (gametitel) {
|
||||
System.out.println(gametitel_gamma);
|
||||
fill(255, gametitel_gamma);
|
||||
fill(color(49, 54, 63), gametitel_gamma);
|
||||
rect(0, 0, 800, 800);
|
||||
textSize(15);
|
||||
fill(0, gametitel_gamma);
|
||||
fill(color(238, 238, 238), gametitel_gamma);
|
||||
text(" ('-. _ .-') ('-. (`\\ .-') /` _ .-') _ .-') _ \n" +
|
||||
" ( OO ).-. ( \\( -O ) ( OO ).-. `.( OO ),' ( \\( -O ) ( ( OO) ) \n" +
|
||||
" / . --. / ,--. ,--. ,------. / . --. /,--./ .--. .-'),-----. ,------. ,--. \\ .'_ \n" +
|
||||
@ -101,26 +92,8 @@ public class Fenster extends PApplet {
|
||||
gametitel = false;
|
||||
}
|
||||
}
|
||||
if (inGame) {
|
||||
player.textsize = 20;
|
||||
|
||||
tiles.draw();
|
||||
// Handle the Cell which the player was on last round
|
||||
if (tiles.get(player.pos.grid_x, player.pos.grid_y) != player) {
|
||||
old_player_cell = tiles.get(player.pos.grid_x, player.pos.grid_y);
|
||||
old_player_x = player.pos.grid_x;
|
||||
old_player_y = player.pos.grid_y;
|
||||
}
|
||||
|
||||
tiles.set(player.pos.grid_x, player.pos.grid_y, player);
|
||||
|
||||
|
||||
ui.draw();
|
||||
}
|
||||
if (inFight) {
|
||||
tiles.draw();
|
||||
myfight.draw();
|
||||
}
|
||||
|
||||
//println(player.x + " " + player.y);
|
||||
}
|
||||
@ -131,64 +104,41 @@ public class Fenster extends PApplet {
|
||||
gametitel_fade = true;
|
||||
}
|
||||
}
|
||||
if (starting && !gametitel) {
|
||||
if (keyCode == 32) {
|
||||
startingDialog.toggle();
|
||||
}
|
||||
}
|
||||
if (inGame) {
|
||||
if (keyCode == this.UP) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x, player.pos.grid_y - 1);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_y_change(-1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
if (newTile.character instanceof Enemy) {
|
||||
myfight = new Fight(this, player, (Enemy) newTile.character);
|
||||
} else {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (keyCode == this.LEFT) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x - 1, player.pos.grid_y);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_x_change(-1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
if (keyCode == this.DOWN) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x, player.pos.grid_y + 1);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_y_change(1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
if (keyCode == this.RIGHT) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x + 1, player.pos.grid_y);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_x_change(1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inFight) {
|
||||
if (keyCode == 32) {
|
||||
myfight.attack();
|
||||
}
|
||||
if (keyCode == this.ESC) {
|
||||
if (key == ESC) {
|
||||
key = 0;
|
||||
}
|
||||
inFight = false;
|
||||
inGame = true;
|
||||
}
|
||||
if (key == 'w') {
|
||||
dead();
|
||||
}
|
||||
startScreen.keyPressed();
|
||||
gameScreen.keyPressed();
|
||||
fightScreen.keyPressed();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void mousePressed() {
|
||||
fightScreen.mousePressed();
|
||||
deathScreen.mousePressed();
|
||||
}
|
||||
|
||||
void classSetup() {
|
||||
player = new Player(this);
|
||||
tiles = new Tiles(this, 40.0f);
|
||||
startScreen = new StartScreen(this);
|
||||
gameScreen = new GameScreen(this);
|
||||
fightScreen = new FightScreen(this);
|
||||
deathScreen = new DeathScreen(this);
|
||||
}
|
||||
|
||||
public void dead() {
|
||||
gameScreen.isState = false;
|
||||
fightScreen.isState = false;
|
||||
deathScreen.isState = true;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
classSetup();
|
||||
deathScreen.isState = false;
|
||||
startScreen.setup();
|
||||
tiles.settings();
|
||||
startScreen.isState = true;
|
||||
}
|
||||
}
|
||||
@ -64,8 +64,8 @@ public class Fight extends Bubble {
|
||||
running_move.draw();
|
||||
}
|
||||
if (enemy.health <= 0 && opened) {
|
||||
window.inFight = false;
|
||||
window.inGame = true;
|
||||
window.fightScreen.isState = false;
|
||||
window.gameScreen.isState = true;
|
||||
player.experience += 20;
|
||||
opened = false;
|
||||
}
|
||||
|
||||
29
src/FightScreen.java
Normal file
29
src/FightScreen.java
Normal file
@ -0,0 +1,29 @@
|
||||
public class FightScreen implements State {
|
||||
Fenster window;
|
||||
boolean isState = false;
|
||||
|
||||
FightScreen(Fenster window) {
|
||||
this.window = window;
|
||||
}
|
||||
public boolean active() {
|
||||
return isState;
|
||||
}
|
||||
public boolean draw() {
|
||||
if (isState) {
|
||||
// window.tiles.draw();
|
||||
window.auraFight.draw();
|
||||
}
|
||||
return isState;
|
||||
}
|
||||
|
||||
public void keyPressed() {
|
||||
if (isState) {
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed() {
|
||||
if (isState) {
|
||||
window.auraFight.hit_check();
|
||||
}
|
||||
}
|
||||
}
|
||||
118
src/GameScreen.java
Normal file
118
src/GameScreen.java
Normal file
@ -0,0 +1,118 @@
|
||||
public class GameScreen implements State {
|
||||
Fenster window;
|
||||
boolean isState = false;
|
||||
Tiles tiles;
|
||||
Player player;
|
||||
UI ui;
|
||||
|
||||
char up = 'd';
|
||||
char left = 'c';
|
||||
char down = 't';
|
||||
char right = 'i';
|
||||
|
||||
|
||||
|
||||
Character old_player_cell;
|
||||
int old_player_x;
|
||||
int old_player_y;
|
||||
|
||||
GameScreen(Fenster window) {
|
||||
this.window = window;
|
||||
this.tiles = window.tiles;
|
||||
this.player = window.player;
|
||||
this.ui = window.ui;
|
||||
}
|
||||
|
||||
public boolean active() {
|
||||
return isState;
|
||||
}
|
||||
public boolean draw() {
|
||||
if (isState) {
|
||||
window.background(255);
|
||||
window.player.textsize = 20;
|
||||
|
||||
window.tiles.draw();
|
||||
// Handle the Cell which the player was on last round
|
||||
if (tiles.get(player.pos.grid_x, player.pos.grid_y) != player) {
|
||||
old_player_cell = tiles.get(player.pos.grid_x, player.pos.grid_y);
|
||||
old_player_x = player.pos.grid_x;
|
||||
old_player_y = player.pos.grid_y;
|
||||
}
|
||||
|
||||
tiles.set(player.pos.grid_x, player.pos.grid_y, player);
|
||||
|
||||
|
||||
ui.draw();
|
||||
}
|
||||
return isState;
|
||||
}
|
||||
|
||||
public void keyPressed() {
|
||||
if (isState) {
|
||||
if (window.key == up) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x, player.pos.grid_y - 1);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_y_change(-1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
if (newTile.character instanceof Enemy) {
|
||||
window.auraFight = new AuraFight(window, player, (Enemy) newTile.character);
|
||||
isState = false;
|
||||
// inFight = true;
|
||||
window.fightScreen.isState = true;
|
||||
} else {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (window.key == left) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x - 1, player.pos.grid_y);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_x_change(-1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
if (newTile.character instanceof Enemy) {
|
||||
window.auraFight = new AuraFight(window, player, (Enemy) newTile.character);
|
||||
isState = false;
|
||||
// inFight = true;
|
||||
window.fightScreen.isState = true;
|
||||
} else {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (window.key == down) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x, player.pos.grid_y + 1);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_y_change(1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
if (newTile.character instanceof Enemy) {
|
||||
window.auraFight = new AuraFight(window, player, (Enemy) newTile.character);
|
||||
isState = false;
|
||||
// inFight = true;
|
||||
window.fightScreen.isState = true;
|
||||
} else {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (window.key == right) {
|
||||
Cell newTile = tiles.get_cell(player.pos.grid_x + 1, player.pos.grid_y);
|
||||
if (!newTile.character.collidable) {
|
||||
player.pos.grid_x_change(1);
|
||||
tiles.set(old_player_x, old_player_y, old_player_cell);
|
||||
} else if (newTile.character instanceof Interactable) {
|
||||
if (newTile.character instanceof Enemy) {
|
||||
window.auraFight = new AuraFight(window, player, (Enemy) newTile.character);
|
||||
isState = false;
|
||||
// inFight = true;
|
||||
window.fightScreen.isState = true;
|
||||
} else {
|
||||
((Interactable) newTile.character).interact();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,6 @@ import processing.core.PApplet;
|
||||
// then press Enter. You can now see whitespace characters in your code.
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
PApplet.main("Fenster");
|
||||
PApplet.main("Fenster");
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,8 @@ public class Player extends Fightable implements Health {
|
||||
public void damage(int damage) {
|
||||
health = health - damage;
|
||||
if (health <= 0) {
|
||||
window.println("dead");
|
||||
health = 0;
|
||||
window.dead();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
54
src/StartScreen.java
Normal file
54
src/StartScreen.java
Normal file
@ -0,0 +1,54 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StartScreen implements State {
|
||||
Fenster window;
|
||||
boolean isState = false;
|
||||
|
||||
Bubble startingDialog;
|
||||
AniShrink startingAnimation;
|
||||
|
||||
StartScreen(Fenster window) {
|
||||
this.window = window;
|
||||
startingAnimation = new AniShrink(this.window, window.player);
|
||||
startingDialog = new Bubble(window, Arrays.asList("Das bist du...", "In einer gefährlichen Welt", "Wirst du überleben?"));
|
||||
}
|
||||
|
||||
public boolean active(){
|
||||
return isState;
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
// start the first dialog
|
||||
startingDialog.open();
|
||||
}
|
||||
public boolean draw() {
|
||||
if (isState) {
|
||||
window.background(255);
|
||||
if (startingDialog.opened) {
|
||||
startingDialog.draw(400, 200, 40);
|
||||
window.player.pos.set(400, 400);
|
||||
window.player.textsize = 200;
|
||||
window.player.draw();
|
||||
} else {
|
||||
if (!startingAnimation.animate(200, 20)) {
|
||||
isState = false;
|
||||
} else {
|
||||
window.tiles.draw();
|
||||
System.out.println("startscreen");
|
||||
window.player.draw();
|
||||
}
|
||||
}
|
||||
}
|
||||
return isState;
|
||||
}
|
||||
|
||||
|
||||
public void keyPressed() {
|
||||
// Probably also has to check: && !gametitle
|
||||
if (isState && !window.gametitel) {
|
||||
if (window.keyCode == 32) {
|
||||
startingDialog.toggle_without_open();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
7
src/State.java
Normal file
7
src/State.java
Normal file
@ -0,0 +1,7 @@
|
||||
public interface State {
|
||||
Fenster window = null;
|
||||
|
||||
boolean isState = false;
|
||||
public boolean active();
|
||||
public boolean draw();
|
||||
}
|
||||
@ -20,7 +20,9 @@ public class Talkable extends Character implements Interactable{
|
||||
}
|
||||
|
||||
public void interact() {
|
||||
this.bubble.toggle();
|
||||
if(!this.bubble.toggle()) {
|
||||
window.player.heal(20);
|
||||
}
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
@ -29,7 +31,6 @@ public class Talkable extends Character implements Interactable{
|
||||
window.text(type, this.pos.get().x, this.pos.get().y);
|
||||
this.bubble.draw(this.pos.get_grid().x, this.pos.get_grid().y, 20);
|
||||
|
||||
System.out.println(window.player.pos.get_grid().x - this.pos.get_grid().x);
|
||||
if (Math.abs(window.player.pos.get_grid().x - this.pos.get_grid().x) > 1 || Math.abs(window.player.pos.get_grid().y - this.pos.get_grid().y) > 1) {
|
||||
this.bubble.close();
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ public class Tiles {
|
||||
Character empty = new Character(window, " ");
|
||||
Character tree = new Character(window, "A", window.color(10, 200, 10), true);
|
||||
Character wall = new Character(window, "#", window.color(132,86,60), true);
|
||||
old_dude = new Talkable(window, "T", window.color(20,20,200), true, new Bubble(window, Arrays.asList("Hey Junge!", "Was machst du hier unten?", "Du solltest hier nicht sein...")));
|
||||
old_dude = new Talkable(window, "T", window.color(20,20,200), true, new Bubble(window, Arrays.asList("Hey Junge!", "Was machst du hier unten?", "Lass mich dich heilen...")));
|
||||
|
||||
tileMap = new Cell[100][100];
|
||||
for(int i = 0; i < tileMap.length; i++) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user