From 965c815f1f587d33cd633f157a8fdd43c43c10f5 Mon Sep 17 00:00:00 2001 From: GammelJan Date: Tue, 31 Mar 2020 23:08:29 +0200 Subject: [PATCH] Inventory Grundmethoden --- core/src/com/dungeoncrawler/Inventory.java | 37 +++++++++++++++++++ .../src/com/dungeoncrawler/ItemContainer.java | 6 +-- 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 core/src/com/dungeoncrawler/Inventory.java diff --git a/core/src/com/dungeoncrawler/Inventory.java b/core/src/com/dungeoncrawler/Inventory.java new file mode 100644 index 0000000..ba6ebc3 --- /dev/null +++ b/core/src/com/dungeoncrawler/Inventory.java @@ -0,0 +1,37 @@ +package com.dungeoncrawler; + + +public class Inventory { + + Item items[][]; + + + Inventory(int width, int height){ + items = new Item[width][height]; + } + + public void addItem(Item i) + { + + for(int n = 0; n <= items.length; n++){ + for(int m = 0; m <= items[0].length; m++){ + if(items[n][m] == null){ + items[n][m] = i; + n = items.length + 1; + break; + } + } + } + } + + public void dropItem(int x, int y){ + items[x][y] = null; + } + + + public Item getItem(int x, int y){ + return items[x][y]; + } + + +} diff --git a/core/src/com/dungeoncrawler/ItemContainer.java b/core/src/com/dungeoncrawler/ItemContainer.java index 7c4eb10..32f475e 100644 --- a/core/src/com/dungeoncrawler/ItemContainer.java +++ b/core/src/com/dungeoncrawler/ItemContainer.java @@ -1,12 +1,12 @@ -/* + /* * 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; -import com.dungeoncrawler.items.*; - +//import com.dungeoncrawler.items.*; +class Item{} /** * * @author jonathan