|
|
|
@ -13,25 +13,21 @@ import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
|
|
|
|
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
|
|
|
|
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
|
|
|
|
import com.dungeoncrawler.model.Dungeon;
|
|
|
|
import com.dungeoncrawler.model.Dungeon;
|
|
|
|
import com.dungeoncrawler.model.DungeonGenerator;
|
|
|
|
import com.dungeoncrawler.model.DungeonGenerator;
|
|
|
|
|
|
|
|
import com.dungeoncrawler.model.Entity;
|
|
|
|
import com.dungeoncrawler.model.entities.*;
|
|
|
|
import com.dungeoncrawler.model.entities.*;
|
|
|
|
|
|
|
|
|
|
|
|
public class View {
|
|
|
|
public class View {
|
|
|
|
Texture b;
|
|
|
|
//PLAYER
|
|
|
|
Texture t;
|
|
|
|
|
|
|
|
Texture p;
|
|
|
|
Texture p;
|
|
|
|
Texture a;
|
|
|
|
|
|
|
|
Sprite button;
|
|
|
|
|
|
|
|
Sprite title;
|
|
|
|
|
|
|
|
Sprite player;
|
|
|
|
Sprite player;
|
|
|
|
Sprite archer;
|
|
|
|
|
|
|
|
int PlayerFrame = 0;
|
|
|
|
|
|
|
|
int PlayerZeile = 0;
|
|
|
|
|
|
|
|
TextureRegion[][] regions;
|
|
|
|
TextureRegion[][] regions;
|
|
|
|
Timer tunten;
|
|
|
|
|
|
|
|
Timer toben;
|
|
|
|
|
|
|
|
Timer tlinks;
|
|
|
|
|
|
|
|
Timer trechts;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ENTITIES
|
|
|
|
|
|
|
|
Texture[] entityTextures;
|
|
|
|
|
|
|
|
Sprite[] entitySprites;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//MAP
|
|
|
|
Map tm;
|
|
|
|
Map tm;
|
|
|
|
TiledMapRenderer tmr;
|
|
|
|
TiledMapRenderer tmr;
|
|
|
|
TiledMap test;
|
|
|
|
TiledMap test;
|
|
|
|
@ -39,30 +35,23 @@ public class View {
|
|
|
|
Dungeon d;
|
|
|
|
Dungeon d;
|
|
|
|
|
|
|
|
|
|
|
|
public View() {
|
|
|
|
public View() {
|
|
|
|
b = new Texture("Button.png");
|
|
|
|
|
|
|
|
t = new Texture("Title.png");
|
|
|
|
|
|
|
|
p = new Texture("animplay.png");
|
|
|
|
|
|
|
|
a = new Texture("Archer-64.png");
|
|
|
|
|
|
|
|
button = new Sprite(b);
|
|
|
|
|
|
|
|
title = new Sprite(t);
|
|
|
|
|
|
|
|
archer = new Sprite(a);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float w = Gdx.graphics.getWidth();
|
|
|
|
float w = Gdx.graphics.getWidth();
|
|
|
|
float h = Gdx.graphics.getHeight();
|
|
|
|
float h = Gdx.graphics.getHeight();
|
|
|
|
float wc = w/2;
|
|
|
|
float wc = w/2;
|
|
|
|
title.setX(wc - (title.getWidth()/2));
|
|
|
|
|
|
|
|
title.setY(h - 200);
|
|
|
|
//PLAYER
|
|
|
|
button.setX(wc - (button.getWidth()/2));
|
|
|
|
p = new Texture("Player.png");
|
|
|
|
button.setY(400);
|
|
|
|
regions = TextureRegion.split(p, 64, 64);
|
|
|
|
regions = TextureRegion.split(p, 32, 32);
|
|
|
|
|
|
|
|
player = new Sprite(regions[0][2]);
|
|
|
|
player = new Sprite(regions[0][2]);
|
|
|
|
player.setX(200);
|
|
|
|
player.setX(200);
|
|
|
|
player.setY(200);
|
|
|
|
player.setY(200);
|
|
|
|
tunten = new Timer();
|
|
|
|
|
|
|
|
toben = new Timer();
|
|
|
|
|
|
|
|
tlinks = new Timer();
|
|
|
|
|
|
|
|
trechts = new Timer();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ENTITIES
|
|
|
|
|
|
|
|
entityTextures = new Texture[5];
|
|
|
|
|
|
|
|
entitySprites = new Sprite[5];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//MAP
|
|
|
|
tm = new Map();
|
|
|
|
tm = new Map();
|
|
|
|
camera = new OrthographicCamera(1, h/w);
|
|
|
|
camera = new OrthographicCamera(1, h/w);
|
|
|
|
d = new DungeonGenerator().generateDungeon(10, 10, 48, new Player());
|
|
|
|
d = new DungeonGenerator().generateDungeon(10, 10, 48, new Player());
|
|
|
|
@ -80,117 +69,27 @@ public class View {
|
|
|
|
tmr = new OrthogonalTiledMapRenderer(test);
|
|
|
|
tmr = new OrthogonalTiledMapRenderer(test);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tunten.scheduleTask(new Timer.Task() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
PlayerZeile = 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(PlayerFrame == 9){
|
|
|
|
|
|
|
|
PlayerFrame = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
PlayerFrame++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},0,1/5f);
|
|
|
|
|
|
|
|
tunten.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toben.scheduleTask(new Timer.Task() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
PlayerZeile = 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(PlayerFrame == 9){
|
|
|
|
|
|
|
|
PlayerFrame = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
PlayerFrame++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 0,1/5f);
|
|
|
|
|
|
|
|
toben.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tlinks.scheduleTask(new Timer.Task() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
PlayerZeile = 2;
|
|
|
|
|
|
|
|
if(player.isFlipX() == true){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
player.flip(true, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(PlayerFrame == 9){
|
|
|
|
|
|
|
|
PlayerFrame = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
PlayerFrame++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 0,1/5f);
|
|
|
|
|
|
|
|
tlinks.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trechts.scheduleTask(new Timer.Task() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
PlayerZeile = 2;
|
|
|
|
|
|
|
|
if(player.isFlipX() == true){
|
|
|
|
|
|
|
|
player.flip(false, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(PlayerFrame == 9){
|
|
|
|
|
|
|
|
PlayerFrame = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
PlayerFrame++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 0,1/5f);
|
|
|
|
|
|
|
|
trechts.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void render (SpriteBatch batch, Player p, Archer a) {
|
|
|
|
public void render (SpriteBatch batch, Player p, Archer a) {
|
|
|
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
|
|
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
player.setX(player.getX()+ (float) p.getMovementX());
|
|
|
|
player.setX(player.getX()+ p.getMovementX());
|
|
|
|
player.setY(player.getY()+ (float) p.getMovementY());
|
|
|
|
player.setY(player.getY()+ p.getMovementY());
|
|
|
|
archer.setX((float)a.getxPos());
|
|
|
|
|
|
|
|
archer.setY((float)a.getyPos());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(p.getMovementX() == 3){
|
|
|
|
if(p.getMovementX() == 3){
|
|
|
|
trechts.start();
|
|
|
|
player.setRegion(regions[0][1]);
|
|
|
|
if(player.isFlipX() == true){
|
|
|
|
|
|
|
|
player.flip(false, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(p.getMovementX() == -3){
|
|
|
|
if(p.getMovementX() == -3){
|
|
|
|
tlinks.start();
|
|
|
|
player.setRegion(regions[0][3]);
|
|
|
|
if(player.isFlipX() == true){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
player.flip(true, false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(p.getMovementY() == 3){
|
|
|
|
if(p.getMovementY() == 3){
|
|
|
|
toben.start();
|
|
|
|
player.setRegion(regions[0][0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(p.getMovementY() == -3){
|
|
|
|
if(p.getMovementY() == -3){
|
|
|
|
tunten.start();
|
|
|
|
player.setRegion(regions[0][2]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tmr.setView(camera);
|
|
|
|
tmr.setView(camera);
|
|
|
|
@ -201,31 +100,38 @@ public class View {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
batch.begin();
|
|
|
|
batch.begin();
|
|
|
|
title.draw(batch);
|
|
|
|
|
|
|
|
button.draw(batch);
|
|
|
|
|
|
|
|
player.draw(batch);
|
|
|
|
player.draw(batch);
|
|
|
|
archer.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);
|
|
|
|
|
|
|
|
}
|
|
|
|
batch.end();
|
|
|
|
batch.end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void newEntity(int i,Entity e, int x, int y){
|
|
|
|
public void tuntenstop(){
|
|
|
|
if(e.getId() == 0){
|
|
|
|
tunten.stop();
|
|
|
|
entityTextures[i] = new Texture("archer.png");
|
|
|
|
PlayerFrame = 0;
|
|
|
|
entitySprites[i] = new Sprite(entityTextures[i]);
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);}
|
|
|
|
entitySprites[i].setX(x);
|
|
|
|
public void tobenstop(){
|
|
|
|
entitySprites[i].setY(y);
|
|
|
|
toben.stop();
|
|
|
|
}
|
|
|
|
PlayerFrame = 0;
|
|
|
|
else if(e.getId() == 1){
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);}
|
|
|
|
entityTextures[i] = new Texture("Swordsman.png");
|
|
|
|
public void tlinksstop(){
|
|
|
|
entitySprites[i] = new Sprite(entityTextures[i]);
|
|
|
|
tlinks.stop();
|
|
|
|
entitySprites[i].setX(x);
|
|
|
|
PlayerFrame = 0;
|
|
|
|
entitySprites[i].setY(y);
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);
|
|
|
|
}
|
|
|
|
player.flip(true, false);}
|
|
|
|
}
|
|
|
|
public void trechtsstop(){
|
|
|
|
|
|
|
|
trechts.stop();
|
|
|
|
|
|
|
|
PlayerFrame = 0;
|
|
|
|
|
|
|
|
player.setRegion(regions[PlayerZeile][PlayerFrame]);}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|