Jonathan Hager 6 years ago
parent 7a82ca3760
commit fbc3a82c23

@ -133,6 +133,9 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
d.setCurrentRoom(d.getCurrentLevel().getRooms()[roomPosX][roomPosY]);
d.setCurrentEntities(d.getCurrentRoom().getEnemies());
d.initVisited(roomAmount);
d.updateVisited(roomPosX, roomPosY);
Gdx.input.setInputProcessor(this);
@ -391,7 +394,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(gs != null){;
d.getPlayer().updateItems();
hc.updateHud(batch, d.getPlayer());
gs.render(batch, d.getPlayer(), d.getCurrentEntities(), tileX, tileY, level, roomPosX, roomPosY, camera);
gs.render(batch, d.getPlayer(), d.getCurrentEntities(), tileX, tileY, level, roomPosX, roomPosY, camera, d.getVisited());
}
}
@ -560,16 +563,21 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
int roomAmount = d.getLevel()[level].getRooms().length;
roomPosX = roomAmount / 2;
roomPosY = roomAmount / 2;
d.initVisited(roomAmount);
}
else{ // Dungeon Exit
end = true;
return;
}
}
d.updateVisited(roomPosX, roomPosY);
d.setCurrentLevel(d.getLevel()[level]);
d.setCurrentRoom(d.getCurrentLevel().getRooms()[roomPosX][roomPosY]);
d.setCurrentEntities(d.getCurrentRoom().getEnemies());
gs.generateEntitySprites(d.getCurrentEntities());

@ -18,6 +18,9 @@ public class Dungeon {
private Level currentLevel;
private Room currentRoom;
private Entity[] currentEntities;
// 0: not found, 1: found, 2: visited
private int[][] isVisited;
public Dungeon(Player player){
this.level = new Level[7];
@ -27,6 +30,10 @@ public class Dungeon {
public void update(){
// TODO: Implementieren
}
public void initVisited(int amount){
isVisited = new int[amount][amount];
}
/**
* @return the level
@ -103,5 +110,45 @@ public class Dungeon {
public void setCurrentEntities(Entity[] currentEntities) {
this.currentEntities = currentEntities;
}
public int getVisited(int i, int j){
return isVisited[i][j];
}
public int[][] getVisited(){
return isVisited;
}
public void setVisited(int i, int j, int value){
isVisited[i][j] = value;
}
public void updateVisited(int roomX, int roomY){
// currentRoom is visited, therefore set to 2
isVisited[roomX][roomY] = 2;
// all neighboring rooms are now found, set to 1, if possible
// left
if(roomX > 0 && currentLevel.getRooms()[roomX - 1][roomY] != null){
isVisited[roomX - 1][roomY] = 1;
}
// right
if(roomX < currentLevel.getRooms().length - 1 && currentLevel.getRooms()[roomX + 1][roomY] != null){
isVisited[roomX + 1][roomY] = 1;
}
// top
if(roomY > 0 && currentLevel.getRooms()[roomX][roomY - 1] != null){
isVisited[roomX][roomY - 1] = 1;
}
// bottom
if(roomY < currentLevel.getRooms().length - 1 && currentLevel.getRooms()[roomX][roomY + 1] != null){
isVisited[roomX][roomY + 1] = 1;
}
}
}

@ -2,6 +2,7 @@ package com.dungeoncrawler.view;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
@ -47,6 +48,9 @@ public class GameScreen {
public ArrayList<AnimatedObject> objects;
public ArrayList<AnimatedObject> mapItems;
public ArrayList<AnimatedObject> doors;
// MiniMap
ShapeRenderer shapeRenderer;
Timer animations;
Timer animatePlayer;
@ -122,6 +126,8 @@ public class GameScreen {
m = mg.generateMap(d);
mg.ichWillSpielen(m.getMaps());
shapeRenderer = new ShapeRenderer();
tm = new TiledMap();
tmr = new OrthogonalTiledMapRenderer(tm);
@ -212,7 +218,9 @@ public class GameScreen {
}
public void render (SpriteBatch batch, Player p, Entity[] e, int tileX, int tileY, int level, int roomPosX, int roomPosY, OrthographicCamera camera) {
public void render (SpriteBatch batch, Player p, Entity[] e, int tileX, int tileY, int level, int roomPosX, int roomPosY, OrthographicCamera camera, int[][] miniMap) {
shapeRenderer.setProjectionMatrix(camera.combined);
entities = e;
@ -303,6 +311,41 @@ public class GameScreen {
batch.end();
int mapX = 10;
int mapY = 320;
int gap = 2;
int rectWidth = 15;
int rectHeight = 10;
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
for(int i = 0; i < miniMap.length; i++){
for(int j = 0; j < miniMap.length; j++){
// current Room
if(i == roomPosX && j == roomPosY){
shapeRenderer.setColor(Color.GREEN);
}
// not found
else if(miniMap[i][j] == 0){
shapeRenderer.setColor(Color.WHITE);
}
// found
else if(miniMap[i][j] == 1){
shapeRenderer.setColor(Color.DARK_GRAY);
}
// visited
else if(miniMap[i][j] == 2){
shapeRenderer.setColor(Color.LIGHT_GRAY);
}
if(miniMap[i][j] != 0 || true) {
shapeRenderer.rect(i * gap + i * rectWidth + mapX, j * gap + j * rectHeight + mapY, rectWidth, rectHeight);
}
}
}
shapeRenderer.end();
// BUTTON HITBOXES
/*
ShapeRenderer lol = new ShapeRenderer();

Loading…
Cancel
Save