The Daily Click ::. Forums ::. Klik Coding Help ::. Will I have problems with a large frame and many backdrops?
 

Post Reply  Post Oekaki 
 

Posted By Message

Perfeks



Registered
  24/07/2008
Points
  315
22nd February, 2014 at 22/02/2014 14:34:40 -

Hello,

I'm planing on making a large procedurally generated city (from top view) and it will be in a frame of like 20000x20000 pixels, but filled with squares of 20x20. The thing is that to generate it, I will use 3 layers : ground, low obstacles(crates), high obstacles (walls). So, to generate it at the beginning, I will use 3 active objects (of 20x20) that will run through all possible coordinates, play a specific animation depending on a value in an array and then use "animation>add backdrop". This means that I could have like 3*20000*20000=1'200'000'000 backdrops. I will manage to use active objects only within the scrolling (maybe destroying those that are out and somehow save them in an array).

The question is, will I encounter some problems? Can MMF2 handle it?

Edited by Perfeks

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
23rd February, 2014 at 23/02/2014 18:12:56 -

Yes, you will have problems, the way you're trying to do it.
Even though your numbers don't add up (a 20000 x 20000 pixel map, from 3 layers of 20 x 20 pixel tiles is "only" 3 million tiles) - that's still far too many to be loaded all at once.
Basically, you just need to come up with a system where only part of that larger map is loaded at one time. There are lots of different ways you could go about that - eg. http://www.sketchy.co.nf/downloads/VirtualScrolling.mfa

 
n/a

Perfeks



Registered
  24/07/2008
Points
  315
23rd February, 2014 at 23/02/2014 22:53:38 -

Thank you for your answer! Oh yes, what poor calculations that was, shame on me that is supposed to be an engineer ^^"

I can't open open your example, because I'm missing the forEach extension and I somehow can't find it anywhere (all the links seem dead). I didn't even know it existed, I still do this by using regular loops and flags.

But I assume your solution is loading the city frame by frame once you reach a border (a scrolling like the old Zeldas)? Or maybe loading all the squares at a reasonable range in such a way that you can never reach the part that is currently loading if you walk straight to it?

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th February, 2014 at 24/02/2014 01:07:41 -

It sounds like you already have a pretty good idea of what you're doing.
Zelda-type scrolling is one option (the simplest), but you'd probably rather the scrolling appears seamless to the player.

I've edited the example to use a fastloop instead of the ForEach object (it wasn't important to this example) - http://1drv.ms/MmCGt6 (read the comments for instructions)

 
n/a

Perfeks



Registered
  24/07/2008
Points
  315
24th February, 2014 at 24/02/2014 19:39:57 -

Did you really make this only for me? That's very kind and well made

So, I was able to open it this time, but I see that the tiles are active objects? Does that mean you suggest using a bunch of active objects to display the current background? Because in my case, I would need around 300 of theses (the screen covers 20x16 squares) and I can't afford it. The game can already go to like 400 active objects (even when limiting particles effects).

Or do you suggest pasting new backdrops over each others to "refresh" the frame like you're doing with active objects? But in that case, the number of backdrops would increase everytime the player moves and if he explores too much of the map, it might reach high numbers! (If I assume there's no way to remove the backdrops that are under the new ones?)

Now that I read me again, maybe I was not very clear. I wanted to paste a single active object (per layer) as backdrop to all positions, using different animations depending on a value in an array (it acts as a "brush" that "paints" the whole map), and destroying it afterwards when I don't need it anymore. And when I said "I will manage to use active objects only within the scrolling", I meant for the game itself, it has nothing to do with the background (because actually, zombies are supposed to swarm in the city and I won't use them when they're out of the scrolling)

After further reflexion, I wouldn't need a map larger than around 250x250 squares. The maximum size of a building is like 25x25 squares, so that would make a city of like 8x8 buildings (assuming they're separated by possible roads), which is actually enough I guess. In addition, there's no need to count 3 layers, because there's actually never a case where layer2 and 3 are non-empty : there's never a wall at the same place of a car for example (they're 2 different layers, because layer 2 is obstacle for ground path only, whereas layer 3 also stops bullets). Uhm so, if I'm not mistaken this time, my number of backdrops is between 250*250=62'500 (there's ground texture everywhere but no 2nd/3rd layer) and 250*250*2=125'000 (every square has an obstacle), which is far less than my previous 3 million.

To have a certain security, can MMF2 handle 200'000 backdrops? Is loading them all at the beginning of the frame better as loading them frame by frame while moving? Do backdrops created during runtime get destroyed once they're too far, or do they simply aren't taken into account (not slowing the game), meaning I could have as many backdrops as long as they're far from the scrolling? I just want to make sure it doesn't slow (too much) the game, because if this is the case, I'll switch to a different gameplay without realtime roaming (something like : you're allowed to be only around a single building during a zombie wave and will be able to switch to another one after the wave, which will be a whole new isolated frame)

Anyway, thank you very much for taking your time to help me, I will show a feedback once I get this working

Edited by Perfeks

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
24th February, 2014 at 24/02/2014 22:22:47 -

No, I didn't make it just for you - I made it ages ago, and then just changed two lines so you could open it without the ForEach object.

Yes, it uses actives for every tile, but that's not a problem, even with 960 of them (a single 32x30 layer is 960 tiles, and that didn't cause any slowdown on my old netbook). MMF2 allows up to 10,000 objects, and with hardware acceleration (ie. display mode set to "Direct3d 9") you shouldn't experience any slowdown.
If you're targeting one of the other exporters (Android / iOS / etc) you can pretty much forget the whole idea - those kind of devices don't have the performance.

I understand what you're saying about pasting objects into the background, but I don't think it's viable on very large maps - although the size you're talking about now doesn't sound too bad (probably worth a shot, since it makes the coding a lot easier).
If you paste objects into the background, they disappear completely when you scroll (or at least they did - think that may have changed in HWA). If you add them as backdrops, they don't disappear.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click