ULTRA MEGA BUG NICHT BEHOBEN ABER FUNKTIONIERT JETZT. WIESO SCHREIBE ICH IN CAPS? KEINE AHNUNG!

master
GammelJan 6 years ago
parent 9f1170c959
commit 713fd0f85e

@ -83,31 +83,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
e = new Entity[5]; e = new Entity[5];
Gdx.input.setInputProcessor(this); Gdx.input.setInputProcessor(this);
tEntities = new Timer();
tEntities.scheduleTask(new Timer.Task() {
@Override
public void run() {
for(int i = 0; i< e.length; i++){
if(e[i] == null){}
else{
if(Math.random() < 0.05){ //Attacks with a chance of 5% every move
for(int n = 0; n < arrows.length; n++){
if(arrows[n] == null){
//arrows[n] = new Arrow(e[i].getxPos(), e[i].getyPos(), e[i].getLvl(), e[i].direction());
//m.newEntity(n,arrows[n],e[i].getxPos(),e[i].getyPos());
}
}
}
e[i].rdmMove();
m.setPlayerSpriteX(d.getPlayer().getxPos());
m.setPlayerSpriteY(d.getPlayer().getyPos());
m.setEntitySpriteX(i, d.getPlayer().getxPos());
m.setEntitySpriteY(i, d.getPlayer().getxPos());
}
}
}
},0,0.4f);
} }

@ -15,13 +15,7 @@ public abstract class Entity {
protected float movementY; protected float movementY;
protected int id; protected int id;
Timer tup;
Timer tright;
Timer tdown;
Timer tleft;
int timerRuns;
boolean isRunning;
int facing;
public Entity(float xPos, float yPos, int lvl){ public Entity(float xPos, float yPos, int lvl){
this.xPos = xPos; this.xPos = xPos;
@ -31,75 +25,9 @@ public abstract class Entity {
this.movementY = 0; this.movementY = 0;
tup = new Timer();
tright = new Timer();
tdown = new Timer();
tleft = new Timer();
isRunning = false;
timerRuns = 0;
facing = 2;
tup.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(0);
setIsRunning(true);
setyPos(getyPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tup.stop();
}
}
},0,0.03f);
tup.stop();
tright.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(1);
setIsRunning(true);
setxPos(getxPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tright.stop();
}
}
},0,0.03f);
tright.stop();
tdown.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(2);
setIsRunning(true);
setyPos(getyPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tdown.stop();
}
}
},0,0.03f);
tdown.stop();
tleft.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(3);
setIsRunning(true);
setxPos(getxPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tleft.stop();
}
}
},0,0.03f);
tleft.stop();
} }
@ -122,42 +50,7 @@ public abstract class Entity {
} }
public void rdmMove(){ public void rdmMove(){
double i = Math.random();
if(i <= 0.2){
if(isRunning == false){
tup.start();
}
}
else if(i > 0.2 && i <= 0.4){
if(isRunning == false){
tright.start();
}
}
else if(i > 0.4 && i <= 0.6){
if(isRunning == false){
if(yPos == 0){
}
else{
tdown.start();
}
}
}
else if(i > 0.6 && i <= 0.8){
if(isRunning == false){
if(xPos == 0){
}
else{
tleft.start();
}
}
}
else{
facing = 2;
}
move();
} }
public int direction(){ // returns direction the entity is facing depending on its movement public int direction(){ // returns direction the entity is facing depending on its movement
@ -246,27 +139,6 @@ public abstract class Entity {
return this.id; return this.id;
} }
private void setIsRunning(boolean n){
isRunning = n;
}
private boolean getIsRunning(){
return isRunning;
}
public int getTimerRuns(){
return timerRuns;
}
public void setTimerRuns(int n){
timerRuns = n;
}
public void setFacing(int i){
facing = i;
}
public int getFacing(){
return facing;
}
} }

