Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Square Map Item System.

Author
Message
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 3rd Jul 2008 20:24 Edited at: 3rd Jul 2008 20:28
Hi ,

I am working in Eye of the Beholder 4 and I have one problem.
In fact , I tried to solve this problem with other way.

As all you know the Game Eye of the Beholder , I want to create one routine which , I have one map , 32x32 let's say I have one array:

Dim Level01(32,32) , 32x32 are my horizontal and vertical squares of my big empty map.

In fact , I have one dimension with variable name Level01(32,32,4) three dimesional array.
This means , I have one level with horizontal size by 32 square , vertical size by 32 and I have one more dimension with 4 , this means the direction of wall (north , east , south , west)

This is so far correct for now and working.

Now , I have one other Dimension array with name:

Dim Floor_items01(32,32,4) this array is the same as the above.

But there is a little bit difference. Each square stores one item
but the third dimension means , this Item , faces in four sub squares. (Each main square stores 4 items in 4 sub-squares).

The image shows what I try to mean.
-----------

-----------

Now , I try to make this Idea , I want to put infinity items in each sub-square , this stored in the main square.

I thing you understood what I try to explain.

I use one classic method , to create one huge array to store my items with this kind of dimension like :

Floor_Items(map_x,map_y,subsquare,max_items)

With this way , I need to pre-allocate whole this memory and program will not run if I create many Floor_Item arrays.

Floor_Items01(map_x,map_y,subsquare,max_items)
Floor_Items02(map_x,map_y,subsquare,max_items)
Floor_Items03(map_x,map_y,subsquare,max_items)
Floor_Items04(map_x,map_y,subsquare,max_items)
Floor_Items05(map_x,map_y,subsquare,max_items)

I eat huge amounts of memory to make nothing , or make the same thing for all of my 100 levels oooops....

If I want to put on one sub-square one key
and on this key , I will through one more item on the key , I drop one helmet in the same sub-square , and then , I drop one healing potion in the same sub-square so I have these items in this sub-square.

1)Key
2)Helmet
3)Healing potion

If I want to pickup the Helmet which is second in the order of this sub-square the new list will be like this:

1)Key
2)Empty
3)Healing potion

But the second position of this sub-square needs to be deleted and resorted , so the new order will be.

1)Key
2)Healing potion.

So if I want to put too many items in a big map , with too many main squares , with 4 sub-squares in each main-square , with to many levels , then it will be a huge chaos to control all of this mess.



Could you have one Idea how to create one smart code that , can I put a lots of Items (Infinity and each sub-square which contains each main square on my level).

Thank you vey much..

http://i-access.gr/future/Banner.jpg
You are an elite hacker and try to save the cyberspace.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 4th Jul 2008 00:03
looking at what you are doing in the picture had me thinking, how many item object do you think you might end up with.

so say you have 10 items this would be dim items(10) now how many floors do you think you will have say 15, so now it would be dim items(10,15), so now all you need, 1 for in room, 0 for not. plus if you have say 24 room on each floor, you would then get dim items(10,17,24).

upto you if follow/use the above.

Dark Physics makes any hot drink go cold.
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 4th Jul 2008 02:10
In each sub-square in fact I will have unlimited objects
All of my levels will be up to 99.

Each main square of 32x32 has 4 sub-squares with unlimited or large amount of objects , for example 100.

So each main square with 4 sub-squares will have 4x100=400 objects
if the max sub-objects per main square are 100.

99 levels , with 32x32 main squares , with 4 sub-squares each of 100 items capacity.



http://i-access.gr/future/Banner.jpg
You are an elite hacker and try to save the cyberspace.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jul 2008 02:34
What you need is a linked list of items.

I'm not going to try and explain how a linked list works - I haven't got the time to do that. I suggest that you google for examples (maybe look it up in wikipedia) and learn how a linked list works, then take a look at the example code I'm giving you.

The following code was an example I put together for someone who was writing a turn-based war/strategy game, where each cell needed to allow any number of units to be placed upon it - it will be trivial to modify it to do what you need:


HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 4th Jul 2008 11:48
Takis76

forgot to say with my idea that you could have one more variable on the end and this look after where the object is in the room.

take
items(items,levels,main_squares,cords)

`so items=1000
`level =78
`sub_squares = 54
if cords 0 has a 1 = item in room
`cords 1 has = xpos
`cords 2 has = ypos
`cords 3 has = ypos
`in code this could be

if item(78,21,54,1,0)=1
x#=item(78,21,54,1,1)
y#=item(78,21,54,1,2)
z#=item(78,21,54,1,3)
endif

just saying you could do it this way, up to you. Plus there's the binary way of doing this.

Dark Physics makes any hot drink go cold.

Login to post a reply

Server time is: 2024-11-25 01:34:34
Your offset time is: 2024-11-25 01:34:34