Merge branch 'Jan'

ICH WILL MERGEN
master
GammelJan 6 years ago
commit 1e289b5510

@ -49,7 +49,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
for(int i = 0; i< e.length; i++){ for(int i = 0; i< e.length; i++){
if(e[i] == null){} if(e[i] == null){}
else{ else{
e[i].rdmMove(); e[i].rdmMove(p.getxPos(), p.getyPos());
m.setPlayerSpriteX(p.getxPos());
m.setPlayerSpriteY(p.getyPos());
m.setEntitySpriteX(i,p.getxPos());
m.setEntitySpriteY(i,p.getxPos());
} }
} }
} }
@ -66,7 +70,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
//PASSIERT IN GAMESCREEN (view) //PASSIERT IN GAMESCREEN (view)
if(m != null){ if(m != null){
//ENTITIES //ENTITIES
p.setxPos(m.getPlayerSpriteX());
p.setyPos(m.getPlayerSpriteY());
//RENDER //RENDER

@ -3,17 +3,17 @@ package com.dungeoncrawler.model;
public abstract class Entity { public abstract class Entity {
protected int xPos; protected float xPos;
protected int yPos; protected float yPos;
protected int hp; protected int hp;
protected int maxhp; protected int maxhp;
protected int dmg; protected int dmg;
protected int lvl; protected int lvl;
protected int movementX; protected float movementX;
protected int movementY; protected float movementY;
protected int id; protected int id;
public Entity(int xPos, int yPos, int lvl){ public Entity(int xPos, float yPos, int lvl){
this.xPos = xPos; this.xPos = xPos;
this.yPos = yPos; this.yPos = yPos;
this.lvl = lvl; this.lvl = lvl;
@ -35,10 +35,62 @@ public abstract class Entity {
public void move(){ public void move(){
xPos = xPos + movementX; xPos = xPos + movementX;
yPos = yPos + movementY; yPos = yPos + movementY;
movementX = 0;
movementY = 0;
} }
public void rdmMove(){ public void rdmMove(float xPlayer, float yPlayer){
if(xPlayer == xPos){
if(yPlayer == yPos){}
else if(yPlayer > yPos){movementY = -1f;}
else if(yPlayer < yPos){movementY = 1f;}
}
else if(yPlayer == yPos){
if(xPlayer == xPos){}
else if(xPlayer > xPos){movementX = 1f;}
else if(xPlayer < xPos){movementX = -1f;}
}
else if(xPlayer > xPos){
if(yPlayer > yPos){ //archer ist im Quadrant III
if((yPos - yPlayer) > (xPos - xPlayer)){
movementY = 1f;
}
else{
movementX = 1f;
}
}
else if(yPlayer < yPos){ //archer ist im Quadrant IV
if((yPos - yPlayer) > (xPlayer - xPos)){
movementX = 1f;
}
else{
movementY = -1f;
}
}
}
else if(xPlayer < xPos){
if(yPlayer < yPos){ //archer ist im Quadrant II
if((yPlayer - yPos) > (xPlayer - xPos)){
movementX = -1f;
}
else{
movementY = 1f;
}
}
else if(yPlayer > yPos){ //archer ist im Quadrant I
if((yPlayer - yPos) > (xPos - xPlayer)){
movementY = -1;
}
else{
movementX = -1;
}
}
}
move();
/*
switch((int) (Math.random() * 5)){ switch((int) (Math.random() * 5)){
case 0: //left case 0: //left
setMovementX(-3); setMovementX(-3);
@ -57,6 +109,23 @@ public abstract class Entity {
move(); move();
break; break;
} }
*/
}
public int direction(){
if(movementX < 0f){
return 3;
}
else if(movementX < 3f){
return 1;
}
else if(movementY > 3f){
return 0;
}
else if(movementY < -3f){
return 2;
}
return -1;
} }
public int direction(){ public int direction(){
@ -76,19 +145,19 @@ public abstract class Entity {
} }
public int getxPos() { public float getxPos() {
return xPos; return xPos;
} }
public void setxPos(int xPos) { public void setxPos(float xPos) {
this.xPos = xPos; this.xPos = xPos;
} }
public int getyPos() { public float getyPos() {
return yPos; return yPos;
} }
public void setyPos(int yPos) { public void setyPos(float yPos) {
this.yPos = yPos; this.yPos = yPos;
} }
@ -124,19 +193,19 @@ public abstract class Entity {
this.lvl = lvl; this.lvl = lvl;
} }
public int getMovementX(){ public float getMovementX(){
return movementX; return movementX;
} }
public void setMovementX(int movementX){ public void setMovementX(float movementX){
this.movementX = movementX; this.movementX = movementX;
} }
public int getMovementY(){ public float getMovementY(){
return movementY; return movementY;
} }
public void setMovementY(int movementY){ public void setMovementY(float movementY){
this.movementY = movementY; this.movementY = movementY;
} }

@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dungeoncrawler.view;
import com.dungeoncrawler.model.entities.Player;
/**
*
* @author Jan
*/
public class Hud {
public Hud(Player p){}
}

@ -23,6 +23,7 @@ public class View {
TextureRegion[][] regions; TextureRegion[][] regions;
//ENTITIES //ENTITIES
Texture[] entityTextures; Texture[] entityTextures;
Sprite[] entitySprites; Sprite[] entitySprites;
@ -155,4 +156,31 @@ public class View {
entitySprites[i].setY(y); entitySprites[i].setY(y);
} }
} }
public float getPlayerSpriteX(){
return player.getX();
}
public float getPlayerSpriteY(){
return player.getY();
}
public void setPlayerSpriteX(float x){
player.setX(x);
}
public void setPlayerSpriteY(float y){
player.setY(y);
}
public float getEntitySpriteX(int i){
return entitySprites[i].getX();
}
public float getEntitySpriteY(int i){
return entitySprites[i].getY();
}
public void setEntitySpriteX(int i,float x){
entitySprites[i].setX(x);
}
public void setEntitySpriteY(int i,float y){
entitySprites[i].setY(y);
}
} }

Loading…
Cancel
Save