@ -1,8 +1,19 @@
package com.dungeoncrawler.model.entities; package com.dungeoncrawler.model.entities;
import com.dungeoncrawler.model.Entity; import com.dungeoncrawler.model.Entity;
import com.badlogic.gdx.utils.Timer;
public class Archer extends Entity{ public class Archer extends Entity{
Timer t;
Timer tup;
Timer tright;
Timer tdown;
Timer tleft;
int timerRuns;
boolean isRunning;
int facing;
public Archer(float xPos, float yPos, int lvl) { public Archer(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl); super(xPos, yPos, lvl);
@ -12,6 +23,140 @@ public class Archer extends Entity{
this.dmg = 3*lvl; this.dmg = 3*lvl;
this.id = 0; this.id = 0;
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
tup = new Timer();
tright = new Timer();
tdown = new Timer();
tleft = new Timer();
isRunning = false;
timerRuns = 0;
facing = 2;
t = new Timer();
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
double i = Math.random();
if(i <= 0.2){
if(isRunning == false){
tup.start();
}
}
else if(i > 0.2 && i <= 0.4){
if(isRunning == false){
tright.start();
}
}
else if(i > 0.4 && i <= 0.6){
if(isRunning == false){
if(getyPos() == 0){
}
else{
tdown.start();
}
}
}
else if(i > 0.6 && i <= 0.8){
if(isRunning == false){
if(getxPos() == 0){
}
else{
tleft.start();
}
}
}
else{
facing = 2;
}
}
},0,1f);
t.stop();
tup.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(0);
setIsRunning(true);
setyPos(getyPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tup.stop();
}
}
},0,0.03f);
tup.stop();
tright.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(1);
setIsRunning(true);
setxPos(getxPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tright.stop();
}
}
},0,0.03f);
tright.stop();
tdown.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(2);
setIsRunning(true);
setyPos(getyPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tdown.stop();
}
}
},0,0.03f);
tdown.stop();
tleft.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(3);
setIsRunning(true);
setxPos(getxPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tleft.stop();
}
}
},0,0.03f);
tleft.stop();
t.start();
}
private void setIsRunning(boolean n){
isRunning = n;
}
private boolean getIsRunning(){
return isRunning;
}
public int getTimerRuns(){
return timerRuns;
}
public void setTimerRuns(int n){
timerRuns = n;
}
public void setFacing(int i){
facing = i;
}
public int getFacing(){
return facing;
} }
} }

@ -1,8 +1,18 @@
package com.dungeoncrawler.model.entities; package com.dungeoncrawler.model.entities;
import com.badlogic.gdx.utils.Timer;
import com.dungeoncrawler.model.Entity; import com.dungeoncrawler.model.Entity;
public class Swordsman extends Entity { public class Swordsman extends Entity {
Timer t;
Timer tup;
Timer tright;
Timer tdown;
Timer tleft;
int timerRuns;
boolean isRunning;
int facing;
public Swordsman(float xPos, float yPos, int lvl) { public Swordsman(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl); super(xPos, yPos, lvl);
@ -12,6 +22,138 @@ public class Swordsman extends Entity {
this.dmg = 3*lvl; this.dmg = 3*lvl;
this.id = 1; this.id = 1;
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
tup = new Timer();
tright = new Timer();
tdown = new Timer();
tleft = new Timer();
isRunning = false;
timerRuns = 0;
facing = 2;
t = new Timer();
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
double i = Math.random();
if(i <= 0.2){
if(isRunning == false){
tup.start();
}
}
else if(i > 0.2 && i <= 0.4){
if(isRunning == false){
tright.start();
}
}
else if(i > 0.4 && i <= 0.6){
if(isRunning == false){
if(getyPos() == 0){
}
else{
tdown.start();
}
}
}
else if(i > 0.6 && i <= 0.8){
if(isRunning == false){
if(getxPos() == 0){
}
else{
tleft.start();
}
}
}
else{
facing = 2;
}
}
},0,1f);
t.stop();
tup.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(0);
setIsRunning(true);
setyPos(getyPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tup.stop();
}
}
},0,0.03f);
tup.stop();
tright.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(1);
setIsRunning(true);
setxPos(getxPos() + 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tright.stop();
}
}
},0,0.03f);
tright.stop();
tdown.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(2);
setIsRunning(true);
setyPos(getyPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tdown.stop();
}
}
},0,0.03f);
tdown.stop();
tleft.scheduleTask(new Timer.Task() {
@Override
public void run() {
setFacing(3);
setIsRunning(true);
setxPos(getxPos() - 1f);
setTimerRuns(getTimerRuns() + 1);
if(getTimerRuns() >= 48){
setTimerRuns(0);
setIsRunning(false);
tleft.stop();
}
}
},0,0.03f);
tleft.stop();
t.start();
} }
private void setIsRunning(boolean n){
isRunning = n;
}
private boolean getIsRunning(){
return isRunning;
}
public int getTimerRuns(){
return timerRuns;
}
public void setTimerRuns(int n){
timerRuns = n;
}
public void setFacing(int i){
facing = i;
}
public int getFacing(){
return facing;
}
} }

Loading…
Cancel
Save