"Chunk System"?
ok, I've asked this question before but never got an answer. so I'm asking again, How can i make a world with 15X15 Pixel blocks as the ground and it go down about 10,000 pixels so i would need ALOT of blocks right? Is there a why to make a "Chunk System" With tables and make it so it only spawns a "Chunk" Big Enough to fit the hole screen and when you get close to another "Chunk" its spawns that "Chunk" and When the other one is not visible it like "Hides" just so the game won't lagg with 1,000+ actors.
Best Answers
-
old_kipper Posts: 1,420
to start with- avoid actors of uneven dimensions as the art will be blurred. Then consider the number of actors you require. If you jump from 15 to 20 (easy to do the math but you can do them what size you like), you would still need either a lot of attributes in a few actors (as long as there are enough to cover the screen width and some spare) or more actors with less attributes. At 20 pixels wide- 10,000 breaks down to 500 block widths. So if you have 50 blocks, each would have to have 10 positional sets of information it would need to store. This could be done with index number attributes that you stepped to remember their state in each position (probably one index for each pos but I suppose you might be able to do something complex like using prime numbers in one index attribute if you wanted to get fancy...). Each actor would also have to have the triggers within it to 'jump' to where they are wanted. This would not be so hard to do as you would reference the hero actor x pos (if the camera was locked to it) and jump when it was getting close to the needed empty slot (and before it came on screen). How you do the destroyed state is down to how you have collisions set up. If the blocks only collide when visible then it would work and you could put the collide for them in a rule that contained the collide and only worked when the alpha was 1. There might be a few problems with this but I haven't set it up and played with it so I am not sure. You would have to experiment.
In one test I've done I spawned all my actors to fill the screen and create a landscape as I could be bothered to place them all. This spawning stepped the placement of the next actor and self numbered it as it did so each actor knew its position and referenced further rules that applied only to those actors in a particular position. It worked, but sometimes instances that are spawned can have problems. Again experiment. All in all it takes some thought and setting up in the rules but can be done. Good luck.
kipper -
old_kipper Posts: 1,420
If you do want to go forward with this I suggest you start with a block moving system just to understand how to shift them in conjunction with the movement of the hero actor.
1). make a wide scene and put a control system in to control the x movement of the hero actor and then add the camera control behaviour to the camera. OPen the scene attributes and narrow the x of the camera control area to 32
2). set up an game integer attribute and constrain that to the hero's x pos (from within the hero actor)
3). set up a 20x20 actor as the blocks that will move. give it an self index attribute and put in a change attribute (outside of a rule) to place the self pos x in the self attribute.
4) then add a rule that says when self pos x = self attribute x and self pos is <hero x-80
change self pos to self attribute +120.
this will then if placed below the hero in the scene change position when it is more than 80 pixels behind the hero. test....
You then have to build up the rules to add to the self pos x at great distances and based on the number of tiles to jump and a reversal set of rules. Once you get this going you are well on the way.
Answers