Map stored as a table..
smurfted
Member, PRO Posts: 586
So I'm making a game that builds the world from a map.
I'm thinking of generating the map in a table so what's shown onscreen is read from the table & rendered on screen.
Has anyone tried this yet?
Comments
Sure, but it depends what you mean by "map." For instance, I've build a first-person maze where the walls are images selected by data from a table "map" if you will.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Excellent. How did it work out?
I thought it worked pretty well. I made it three years ago when I was still pretty new to GameSalad. Note that the graphics got messed up a bit but you get the idea hopefully:
The table for the walls looks like this:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Nice one, it reminds me of those amiga exploration games like Hired Guns..
When I was 12, I was in a summer programming class at UC Berkeley and my partner was this wiz kid who figured out how to randomly generate and display a 3D maze like the one in my GameSalad game using Pascal. I was totally blown away back then. And really, his accomplishment is still much more impressive than anything I've done with GameSalad.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I'm trying something pretty out there with this experiment.
I am trying to read from a table and then render the outcome, re-assigning actors each game cycle. I'm not sure if GS can handle it, but i like pushing the boat out a bit..
First of i need to write a loop that collects all the data from the map (table)..
So i need to look in a table in a grid pattern say playerX-5 to playerX+5 & repeat that over a vertical area of the grid, from playerY-5 to playerY+5.
Recording anything that registers more than 0.
So what would be the most efficient way of doing this do you think?
@smurfted
two main things will affect how you should approach it.
Depending on the above, the right combination of "Loop (with Max loops/frame set)", "tableSearch", and "tableColSum" will give you very good, low overhead, performance.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
if the character is moving we need to be reading the map, and it will be much more likely to find nothing than something...
"tablecolsum" would be to right off checking that column at all i guess, clever..
Okay so i have made a loop that looks across columns close to playerY and its picking up the data from the map.
I know i cant loop loops (unfortunately). But i copied the group with the loop in it and changed which row it looks at manually.
For some reason it only records the info from the first loop?! Any ideas what this could be?
You can't easily loop loops but you can use multiple "checker" actors, one for each row of values. That's essentially what I did with my maze spawner/checker.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
whats that?
well bugger, i thought i had it for a minute, then it failed me again. looking like it gets stuck in the loop..
It works just fine till i turn on the "if it finds something in the cell" bit, then it freezes.
in there there is just a table cell check if there is anything there on the map...
That's the most important part to share.
If it's freezing, it's likely trying to check the value of a table row or column that exceeds the size of your table. Or it's trying to check row zero.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@smurfted
Looking at your loop (until all) conditions, and the way your scanX and scanY increments -
your loop will never fulfill the exit condition since scanX gets reset if it is > 4 before scanY gets incremented.
Therefore scanY will endlessly increase and crash the program when it is out of bounds.
Take the scanX>4 condition out of the loop rule, since you handle that in the code further down.
MESSAGING, X-PLATFORM LEADERBOARDS, OFFLINE-TIMER, ANALYTICS and BACK-END CONTROL for your GameSalad projects
www.APPFORMATIVE.com
I started in the middle of the map so no 0 cell searches can happen. Been there before and that was a crash
@Hopscotch my loop was indeed flawed, i have now pre-calculated the min and max positions as integers. That way i could be precise with the conditions of the loop. It's working a little better now.
I added a limit of 222 to check if the loop was working. It should finish on 81, and now it does..
Now to turn on the table searching again...
so i have refined it and gotten it working, though it does seem to get a bit laggy...