master
GammelJan 6 years ago
parent a32488536e
commit c158ed733a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 756 B

After

Width:  |  Height:  |  Size: 1003 B

@ -31,17 +31,18 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override
public void create(){
a = new Archer(200,200,200);
e = new Entity[5];
batch = new SpriteBatch();
v = new MainMenu();
p = new Player();
d = new Dungeon(p);
dg = new DungeonGenerator();
dg.ichWillSpielen();
e = new Entity[5];
Gdx.input.setInputProcessor(this);
t = new Timer();
a = new Archer(0,0,0);
t.scheduleTask(new Timer.Task() {
@Override
public void run() {
@ -55,41 +56,51 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
},0,0.1f);
}
public void newEntity(Entity ent, int x, int y, int lvl){
for(int i = 0; i < e.length ; i++){
if(e[i] == null){
switch(ent.getId()){
case 0:
e[i] = new Archer(x,y,lvl);
m.newEntity(i,ent,x,y);
i = 10;
break;
case 1:
e[i] = new Swordsman(x,y,lvl);
m.newEntity(i,ent,x,y);
i = 10;
break;
}
}
}
}
@Override
public void render(){
//PASSIERT IN MAINMENU
if(v != null){
v.render(batch, p , e);
}
if(v == null){
m.render(batch, p, a);
//PASSIERT IN GAMESCREEN (view)
if(m != null){
//ENTITIES
//RENDER
m.render(batch, p, e);
}
}
@Override
public void dispose () {
batch.dispose();
}
public void newEntity(Entity ent, int x, int y, int lvl){
for(int i = 0; i < e.length ; i++){
if(e[i] == null){
switch(ent.getId()){
case 0:
e[i] = new Archer(x,y,lvl);
m.newEntity(i,ent,x,y);
i = 10;
break;
case 1:
e[i] = new Swordsman(x,y,lvl);
m.newEntity(i,ent,x,y);
i = 10;
break;
}
}
}
}
@Override
public boolean keyDown(int keycode) {
if(keycode == Input.Keys.LEFT){
@ -134,6 +145,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
else if(v.click() == 0){
v = null;
m = new View();
newEntity(a, 200, 200, 200);
System.out.println("NICE");
}
}

@ -59,6 +59,22 @@ public abstract class Entity {
}
}
public int direction(){
if(movementX == -3){
return 3;
}
if(movementX == 3){
return 1;
}
if(movementY == 3){
return 0;
}
if(movementY == -3){
return 2;
}
return -1;
}
public int getxPos() {
return xPos;

@ -26,6 +26,8 @@ public class View {
//ENTITIES
Texture[] entityTextures;
Sprite[] entitySprites;
TextureRegion[][] archerRegions;
Texture archerTexture;
//MAP
Map tm;
@ -49,6 +51,9 @@ public class View {
//ENTITIES
entityTextures = new Texture[5];
entitySprites = new Sprite[5];
archerTexture = new Texture("archer.png");
archerRegions = TextureRegion.split(archerTexture, 64, 64);
//MAP
@ -72,9 +77,11 @@ public class View {
}
public void render (SpriteBatch batch, Player p, Archer a) {
public void render (SpriteBatch batch, Player p, Entity[] e) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
//PLAYER
player.setX(player.getX()+ p.getMovementX());
player.setY(player.getY()+ p.getMovementY());
@ -92,6 +99,7 @@ public class View {
player.setRegion(regions[0][2]);
}
//MAP
tmr.setView(camera);
tmr.render();
camera.zoom = 1000f;
@ -99,22 +107,35 @@ public class View {
batch.setProjectionMatrix(camera.combined);
//BATCH
batch.begin();
player.draw(batch);
if(entitySprites[0] != null){
entitySprites[0].draw(batch);
}
if(entitySprites[1] != null){
entitySprites[1].draw(batch);
}
if(entitySprites[2] != null){
entitySprites[2].draw(batch);
}
if(entitySprites[3] != null){
entitySprites[3].draw(batch);
}
if(entitySprites[4] != null){
entitySprites[4].draw(batch);
for(int i = 0; i < e.length; i++){
if(entitySprites[i] != null){
entitySprites[i].setX(e[i].getxPos());
entitySprites[i].setY(e[i].getyPos());
switch(e[i].direction()){
case -1:
break;
case 0:
entitySprites[i].setRegion(archerRegions[0][0]);
break;
case 1:
entitySprites[i].setRegion(archerRegions[0][1]);
break;
case 2:
entitySprites[i].setRegion(archerRegions[0][2]);
break;
case 3:
entitySprites[i].setRegion(archerRegions[0][3]);
break;
}
entitySprites[i].draw(batch);
}
}
batch.end();
}
@ -123,7 +144,7 @@ public class View {
public void newEntity(int i,Entity e, int x, int y){
if(e.getId() == 0){
entityTextures[i] = new Texture("archer.png");
entitySprites[i] = new Sprite(entityTextures[i]);
entitySprites[i] = new Sprite(archerRegions[0][2]);
entitySprites[i].setX(x);
entitySprites[i].setY(y);
}

Loading…
Cancel
Save