Level Tile creation based on scroll

Get help using Construct 2

Post » Fri Feb 15, 2013 9:20 am

I have a tile based game, and to save memory, I want to only render within a set area.

For example, I have an array the level spawns tile locations from, and I only want to show the tiles between scrollx-12 and scrollx+12. I only want to spawn them when they are within the boundry and I want to have all other tiles destroyed outside of the boundry


Currently I'm generating the entire level at layout start
SYS>Start of layout
>>>foreground_array>for each XY element

Sys:Creat object TILE at (background_array.CurY, background_array.CurX)

While the size of tiles, each one is a sprite. The game should be lightweight even with the entire level generated at start, but I would like to do anything I can to make it optimized.Thndr2013-02-15 09:24:11
B
15
S
4
G
4
Posts: 294
Reputation: 3,225

Post » Sun Mar 03, 2013 11:03 am

I tried to put what I learned since this post to create this, but I could not.

What' I'm trying to do is whenever the player moves over 8 pixels floor(scrollx/8) that it destroys the tileset objects outside of a preset range. The tiles are 8x8 large

array_scrollx=floor(scrollx/8)
boundry_scrollx=12


and I've made some events that may reflect that.



Only problem is that it seems to generate duplicate tiles, and not properly delete them, along with taking too long to calculate everything.


At the moment I have 683 objects total spawned on my layout, and it's a medium sized layout. I expect to reach 1000+ on a real level and I am worried if that might affect gameplay. In the spirit of optimizing what the game does, I want to see if there is a way to only create/use the tiles within a boundry (+/- 12) on the tilemap array efficiently. There has to be a wayThndr2013-03-03 11:04:28
B
15
S
4
G
4
Posts: 294
Reputation: 3,225


Return to How do I....?

Who is online

Users browsing this forum: Radulepy and 7 guests