faiwfioaeshgioewhj

master
GammelJan 6 years ago
parent ddf03094bf
commit b0572501a4

@ -430,6 +430,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(Intersector.overlaps(gs.getPlayer().getCollisionSprite(), tempSprites.get(i).getSprite().getBoundingRectangle())){
garbageCollector.add(tempItems.get(i));
tempItems.remove(i);
tempSprites.remove(i);
}
@ -570,7 +571,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.Q){
if(gs != null && gs.getIsLoading() == false){
d.getPlayer().getInv().dropItem();
if(d.getPlayer().getInv().getItem(d.getPlayer().getInv().getSelected()) != null){
d.getCurrentRoom().spawnItem((int)d.getPlayer().getxPos(), (int)d.getPlayer().getyPos(), d.getPlayer().getInv().getItem(d.getPlayer().getInv().getSelected()));
gs.getM().getMaps()[level][roomPosX][roomPosY].addItem(48, 48,(int)d.getPlayer().getxPos(), (int)d.getPlayer().getyPos(), d.getPlayer().getInv().getItem(d.getPlayer().getInv().getSelected()));
d.getPlayer().getInv().dropItem();
}
}
}
if(keycode == Input.Keys.ESCAPE){

@ -28,8 +28,8 @@ public class Room {
enemy.setyPos(yPos);
}
public void spawnItem(int xPos, int yPos){
// TODO: Zu Implementieren
public void spawnItem(int xPos, int yPos, Item i){
items.add(new ItemContainer(xPos, yPos, i));
}
/**

@ -54,6 +54,10 @@ public class AnimatedObject {
this.sprite = sprite;
}
public void setSpritePosition(int xPos, int yPos){
sprite.setPosition(xPos, yPos);
}
/**
* @return the texture
*/

@ -5,7 +5,9 @@
*/
package com.dungeoncrawler.view;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.dungeoncrawler.model.Item;
import java.util.ArrayList;
/**
@ -25,6 +27,28 @@ public class MapContainer {
this.enemies = new EntitySprite[15];
}
public void addItem(int width, int height, int xPos, int yPos, Item i){
switch(i.getId()){
case 0: // key
AnimatedObject ao1 = new AnimatedObject(new Texture("sprites/key.png"), width, height);
mapItems.add(ao1);
ao1.setSpritePosition(xPos, yPos);
break;
case 1: // potion
AnimatedObject ao2 = new AnimatedObject(new Texture("sprites/potion.png"), width, height);
mapItems.add(ao2);
ao2.setSpritePosition(xPos, yPos);
break;
case 2: // amulet
AnimatedObject ao3 = new AnimatedObject(new Texture("sprites/amulet.png"), width, height);
mapItems.add(ao3);
ao3.setSpritePosition(xPos, yPos);
break;
}
}
/**
* @return the map
*/
@ -60,6 +84,7 @@ public class MapContainer {
return mapItems;
}
/**
* @param mapItems the mapItems to set
*/

Loading…
Cancel
Save