Dealilng with 2D tile map arrays and the game loop

BlitzMax Forums/BlitzMax Beginners Area/Dealilng with 2D tile map arrays and the game loop

allranger(Posted 2013) [#1]
I am working on a game that is a 2D platformer/tower defense/building type game.

Part of what I have read is John Judnich's OOP in BlitzMax and the BlitzMax book for beginners.

I have created different parts for the game and now I an trying to stitch them together and am seeing some of my problems.

I created a game loop and a list of all my entities. The game loop called the update and draw methods for each game type. It seems to be a pretty common thing based off what I see on the forums.

Now here is where I get my problem, separately I created a tile map type, which is basically an array with some other data. Based off the number in the array that is what tile to draw.

Of course I only want to draw the tiles on the screen, so I can add the tile map as a game object, and them put the code to draw only the section on the screen in there.

OR, should I be adding each tile as a game object? If I am just adding each tile as a game object then I will have to be removing tiles from my list that are not on the screen any more. So then the game object list will always be changing, not sure if that is a bad thing or not.

Does anybody have any tips on how they over came this problem?


col(Posted 2013) [#2]
Hiya,

There's a whole ton of different ways to achieve it. Personally, I'd get something working and see how it performs, if its too slow or doesn't fit in with your code, then try another method, or try optimising what you've came up. Optimising is a big enough subject in itself, however if your game doesnt need it, ie its already fast enough that you are satisfied with it, then theres no need to optimise anything.

Trial and error is a great way to learn the goods and bads especially once you have some ideas on how to solve the problem. You already have 2 ideas, both of which are as good as each other, why not try them both and see which works best. And don't be afraid to be get bits wrong the first, second or third time. Even then, once you do solve it you'll often think of a better way to do it, but at that point try to resist from making something that already works better unless you really have to ( ie optimise ONLY when you have to ).

When you have something that works, don't try to fix it ;-)