Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Inventory, how to make cells 'bigger'.  (Read 735 times)
0 Members and 1 Guest are viewing this topic.
Offline roseslayer

Junior Member


Medals: 1



« Posted 2013-12-09 15:26:29 »

Hi there JGO,

currently I am working on the Inventory. I had an idea to make some items bigger then 1 cell:



But if you can see it is only rendering a bit of the item. I had some ideas to make a few variables, and then just try things out. But it doesn't seem to work that good. The only part that was good is the selection of multiple Cells:

1  
2  
3  
4  
5  
6  
7  
8  
9  
   public List<Integer> biggerCell() {
      List<Integer> cells = new ArrayList<>();
      for(int x = 0 ; x < item[0].getWidth(); x++){
         for(int y = 0 ; y < item[0].getHeight(); y++){
            cells.add(this.x + x + (this.y + y) * maxWidth);
         }
      }
      return cells;
   }


So my question is: Are there any tutorials on how to make cells that are 'bigger' than 1 cell?
Or if you have any ideas, just post them and I will do something with it! (Please do not post any codes, I am still learning and it is not learning if I am copying stuff).

Thanks already!
-RoseSlayer

Fundamentum W.I.P.
Offline trollwarrior1
« Reply #1 - Posted 2013-12-09 15:30:16 »

So basically you want to make some "cells" bigger than the rest? I kinda don't really understand what you want to achieve. You want to keep some cells at size x, and make some others of size 2x ?
Offline roseslayer

Junior Member


Medals: 1



« Reply #2 - Posted 2013-12-09 15:41:18 »

So basically you want to make some "cells" bigger than the rest? I kinda don't really understand what you want to achieve. You want to keep some cells at size x, and make some others of size 2x ?

I don't want to make the cells bigger, but the items in the cell are bigger then the cell, so it needs to look like the cells has become bigger example:



As you can see here, some items are bigger then 1 cell.

-RoseSlayer

Fundamentum W.I.P.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Varkas
« Reply #3 - Posted 2013-12-09 15:46:51 »

I'm not entirely sure about your code, but in my RPG attempts the items have a "inventory size" in cells. They can cover e.g. 1x1, 2x1 or 2x6 or whatever amount of cells.

Your code must take care of the item size, and display the items correctly in/over the inventory grid.

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Offline Damocles
« Reply #4 - Posted 2013-12-09 16:00:25 »

First a bit of abstractcion:

-you have a collection of Items,
-these Items have different "sizes"
-you have an Invetory with a dimension (grids)
-each item has a position in this grid.

I would first define for each item-class what size it is (1x1,1x2,2x2 etc)

the inventory should have:
-a list of items it contains
-a grid (2-dimensional int matrix)
now when dropping the stuff into the inventory GRID, you give each item a position,
best is to use the upper left corner as the "ancor".

when dropping an item into the inventory:
-> search trough the inventory-grid if there is for example a 2x2 space free,
-if yes, position the item there,
-let the inventory-list remember the ancor x,y position and item id,
-mark in the grid the used 2x2 space also with the item-id.

--

the item-ids on the Grid also are useful to check wich item is beeing clicked by the mouse-click ...

--

when removing the item,
remove it from the list, and empty the grid (put a 0 there for example)

--
also offer a function to "sort" the inventory (removing all items, then adding fist the large, then the smaller items)
I hated that about Diablo, that it was missing such a function.

--
for then rendering:
when displaying the items, you just need to go though the list of items and start rendering at the ancor position (top left)


Thats how I would approch it



Offline roseslayer

Junior Member


Medals: 1



« Reply #5 - Posted 2013-12-09 16:24:23 »

Thanks, going to work on it!
-RoseSlayer

Fundamentum W.I.P.
Offline roseslayer

Junior Member


Medals: 1



« Reply #6 - Posted 2013-12-09 21:59:33 »

Thanks for the help, as always!

This is the finished product:



-RoseSlayer

Fundamentum W.I.P.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #7 - Posted 2013-12-10 02:33:06 »

+1 For working it out yourself Wink

Offline StumpyStrust
« Reply #8 - Posted 2013-12-10 02:46:49 »

Just an idea. Do not remove the horizontal line for the 1x2. I think it looks better by keeping the lines. More consistent.

Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #9 - Posted 2013-12-10 02:50:44 »

I personally think it would look very weird with the line still there because it just doesn't fit in the spot. The other thing you could do is create a miniature version of the texture and just use that instead. I think that would work better mechanics wise.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline roseslayer

Junior Member


Medals: 1



« Reply #10 - Posted 2013-12-10 15:44:40 »

I personally think it would look very weird with the line still there because it just doesn't fit in the spot. The other thing you could do is create a miniature version of the texture and just use that instead. I think that would work better mechanics wise.

What do you mean with the miniature version, the items that you can see in the inventory are already size *2
& thank you for the +1  Cool

-RoseSlayer

Fundamentum W.I.P.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #11 - Posted 2013-12-10 20:36:59 »

I meant reduce the textures down so that they fit in a single inventory slot. It just looks odd when your items span multiple slots, but that's just my opinion!

Offline ags1

JGO Knight


Medals: 29
Projects: 2
Exp: 5 years


Make code not war!


« Reply #12 - Posted 2013-12-10 21:39:23 »

I think the idea is larger items use more slots - so a little bag of coins takes one slot, but a double-handed broadsword might take three.

It's a very old way of representing the weight/bulk of items - I recall seeing it as far back as the original UFO games in 1994. It's probably older.

Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #13 - Posted 2013-12-10 23:27:28 »

Yeah, that is actually an interesting way of dealing with limitations on the inventory size, it just really makes me crazy because its not all uniform! I feel like I have to fix it and make everything the same size Tongue

Offline CodeHead

JGO Coder


Medals: 35


From rags to riches...to rags.


« Reply #14 - Posted 2013-12-10 23:30:31 »

Yeah, that is actually an interesting way of dealing with limitations on the inventory size, it just really makes me crazy because its not all uniform! I feel like I have to fix it and make everything the same size Tongue

If you look at it as an arbitrary choice, then equal size items make sense. If you look at it as a form of resource (space) management, it adds an extra level of strategy/complexity to a game.

Arthur: Are all men from the future loud-mouthed braggarts?
Ash: Nope. Just me baby...Just me.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #15 - Posted 2013-12-10 23:53:18 »

Oh, don't get me wrong I like the idea of it to limit the number of items you can carry, its just I like things because uniform sizes!

Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (55 views)
2014-04-15 18:08:23

BurntPizza (53 views)
2014-04-15 03:46:01

UprightPath (66 views)
2014-04-14 17:39:50

UprightPath (49 views)
2014-04-14 17:35:47

Porlus (66 views)
2014-04-14 15:48:38

tom_mai78101 (90 views)
2014-04-10 04:04:31

BurntPizza (151 views)
2014-04-08 23:06:04

tom_mai78101 (246 views)
2014-04-05 13:34:39

trollwarrior1 (204 views)
2014-04-04 12:06:45

CJLetsGame (211 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!