master
GammelJAN 6 years ago
parent 1583e6c1ec
commit 4998a2ef24

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 813 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

@ -27,7 +27,7 @@ import com.dungeoncrawler.model.Item;
import com.dungeoncrawler.model.ItemContainer; import com.dungeoncrawler.model.ItemContainer;
import com.dungeoncrawler.model.items.Key; import com.dungeoncrawler.model.items.Key;
import com.dungeoncrawler.model.items.Potion; import com.dungeoncrawler.model.items.Potion;
import com.dungeoncrawler.model.items.Sword; import com.dungeoncrawler.model.items.Amulet;
import java.util.ArrayList; import java.util.ArrayList;
public class Controller extends ApplicationAdapter implements InputProcessor{ public class Controller extends ApplicationAdapter implements InputProcessor{
@ -65,7 +65,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
@Override @Override
public void create(){ public void create(){
volume = 0.01f; volume = 0.01f;
arrows = new Entity[10]; arrows = new Entity[10];
@ -142,7 +141,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
// Render methode zum rendern der einzelnen Sprites wird aufgerufen // Render methode zum rendern der einzelnen Sprites wird aufgerufen
m.render(batch, d.getPlayer(), d.getCurrentEntities(), arrows, tileX, tileY, level, roomPosX, roomPosY); m.render(batch, d.getPlayer(), d.getCurrentEntities(), arrows, tileX, tileY, level, roomPosX, roomPosY);
hc.updateInventory(batch, d.getPlayer()); hc.updateHud(batch, d.getPlayer());
d.getPlayer().updateItems();
} }
} }
} }
@ -382,6 +382,12 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
m.music.setVolume(volume); m.music.setVolume(volume);
} }
} }
if(keycode == Input.Keys.Q){
if(m != null && m.getIsLoading() == false){
d.getPlayer().getInv().dropItem();
}
}
return true; return true;
} }

