Building a level from a table

I'm toying with the idea of building levels from tables instead of the traditional way.

BUT... I'm uncertain WHERE to build the level in the scene. Since scenes don't have behaviors, do you need to create a build actor and have it do all the work?

In programming, I'd just do a loop of some sort and cycle through all of the table. But how do you make sure you go through all entries in the table?

Do you literally test for each one?

Would you make it a timer.... run after .001 seconds?

Any tutorials on how to do this?

Thanks!

Comments

  • TosanuTosanu Member, PRO Posts: 388

    I did this myself, so although I do not have a tutorial, I can at least try to describe it.

    I started by making a LevelMaker actor. This is the only actor i manually place on the field, and I have it spawn the hero as well.

    What I did was first mark off all the column pairs (or more if the items have other variable features), and then created a series of game level attributes, calling them AttributeCounters 1, 2 and so on.

    I tied these to the X coordinate columns of each item. Then i create a Row Tracker attribute and set it to one. At the start o the item it sets all the Attributes to their column and the Row Tracker Row. I then created a loop that every .02 seconds, it checks across all the Attributes to see if they equal zero. If they dont, it then sets up a spawn behavior at Attribute,(Table, Attribute row, column).

    And then it adds one to the Row Tracker, reassigns all the AttributeCounters, and starts over until it reaches the last row (which i put as a condition in the rules so that the timer shuts off when done.)

    Note that this is a bit fiddly. Because you cannot dynamically set tables, you will have to unlock each instance of the Maker and change over all the table calls to each level's table. And unless you know exactly how many different types of actor you will be spawning and set up the tables exactly to that many (you dont have to use each in each level, of course), you will be finetuning your spawning behaviors as well in each instance.

    I like how it functions, myself, though. It allows me to build my levels in excel and then manually input the information.

    Sorry, Its a bit of a tall set of behaviors so getting screenshots would be tricky. I hope this was clear enough

  • ookami007ookami007 Member Posts: 581

    Thanks for the help! I managed to create a working prototype by creating something similar.

    A couple of questions...

    1) Do you find it creates a performance hit with so many actors - 1 per "tile"?

    2) To prevent the problem of opening up each spawner and changing the table, could you use a SINGLE table, but LOAD the values into the table?

  • TosanuTosanu Member, PRO Posts: 388
    1. I use wide variety of actors for my geometry, 1x1, 1x2, 1x3 and so on platforms. This not only cuts down on the total number, since they are being built in parallels it speeds up the finishing of the spawning.

    2. Now thats an interesting idea. The only problem is I have yet to find a way to make tables modular. If i understand you right, the idea is to have a base table called Active Level, which is open and blank, and then at the start of the actor have a Copy Table attribute? In my own experience you cannot mark tables in any way using other attributes (table number Integer for example) but if you set it up that way, it would at least mean you would only need to change ONE attribute per instance of the actor since the only behavior youd have to change is the Copy Table one.

  • imjustmikeimjustmike Member Posts: 450

    I've used tables to create much simpler scenes where the scenes are essentially the same but with actors in different locations. I used the table to store the x and y location of the actors for each level.

    I create two integer attributes called game.load and game.level and within each actor I create a rule that says when game.load is 1, change self.x and change self.y to the table location. I use game.level to determine which row of the table. You could also change the table, or the column using this technique.

    You have to have all the actors already on the scene for this to work, but for simple games like puzzlers and basic platformer this works a treat. I believer tshirtbooth has a demo on this somewhere too.

  • ookami007ookami007 Member Posts: 581

    So, instead of using a tile system, you have an id for the "block" and then coordinates or it to be placed?

Sign In or Register to comment.