Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 17,416 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Can entities be stored in arrays? #205233
05/05/08 10:25
05/05/08 10:25
Joined: Jul 2007
Posts: 24
N
noobie86 Offline OP
Newbie
noobie86  Offline OP
Newbie
N

Joined: Jul 2007
Posts: 24
Hi i'm trying to make a 2D/2.5D game with Gamestudio. Here's the scenario:

i have a board with 49 tiles/nodes. There are 8 types of entities in the game. At the start, all the 49 tiles are filled with any of these 8 entities, created randomly. Whenever i select any entity with the mouse, the surrounding entities need to be checked for a particular characteristic, say color. The number of entities to be checked vary from minimum 4 to maximum 12.

Presently how i'm doing this is: i have 49 entity pointers, each pointing to an entity on the board.

eg ball5= ent_create(ball_red,ball_pos5,ball);

Next, i have 12 pointers for the case where maximum 12 need to be checked. An entity's skill11 and skill12 are set to 2 numbers, one for its node number and one indicating its color or type. When i select, say ball5, i need to check ball6, ball7, ball12 (5+7) and a lot more. The algorithm i'm using is

if(ball5 is selected) {store pointers ptr1=ball6, ptr2=ball7, ptr3=ball12 and so on for the 12 pointers}

The problem is, if this method is used, this line needs to coded for all 49 balls. 49 is ok but when the board is expanded to bigger sizes, the program length increases exponentially. Rather if i could store the entities in arrays, i could write

if (ball[n] is selected) {store pointers ptr1=ball[n+1], ptr2=ball[n+2], ptr3=ball[n+7] and so on}

This would make the program more efficient and simpler. Can entites be somehow stored in arrays?

Re: Can entities be stored in arrays? [Re: noobie86] #205237
05/05/08 10:35
05/05/08 10:35
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
you may try linked lists, or arrays aswell.

You can mostly treat entites as normal structs you can store them in arrays.
You can use 2D arrays. like
ENTITY* ball[50][50]

if ball[x][y] is selected

ball[x-1][y], ball[x-1][y-1],ball[x-1][y+1] .... etc will stand for surrounding balls, if you fill array this way. You can also try linked lists with your balls but this will be more comlicated, if your board wont change it's size during runtime i suggest usin 2d arrays.


3333333333
Re: Can entities be stored in arrays? [Re: Quad] #205240
05/05/08 10:53
05/05/08 10:53
Joined: Jul 2007
Posts: 24
N
noobie86 Offline OP
Newbie
noobie86  Offline OP
Newbie
N

Joined: Jul 2007
Posts: 24
hi thanks Quadraxas

i tried to use arrays entity* ball[50] and entity* ball[50][50] but both times i get the msg:

error(285) wrong type [50]..


Re: Can entities be stored in arrays? [Re: noobie86] #205248
05/05/08 11:31
05/05/08 11:31
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
Make sure you are using lite-c(your file ext. must be ".c")

and ENTITY is written all capital.


3333333333
Re: Can entities be stored in arrays? [Re: Quad] #205398
05/06/08 12:50
05/06/08 12:50
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
i thought you couldn't have arrays of engine objects.

Re: Can entities be stored in arrays? [Re: Joey] #205404
05/06/08 13:26
05/06/08 13:26

M
mercuryus
Unregistered
mercuryus
Unregistered
M



ENTITY* ball[50][50] are just pointers.
You have to use ball[2][7]=ent_create(....) to create an object.

Re: Can entities be stored in arrays? [Re: ] #205414
05/06/08 14:11
05/06/08 14:11
Joined: Dec 2003
Posts: 1,225
germany
gri Offline
Serious User
gri  Offline
Serious User

Joined: Dec 2003
Posts: 1,225
germany
What about using object-handles?

Why dont you store the entity handles in the array and read them if you need?

,gri


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1