0 Favourites

Handling many (200+) static objects.

  • tl;dr Do objects outside the view area have less performance impact or the same as objects you can see?

    I created an array of objects IDs and locations and am writing events to spawn or destroy objects from the list based on distance from the player. This is so I can have 200+ scenery objects in a map without actually having them all placed on the map at the same time.

    I wonder however, does C2 do this internally already?

    Will it be better for CPU cycles to iterate through a list of 200 and only create them when needed then destroy them when the player moves away or should I just place all of the objects in the layout from the beginning?

    These objects will not be moving. They are just foliage and rocks and the like.

    Thanks!

  • if the objects will be static, you can use them as tilemap with a solid behavior..

    in my experiments on mobile devices, the amount of objects affects the perfomance. in one android device with less than a 100 objects I get 60 FPS; in the other android I will get 60 FPS only with 80 objects.

  • in this small tutorial game that I made, all the solids is one tilemap (just one object), then I "cover" it with another tilemap. so, with 2 objects, I get all the static solids of the game. you can download the source code of the game and see how I made it.

  • if the objects will be static, you can use them as tilemap with a solid behavior..

    in my experiments on mobile devices, the amount of objects affects the perfomance. in one android device with less than a 100 objects I get 60 FPS; in the other android I will get 60 FPS only with 80 objects.

    Thanks for the reply. Unfortunately it can't be a tilemap for this because of the Z-sorting. The player and enemies have to be able to walk behind the bushes.

    http://www.cargocultgaming.com/CoA/ WASD to move and mouse to shoot. Or use a touch screen for both.

  • in this small tutorial game that I made, all the solids is one tilemap (just one object), then I "cover" it with another tilemap. so, with 2 objects, I get all the static solids of the game. you can download the source code of the game and see how I made it.

    Not bad! I like the music and visual style. What happens if you want to remove a brick? Can you edit the tilemap during runtime? When the brick shows cracks are you just spawning a sprite on top of the tilemap?

  • roguecore, thanks. I dont know if the tilemap can be edited during the runtime.

    The bricks that cracks are not tilemap, they are regular sprites, when the player hits it, it changes the animation. Tilemaps are static in the animations, I think you can not change the animation.

    To spawn a sprite over a specific tilemap is a good idea, but I dont know if it is possible.

  • if the objects will be static, you can use them as tilemap with a solid behavior..

    in my experiments on mobile devices, the amount of objects affects the perfomance. in one android device with less than a 100 objects I get 60 FPS; in the other android I will get 60 FPS only with 80 objects.

    I think I solved it here https://www.scirra.com/forum/test-of-many-scenery-objects_p1072801?#p1072801

    What kind of performance do you get?

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • roguecore, in my experiments, I mean, I made an android apk exporting to cordova and using intel xdk.

    I noticed that in my game Zuper Alien World running on my old cellphone (from 2014), it gets an average of 40 FPS and 80-90% of CPU usage if the game has more than 100 objects, sometimes it gets 100% of CPU and the FPS goes down to 20 FPS. when I start to get coins, and destroy some enemies and blocks, the object counting goes to less than 100 objects, then the CPU goes to about 70% and I get 50-60 FPS.

    In the same game, on my older tablet (from 2013), the perfomance only gets better when the amount of objects go less than 80.

    the game that I mention is this one:

    but running the game on the web, the performance is better, different when I run it as an android APK as I mentioned.

    that's it.

  • > in this small tutorial game that I made, all the solids is one tilemap (just one object), then I "cover" it with another tilemap. so, with 2 objects, I get all the static solids of the game. you can download the source code of the game and see how I made it.

    >

    >

    >

    Not bad! I like the music and visual style. What happens if you want to remove a brick? Can you edit the tilemap during runtime? When the brick shows cracks are you just spawning a sprite on top of the tilemap?

    Yes, you can destroy it. You need to do a few things before anything:

    1- Solid tilemap and the respective Tilemap with all the graphics must have the same size.

    2- The same for the array. (e.g an array with 50 width and 20 height correspond to a tilemap of 1600 by 640 if tiles measure 32px (50*32 = 1600 and 32*20 = 640)

    3- once done it all your map will be manageable because you now can use your array since every cell of the array correspond to a tile on the screen.

    4-If you want to destroy some foliage on the map with your bullet... on destroy get the bullet's position, convert the x and y coordinate into tiles and now you know which tile to destroy.

    Let me know if an example in capx is needed.

  • I use "proxy object" in my example to call big images when it will about to appear on screen. You won't notice what's happening till using debug mode.

  • I use "proxy object" in my example to call big images when it will about to appear on screen. You won't notice what's happening till using debug mode.

    Nice! Looks like we're basically doing the same thing I just store the locations in an array instead of a proxy object.

  • >

    > > in this small tutorial game that I made, all the solids is one tilemap (just one object), then I "cover" it with another tilemap. so, with 2 objects, I get all the static solids of the game. you can download the source code of the game and see how I made it.

    > >

    > >

    > >

    >

    > Not bad! I like the music and visual style. What happens if you want to remove a brick? Can you edit the tilemap during runtime? When the brick shows cracks are you just spawning a sprite on top of the tilemap?

    >

    Yes, you can destroy it. You need to do a few things before anything:

    1- Solid tilemap and the respective Tilemap with all the graphics must have the same size.

    2- The same for the array. (e.g an array with 50 width and 20 height correspond to a tilemap of 1600 by 640 if tiles measure 32px (50*32 = 1600 and 32*20 = 640)

    3- once done it all your map will be manageable because you now can use your array since every cell of the array correspond to a tile on the screen.

    4-If you want to destroy some foliage on the map with your bullet... on destroy get the bullet's position, convert the x and y coordinate into tiles and now you know which tile to destroy.

    Let me know if an example in capx is needed.

    Good advice! I think I will use this technique in my game

  • > I use "proxy object" in my example to call big images when it will about to appear on screen. You won't notice what's happening till using debug mode.

    >

    >

    >

    Nice! Looks like we're basically doing the same thing I just store the locations in an array instead of a proxy object.

    Once proxy object out from screen, the image will removed. And once it enter the screen, the image will restored. Probably easy enough for people who don't want mess with an array object.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)