diff --git a/core/assets/Archer-64.png b/core/assets/Archer-64.png deleted file mode 100644 index 26ecf00..0000000 Binary files a/core/assets/Archer-64.png and /dev/null differ diff --git a/core/assets/Player.png b/core/assets/Player.png index 174204e..74b08ff 100644 Binary files a/core/assets/Player.png and b/core/assets/Player.png differ diff --git a/core/assets/Swordsman.png b/core/assets/Swordsman.png new file mode 100644 index 0000000..cf73c7e Binary files /dev/null and b/core/assets/Swordsman.png differ diff --git a/core/assets/animplay.png b/core/assets/animplay.png deleted file mode 100644 index 881f12f..0000000 Binary files a/core/assets/animplay.png and /dev/null differ diff --git a/core/assets/badlogic.jpg b/core/assets/badlogic.jpg deleted file mode 100644 index 4390da6..0000000 Binary files a/core/assets/badlogic.jpg and /dev/null differ diff --git a/core/assets/cursor.png b/core/assets/cursor.png new file mode 100644 index 0000000..92230ec Binary files /dev/null and b/core/assets/cursor.png differ diff --git a/core/assets/key.png b/core/assets/key.png new file mode 100644 index 0000000..2376f7f Binary files /dev/null and b/core/assets/key.png differ diff --git a/core/src/com/dungeoncrawler/control/Controller.java b/core/src/com/dungeoncrawler/control/Controller.java index 3986e0c..922f833 100644 --- a/core/src/com/dungeoncrawler/control/Controller.java +++ b/core/src/com/dungeoncrawler/control/Controller.java @@ -10,49 +10,72 @@ import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.dungeoncrawler.view.View; +import com.dungeoncrawler.view.*; import com.dungeoncrawler.model.Dungeon; import com.dungeoncrawler.model.DungeonGenerator; -import com.dungeoncrawler.model.entities.Player; -import com.dungeoncrawler.model.entities.Archer; +import com.dungeoncrawler.model.entities.*; +import com.dungeoncrawler.model.Entity; import com.badlogic.gdx.utils.Timer; public class Controller extends ApplicationAdapter implements InputProcessor{ SpriteBatch batch; Dungeon d; DungeonGenerator dg; - View v; - Player p; - Archer a; + MainMenu v; + Player p; + Entity[] e; Timer t; + Map m; @Override public void create(){ batch = new SpriteBatch(); - v = new View(); + v = new MainMenu(); p = new Player(); d = new Dungeon(p); - dg = new DungeonGenerator(); dg.ichWillSpielen(); - - p = new Player(); - d = new Dungeon(p); - a = new Archer(500, 200, 1); - + e = new Entity[5]; Gdx.input.setInputProcessor(this); t = new Timer(); t.scheduleTask(new Timer.Task() { @Override public void run() { - a.rdmMove(); + for(int i = 0; i< e.length; i++){ + if(e[i] == null){} + else{ + e[i].rdmMove(); + } + } } },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); + v.newEntity(i,ent,x,y); + i = 10; + break; + case 1: + e[i] = new Swordsman(x,y,lvl); + v.newEntity(i,ent,x,y); + i = 10; + break; + } + + } + } + } + @Override public void render(){ - v.render(batch, p , a); + if(v != null){ + v.render(batch, p , e); + } } @Override @@ -63,22 +86,50 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ @Override public boolean keyDown(int keycode) { if(keycode == Input.Keys.LEFT){ - p.setMovementX(-3); + if(v != null){ + v.moveCursor(3); + } + if(m != null){ + p.setMovementX(-5); + } } if(keycode == Input.Keys.RIGHT){ - p.setMovementX(3); - } - - if(keycode == Input.Keys.UP){ - p.setMovementY(3); + if(v != null){ + v.moveCursor(1); + } + if(m != null){ + p.setMovementX(5); + } } if(keycode == Input.Keys.DOWN){ - p.setMovementY(-3); + if(v != null){ + v.moveCursor(2); + } + if(m != null){ + p.setMovementY(-5); + } } - if(keycode == Input.Keys.W){ - + + if(keycode == Input.Keys.UP){ + if(v != null){ + v.moveCursor(0); + } + if(m != null){ + p.setMovementY(5); + } + } + + if(keycode == Input.Keys.ENTER){ + if(v != null){ + if(v.click() == -1){} + else if(v.click() == 0){ + v = null; + m = new Map(); + System.out.println("NICE"); + } + } } return true; } @@ -86,24 +137,40 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ @Override public boolean keyUp(int keycode) { if(keycode == Input.Keys.LEFT){ + if(v != null){ + v.stopCursor(3); + } + if(m != null){ p.setMovementX(0); - v.tlinksstop(); + } } if(keycode == Input.Keys.RIGHT){ + if(v != null){ + v.stopCursor(1); + } + if(m != null){ p.setMovementX(0); - v.trechtsstop(); + } } if(keycode == Input.Keys.DOWN){ + if(v != null){ + v.stopCursor(2); + } + if(m != null){ p.setMovementY(0); - v.tuntenstop(); + } } if(keycode == Input.Keys.UP){ + if(v != null){ + v.stopCursor(0); + } + if(m != null){ p.setMovementY(0); - v.tobenstop(); - } + } + } return true; } @@ -113,9 +180,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{ } @Override - public boolean touchDown(int i, int i1, int i2, int i3) { - return false; - } + public boolean touchDown(int screenX, int screenY, int pointer, int button) + { + + return false; + } @Override public boolean touchUp(int i, int i1, int i2, int i3) { diff --git a/core/src/com/dungeoncrawler/model/DungeonGenerator.java b/core/src/com/dungeoncrawler/model/DungeonGenerator.java index 35716ef..0c108e8 100644 --- a/core/src/com/dungeoncrawler/model/DungeonGenerator.java +++ b/core/src/com/dungeoncrawler/model/DungeonGenerator.java @@ -37,11 +37,13 @@ public class DungeonGenerator { System.out.println(roomAmount); // TODO: Zufällig Türen setzen + //int xPos = roomAmount / 2; //int yPos = roomAmount / 2; int xPos = (int) (Math.random() * roomAmount); int yPos = (int) (Math.random() * roomAmount); + tempLevel.setRoom(generateRoom(), xPos, yPos); for(int i = 1; i < roomAmount;){ diff --git a/core/src/com/dungeoncrawler/model/Entity.java b/core/src/com/dungeoncrawler/model/Entity.java index 07d13e1..7747d27 100644 --- a/core/src/com/dungeoncrawler/model/Entity.java +++ b/core/src/com/dungeoncrawler/model/Entity.java @@ -11,6 +11,7 @@ public abstract class Entity { protected int lvl; protected int movementX; protected int movementY; + protected int id; public Entity(int xPos, int yPos, int lvl){ this.xPos = xPos; @@ -122,4 +123,8 @@ public abstract class Entity { public void setMovementY(int movementY){ this.movementY = movementY; } + + public int getId(){ + return this.id; + } } \ No newline at end of file diff --git a/core/src/com/dungeoncrawler/model/entities/Archer.java b/core/src/com/dungeoncrawler/model/entities/Archer.java index 361a710..a55f8e7 100644 --- a/core/src/com/dungeoncrawler/model/entities/Archer.java +++ b/core/src/com/dungeoncrawler/model/entities/Archer.java @@ -10,12 +10,8 @@ public class Archer extends Entity{ this.hp = this.maxhp; this.dmg = 3*lvl; - + this.id = 0; // TODO: Sinnvolle Werte finden } - - - - } diff --git a/core/src/com/dungeoncrawler/model/entities/Player.java b/core/src/com/dungeoncrawler/model/entities/Player.java index 98181f4..60a543b 100644 --- a/core/src/com/dungeoncrawler/model/entities/Player.java +++ b/core/src/com/dungeoncrawler/model/entities/Player.java @@ -20,7 +20,7 @@ public class Player extends Entity { this.hp = this.maxhp; this.dmg = 3*lvl; - + id = -1; // TODO: Sinnvolle Werte finden } diff --git a/core/src/com/dungeoncrawler/model/entities/Swordsman.java b/core/src/com/dungeoncrawler/model/entities/Swordsman.java index 4c43211..710cfc9 100644 --- a/core/src/com/dungeoncrawler/model/entities/Swordsman.java +++ b/core/src/com/dungeoncrawler/model/entities/Swordsman.java @@ -1,16 +1,6 @@ -/* - * 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.model.entities; - import com.dungeoncrawler.model.Entity; -/** - * - * @author Jan - */ public class Swordsman extends Entity { public Swordsman(int xPos, int yPos, int lvl) { @@ -20,10 +10,8 @@ public class Swordsman extends Entity { this.hp = this.maxhp; this.dmg = 3*lvl; - + this.id = 1; // TODO: Sinnvolle Werte finden } - - } diff --git a/core/src/com/dungeoncrawler/view/MainMenu.java b/core/src/com/dungeoncrawler/view/MainMenu.java new file mode 100644 index 0000000..545c364 --- /dev/null +++ b/core/src/com/dungeoncrawler/view/MainMenu.java @@ -0,0 +1,159 @@ +package com.dungeoncrawler.view; + +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.Texture; +import com.badlogic.gdx.graphics.g2d.SpriteBatch; +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.math.Rectangle; +import com.dungeoncrawler.model.entities.*; +import com.dungeoncrawler.model.Entity; + + +public class MainMenu{ + //MENU-SCREEN + Texture b; + Texture t; + Sprite button; + Sprite title; + + //ENTITIES + Texture[] entityTextures; + Sprite[] entitySprites; + + //CURSOR + Texture c; + Sprite cursor; + float CursorMoveX; + float CursorMoveY; + /* + //PLAYER + Texture p; + Sprite player; + TextureRegion[][] regions; + */ + public MainMenu() { + //MENU-SCREEN + float w = Gdx.graphics.getWidth(); + float h = Gdx.graphics.getHeight(); + float wc = w/2; + b = new Texture("Button.png"); + t = new Texture("Title.png"); + button = new Sprite(b); + title = new Sprite(t); + title.setX(wc - (title.getWidth()/2)); + title.setY(h - 200); + button.setX(wc - (button.getWidth()/2)); + button.setY(400); + //ENTITIES + entityTextures = new Texture[5]; + entitySprites = new Sprite[5]; + + //CURSOR + c = new Texture("cursor.png"); + cursor = new Sprite(c); + cursor.setX((float) w/2); + cursor.setY((float) h/2); + CursorMoveX = 0f; + CursorMoveY = 0f; + + //PLAYER + /* + p = new Texture("player.png"); + regions = TextureRegion.split(p, 64, 64); + player = new Sprite(regions[0][0]); + player.setX(200); + player.setY(200); + */ + } + + + public void render (SpriteBatch batch, Player p, Entity[] a) { + Gdx.gl.glClearColor(0, 0, 0, 1); + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + cursor.setX(cursor.getX()+ CursorMoveX); + cursor.setY(cursor.getY()+ CursorMoveY); + /* + player.setX(player.getX()+ (float) p.getMovementX()); + player.setY(player.getY()+ (float) p.getMovementY()); + + if(p.getMovementX() == 5){ + player.setRegion(regions[0][1]); + } + if(p.getMovementX() == -5){ + player.setRegion(regions[0][3]); + } + if(p.getMovementY() == 5){ + player.setRegion(regions[0][0]); + } + if(p.getMovementY() == -5){ + player.setRegion(regions[0][2]); + } + */ + batch.begin(); + title.draw(batch); + button.draw(batch); + cursor.draw(batch); + if(entitySprites[0] != null){ + entitySprites[0].draw(batch); + } + if(entitySprites[1] != null){ + entitySprites[1].draw(batch); + } + batch.end(); + } + + 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].setX(x); + entitySprites[i].setY(y); + } + else if(e.getId() == 1){ + entityTextures[i] = new Texture("Swordsman.png"); + entitySprites[i] = new Sprite(entityTextures[i]); + entitySprites[i].setX(x); + entitySprites[i].setY(y); + } + } + + + + public void moveCursor(int direction){ + switch(direction){ + case 0: + CursorMoveY = 10f; break; + case 1: + CursorMoveX = 10f; break; + case 2: + CursorMoveY = -10f; break; + case 3: + CursorMoveX = -10f; break; + } + } + public void stopCursor(int direction){ + switch(direction){ + case 0: + CursorMoveY = 0f; break; + case 1: + CursorMoveX = 0f; break; + case 2: + CursorMoveY = 0f; break; + case 3: + CursorMoveX = 0f; break; + } + } + public int click(){ + Rectangle rectangleCursor = cursor.getBoundingRectangle(); + Rectangle rectangleButton = button.getBoundingRectangle(); + boolean overlapsPlay = rectangleCursor.overlaps(rectangleButton); + if(overlapsPlay == true){ + return 0; + } + else{return -1;} + } + + + + } diff --git a/core/src/com/dungeoncrawler/view/Map.java b/core/src/com/dungeoncrawler/view/Map.java index cf09838..2fd734c 100644 --- a/core/src/com/dungeoncrawler/view/Map.java +++ b/core/src/com/dungeoncrawler/view/Map.java @@ -14,7 +14,6 @@ import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell; import com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile; -import com.badlogic.gdx.utils.Timer; /** * * @author jonathan diff --git a/core/src/com/dungeoncrawler/view/View.java b/core/src/com/dungeoncrawler/view/View.java deleted file mode 100644 index 766a266..0000000 --- a/core/src/com/dungeoncrawler/view/View.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.dungeoncrawler.view; - -import com.badlogic.gdx.Gdx; -import com.badlogic.gdx.graphics.GL20; -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.SpriteBatch; -import com.badlogic.gdx.graphics.g2d.Sprite; -import com.badlogic.gdx.utils.Timer; -import com.badlogic.gdx.graphics.g2d.TextureRegion; -import com.dungeoncrawler.model.entities.*; - -public class View { - Texture b; - Texture t; - Texture p; - Texture a; - Sprite button; - Sprite title; - Sprite player; - Sprite archer; - int PlayerFrame = 0; - int PlayerZeile = 0; - TextureRegion[][] regions; - Timer tunten; - Timer toben; - Timer tlinks; - Timer trechts; - - 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 h = Gdx.graphics.getHeight(); - float wc = w/2; - title.setX(wc - (title.getWidth()/2)); - title.setY(h - 200); - button.setX(wc - (button.getWidth()/2)); - button.setY(400); - regions = TextureRegion.split(p, 32, 32); - player = new Sprite(regions[0][2]); - player.setX(200); - player.setY(200); - tunten = new Timer(); - toben = new Timer(); - tlinks = new Timer(); - trechts = new Timer(); - - 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) { - Gdx.gl.glClearColor(0, 0, 0, 1); - Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); - player.setX(player.getX()+ (float) p.getMovementX()); - player.setY(player.getY()+ (float) p.getMovementY()); - archer.setX((float)a.getxPos()); - archer.setY((float)a.getyPos()); - - if(p.getMovementX() == 3){ - trechts.start(); - if(player.isFlipX() == true){ - player.flip(false, false); - } - } - if(p.getMovementX() == -3){ - tlinks.start(); - if(player.isFlipX() == true){ - - } - else{ - player.flip(true, false); - } - } - if(p.getMovementY() == 3){ - toben.start(); - } - if(p.getMovementY() == -3){ - tunten.start(); - } - - batch.begin(); - title.draw(batch); - button.draw(batch); - player.draw(batch); - archer.draw(batch); - batch.end(); - } - - - - public void tuntenstop(){ - tunten.stop(); - PlayerFrame = 0; - player.setRegion(regions[PlayerZeile][PlayerFrame]);} - public void tobenstop(){ - toben.stop(); - PlayerFrame = 0; - player.setRegion(regions[PlayerZeile][PlayerFrame]);} - public void tlinksstop(){ - tlinks.stop(); - PlayerFrame = 0; - player.setRegion(regions[PlayerZeile][PlayerFrame]); - player.flip(true, false);} - public void trechtsstop(){ - trechts.stop(); - PlayerFrame = 0; - player.setRegion(regions[PlayerZeile][PlayerFrame]);} - - }