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?