@ -6,7 +6,7 @@
package com.dungeoncrawler.model; package com.dungeoncrawler.model;
import com.dungeoncrawler.model.entities.*; import com.dungeoncrawler.model.entities.*;
import com.dungeoncrawler.model.items.Sword; import com.dungeoncrawler.model.items.Amulet;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -206,7 +206,7 @@ public class DungeonGenerator {
int id = (int) (Math.random() * 2); int id = (int) (Math.random() * 2);
switch(id){ switch(id){
case 0: case 0:
tempItem = new Sword(lvl); tempItem = new Amulet(lvl);
break; break;
/*case 1: /*case 1:

@ -58,8 +58,8 @@ public class Inventory {
selected += i; selected += i;
} }
public void dropItem(int x){ public void dropItem(){
items[x] = null; items[selected] = null;
} }

@ -23,6 +23,12 @@ public abstract class Item {
public int getId(){ public int getId(){
return this.id; return this.id;
} }
public int getDmg(){
return dmg;
}
public int getHeal(){
return heal;
}
/** /**
* @return the amount * @return the amount
*/ */

@ -28,6 +28,7 @@ public class ItemContainer {
/** /**
* @param xPos the xPos to set * @param xPos the xPos to set
*
*/ */
public void setxPos(int xPos) { public void setxPos(int xPos) {
this.xPos = xPos; this.xPos = xPos;

@ -16,16 +16,22 @@ import com.dungeoncrawler.model.ItemContainer;
*/ */
public class Player extends Entity { public class Player extends Entity {
int standartDmg;
int standartMaxHp;
public Player() { public Player() {
super(200, 200, 1); super(200, 200, 1);
this.maxhp = 5*lvl; this.maxhp = 5 * lvl;
this.hp = this.maxhp; this.hp = this.maxhp;
standartMaxHp = this.maxhp;
this.dmg = 3*lvl; this.dmg = 3*lvl;
standartDmg = this.dmg;
id = -1; id = -1;
inv = new Inventory(3,2); inv = new Inventory(3,2);
// TODO: Sinnvolle Werte finden // TODO: Sinnvolle Werte finden
} }
public void pickUp(Item item){ public void pickUp(Item item){
@ -34,5 +40,15 @@ public class Player extends Entity {
public Inventory getInv(){ public Inventory getInv(){
return inv; return inv;
} }
public void updateItems(){
if(inv.getItem(1) != null){
dmg = standartDmg + inv.getItem(1).getDmg();
maxhp = standartMaxHp + inv.getItem(1).getHeal();
}
else{
dmg = standartDmg;
maxhp = standartMaxHp;
}
}
} }

@ -11,11 +11,12 @@ import com.dungeoncrawler.model.Item;
* *
* @author jonathan * @author jonathan
*/ */
public class Sword extends Item { public class Amulet extends Item {
public Sword(int lvl) { public Amulet(int lvl) {
super(lvl); super(lvl);
this.dmg = lvl * 4; this.dmg = lvl * 4;
this.heal = lvl * 4;
this.id = 2; this.id = 2;
} }

@ -172,7 +172,7 @@ public class GameScreen {
roomChangeRow++; roomChangeRow++;
} }
} }
},0, 0.02f); },0, 0.01f);
} }
@ -226,7 +226,7 @@ public class GameScreen {
tmr.setView(camera); tmr.setView(camera);
tmr.render(); tmr.render();
camera.zoom = 700f; camera.zoom = 700f; // Standart 700f
camera.update(); camera.update();
batch.setProjectionMatrix(camera.combined); batch.setProjectionMatrix(camera.combined);

@ -8,6 +8,7 @@ package com.dungeoncrawler.view;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.dungeoncrawler.model.Item; import com.dungeoncrawler.model.Item;
import com.dungeoncrawler.model.entities.Player; import com.dungeoncrawler.model.entities.Player;
@ -26,7 +27,12 @@ public class HudContainer {
Texture selectedTexture; Texture selectedTexture;
Sprite selectedSprite; Sprite selectedSprite;
Texture playerHealthTexture;
Sprite playerHealthSprite;
public HudContainer(){ public HudContainer(){
playerHealthTexture = new Texture("sprites/playerHealthBar.png");
playerHealthSprite = new Sprite();
selectedTexture = new Texture("sprites/selected.png"); selectedTexture = new Texture("sprites/selected.png");
selectedSprite = new Sprite(selectedTexture); selectedSprite = new Sprite(selectedTexture);
HudTexture = new Texture("sprites/hud.png"); HudTexture = new Texture("sprites/hud.png");
@ -62,10 +68,9 @@ public class HudContainer {
selected = 2; selected = 2;
selectedSprite.setX(invXPos[selected] - 2f); selectedSprite.setX(invXPos[selected] - 2f);
selectedSprite.setY(invYPos[selected] - 2f); selectedSprite.setY(invYPos[selected] - 2f);
} }
public void updateInventory(SpriteBatch batch, Player p){ public void updateHud(SpriteBatch batch, Player p){
InventoryItemSprites = new Sprite[8]; InventoryItemSprites = new Sprite[8];
Item[] items = p.getInv().getItem(); Item[] items = p.getInv().getItem();
@ -77,6 +82,15 @@ public class HudContainer {
} }
selectedSprite.setX(invXPos[selected] - 2f); selectedSprite.setX(invXPos[selected] - 2f);
selectedSprite.setY(invYPos[selected] - 2f); selectedSprite.setY(invYPos[selected] - 2f);
p.setHp(3);
float n = p.getHp() / p.getMaxhp();
int newWidth = (int) (n * 122);
TextureRegion[][] playerHealthRegion = TextureRegion.split(playerHealthTexture,newWidth, playerHealthTexture.getHeight());
playerHealthSprite = new Sprite(playerHealthRegion[0][0]);
playerHealthSprite.setPosition(200f, 200f);
batch.begin(); batch.begin();
HudSprite.draw(batch); HudSprite.draw(batch);
for(int i = 0; i < InventoryItemSprites.length ;i++){ for(int i = 0; i < InventoryItemSprites.length ;i++){
@ -85,8 +99,10 @@ public class HudContainer {
} }
} }
selectedSprite.draw(batch); selectedSprite.draw(batch);
playerHealthSprite.draw(batch);
batch.end(); batch.end();
} }
public void addItem(Item item, int x){ public void addItem(Item item, int x){

@ -58,10 +58,10 @@ public class MainMenu{
backgroundSprite.setY(0); backgroundSprite.setY(0);
camera = new OrthographicCamera(1, h/w); //camera = new OrthographicCamera(1, h/w);
camera.translate(backgroundSprite.getWidth()/2, backgroundSprite.getHeight()/2); //camera.translate(backgroundSprite.getWidth()/2, backgroundSprite.getHeight()/2);
camera.zoom = 1150f; //camera.zoom = 1150f;
camera.update(); //camera.update();
Pixmap pm = new Pixmap(Gdx.files.internal("sprites/cursor.png")); Pixmap pm = new Pixmap(Gdx.files.internal("sprites/cursor.png"));
Gdx.graphics.setCursor(Gdx.graphics.newCursor(pm, 0, 0)); Gdx.graphics.setCursor(Gdx.graphics.newCursor(pm, 0, 0));
@ -86,7 +86,7 @@ public class MainMenu{
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin(); batch.begin();
batch.setProjectionMatrix(camera.combined); //batch.setProjectionMatrix(camera.combined);
backgroundSprite.draw(batch); backgroundSprite.draw(batch);
startButtonSprite.draw(batch); startButtonSprite.draw(batch);
quitButtonSprite.draw(batch); quitButtonSprite.draw(batch);

@ -312,7 +312,7 @@ public class MapGenerator {
Item item = container.getItem(); Item item = container.getItem();
if(item.getId() == 2){ if(item.getId() == 2){
AnimatedObject swordSprite = new AnimatedObject(sword, 24, 24); AnimatedObject swordSprite = new AnimatedObject(sword, 48, 48);
swordSprite.getSprite().setPosition(container.getxPos(), container.getyPos()); swordSprite.getSprite().setPosition(container.getxPos(), container.getyPos());
temp.getMapItems().add(swordSprite); temp.getMapItems().add(swordSprite);
} }

Loading…
Cancel
Save