User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Just in theory - deleting out of frame objects

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Just in theory - deleting out of frame objects

    Hello.
    I'm making a dynamic map editor just for fun and now I'm thinking about MMF's performance. It's odd to load all objects to map especially if map is huge, because MMF2 has limit of objects (20 000), editor will start lagging and it will drain large amount of memory when there will be thousands of active objects (grounds, borders, etc).

    The way to fix it is simple, just dynamically load visible objects and delete out of frame objects. I think that AssArray Object would hold whole map and dynamically load and save objects in array.

    Well, I'm stuck there, because I have some questions. Will AssArray object be able to hold huge array, for example 20 000 x 20 000?

    If yes, I would like to ask somebody how to make a such dynamic loading object, I mean theory or example, because for now I have no idea.

  2. #2
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    I know you can do Add Backdrop, and Paste Image into Background. So if you use active's to paste backdrops then delete the active that should save on resources. As opposed to just making everything actives. I'm not sure if that's what you were already doing however.

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    Yes, but I'd like to operate on each object; click, highligh, dehighlight, delete, set values, etc. If I change them to backdrops, yes, I'll get better performance, but they'll be just backdrops, I will do nothing with them.

  4. #4
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    Ah I see, I didn't realize you wanted to be able to test them for events. Yeah in that case I would think deleting when they are out of frame would work. Not sure about the limitations of the arrays or what effect on performance you would have with this method.

  5. #5
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    Well I found that an extension named "Array" is efficent and it can hold a table greater than 2000x2000. The only problem is that, when I try to make such array, it takes some minutes to fill it.

    I made it this way:
    Code:
    Start of frame:
    -> (General) Start loop "x" 2000 times
    
    On loop "x":
    -> (General) Start loop "y" 2000 times
    
    On loop "y":
    -> (Array) Write Value 1 to (LoopIndex("x"), LoopIndex("y"))
    
    Upon pressing "Enter":
    -> (Counter) Set Counter to ValueAtXY("Array", 1990, 1822)
    I was testing in C/C++ (compiling under linux gcc) how much time will get filling greater table:
    Code:
    #include <cstdlib>
    #include <iostream>
    #include <stdint.h>
    
    int main ( int argc, char** argv )
    {
    	int32_t wynMax = 11145;
    	int64_t** tabeleczka = new int64_t*[wynMax];
    	for(int32_t x = 0; x < wynMax; x++)
    	{
    	    tabeleczka[x] = new int64_t[wynMax];
    		for(int32_t y = 0; y < wynMax; y++)
    			tabeleczka[x][y] = 1;
    	}
    
    	std::cout << "Got it: " << tabeleczka[wynMax / 2][wynMax / 2] << std::endl;
    
    
     	for(int32_t x = 0; x < wynMax; x++)
    	    delete[] tabeleczka[x];
        delete[] tabeleczka;
    
    return 0;
    }
    MMF2 was lagging some minutes with loop in loop x2000. C/C++ was lagging few seconds with loop in loop x11145. This is a few strange... :P

    Is it possible that virtualization, I mean virtualbox will make it some laggy? There is no way I can use MMF2 different way than under virtualized windows.

    I noticed also the fast loop object got a little more laggy that mmf's fast loop. The assarray object was VERY laggy, a lot of more than array.

    However, is there anyone who could help me with topic question?

  6. #6
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    JimJam's Avatar
    Join Date
    Jun 2006
    Location
    USA
    Posts
    353
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    That is exactly your problem. You said you wanted to create map rendering method that deletes objects out of view, right? If you are creating a map that is 2000x2000 tiles, then don't try to render a loop for the WHOLE width of the level at once.

    A loop running 2000 times inside another 2000 loop is trying to make calculations 4,000,000 on every MMF loop. If your frame rate is 50, that's 200,000,000 calculations a second! You are attempting to brute-force the problem. An array that size is too complex to write to all in one instant. And a loop is not the most efficient way to do that. That is exactly why it is taking some time to do the calculations.

    Only draw to the screen the amount of tiles on the screen. So for example, if your screen is 16x16 tiles large, run the loop for 16 X tiles, and 16 Y tiles, for a total of 256 loop iterations (instead of 4,000,000).

    If you are planning on using real time scrolling, then you need to expand your scope a little. For extra security, make your game render a little outside of the screen too. If your screen is 20 tiles wide, render about 28 tiles (leaving 4 extra tiles on the left and right). This way you won't see the game 'drawing' tiles to the screen. Also, your enemies will still be able to behave a little outside of the window (instead of having the screen edge being a kill zone).

  7. #7
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    Thanks for the reply,
    Well, you misunderstood me. I've been thinking of loading map at once, while opening file. When I load the map, it will start a loop 4,000,000 times to load entire map into the array and next showing player items, grounds, borders etc. depends on where he is on the map, as you said with little offset from this array.

  8. #8
    Clicker Fusion 2.5
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    JimJam's Avatar
    Join Date
    Jun 2006
    Location
    USA
    Posts
    353
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    See, this is what I don't understand. You shouldn't need to run four million loops to load an array file. Most array extensions have simple file loading procedures that are near instantaneous.

    Here is an example file I made a while back when I was studying how scrolling games work, along with the source to Knytt stories. It is a very simple scrolling example. But it is basically what you want to do (I think).

    My example uses backdrops, but you could very easily replace those actions with "Create object" actions.

    The "Mario Level" mfa shows how it would look to your player, and the "how Mario Works" mfa shows what your engine is actually doing behind the scenes if you could see it:

    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Main=19274&Number=1368 80#Post136880

    This is how all major 2D games worked in the 80's.

    If I'm still completely off mark of what you are doing, please say so. Regardless, I can't imagine many situations where you need to run four million loops to do something. You should really break it down into simpler tasks.

  9. #9
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2007
    Location
    Poland
    Posts
    232
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    Thank you JimJam. Your reply and attached example were very helpful. Now I have finished dynamically items loading.

    Thanks again!

  10. #10
    No Products Registered

    Join Date
    Jun 2010
    Location
    Sutton, Surrey, UK
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Just in theory - deleting out of frame objects

    Whilst this topic is still alive, if I were to make all "Out of screen" objects invisible, and reappear when they are onscreen, would that help speed up the application?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Advanced Game Board Object - deleting active objects
    By Wackyjackie in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 5th May 2012, 07:03 AM
  2. Deleting Undeletable Objects
    By Crash86 in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 18th September 2010, 01:47 PM
  3. MMF2 was crashed! when object deleting from frame
    By ASD in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 15th May 2010, 05:17 PM
  4. Problem with deleting objects on a specific layer
    By ChrisStreet in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 7th June 2009, 12:29 PM
  5. Creating/ Deleting Active Objects
    By Kid_Roleplay in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 8th December 2006, 01:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •