Hi Everyone,
I have created my own game engine that allows we to scroll through an array tile map levels in fusion. I want to utilize the physic engine for all physics related movements. The level array stores all the date for the entire level (i.e. background walls etc). My engine loads the viewable tiles into my frame and displays them in the background and it works perfectly.
Now I am at the stage where I want to dynamically load enemies and obstacles into my level only when they are viewable. Once an enemy/obstacle leaves the viewable area of the level the enemy's active is destroyed however their information is stored in an array. Thus I can have a ton of enemies in a large world but I only make actives for the ones that the player can see.
My idea to create the dynamic loading of obstacles and enemies is the following:
1) In the level tilemap create a layer for obstacles and enemies. [lets call this the Level Array]
2) Create a seperate list/array of all the obstacles/enemies in the entire level. Each object in the list is indexed and has its respective alterable values stored. [lets call this Active Objects list]
3) Now, for each tile that has an obstacle or enemy in it I store a unique index reference to the Active Object list.
4) When the tile is viewable I look up any actives that should be on the screen and I create them and assign their alterable values from the active object list.
5) While on screen I track the active's position and other values in the Object's alterable values
6) When the actives go off screen I write the actives values back into the Active Object List and update the Level Array reference to the object's new position
7) Once all data is stored in the Active Object List and the Level Array's references are updated I destroy the active object.
Notes: - All objects movements are tracked and updated in the Active Object List (even if they aren't created or on screen).
- Physics engine does not apply to non-created active objects
Question 1: What is the best way to implement the above in mmf2?
Proposed solution: I was thinking of using a list object in conjunction with an Array to make an Active Object list. I would use the list object to sort the array so I can easily add/remove items and determine which are viewable from the list.
Then I just reconstruct the 2D array once all removals and sorts are performed based off the list object. Does this make sense? [seems inefficient in my head]
Question 2: I can have multiple active objects in the same tile. My level array can only store one reference to the active object list per tile. How to adjust for this issue?
Proposed solution: I was thinking that the ID's used in the active object list are listed are index in a way so I can have mutiple objects on the same tile (i.e. tile 2,3 index object would have 2003001, 2003002, 2003003, etc).
My brain is mush at this point but I would appreciate any help or guidance on how to deal with these issues. Thanks!




Reply With Quote