Offscreen stuff causing lag

For questions about using Classic.

Post » Sun Sep 13, 2009 11:49 pm

Ok so Iw ant to make a huge world map on the same layout much like metroid. problem is,once I get to so many objects the game begins to lag and cause itself to function unintentionally. This has happened to me in 98.9 and in my current version 99.42. I believe because there are so many objects in the game, construct tries to render or do events with them even if they are offscreen. Many of my events have "If Object is onscreen" in them but it doesnt seem to help. Is there any way that we can have objects that are X many pixels away from the screen to not be rendered or scripted at all? In metroid I assume they solved this with their "loading doors" which loaded the next room when entered, which would be nice If construct could do. http://dl.getdropbox.com/u/740832/SMSzil.cap
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Mon Sep 14, 2009 2:12 am

until this is fixed u can take advantage of distance between points expression in conditions to cut the range of which events can run for objects out of range/screen.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Tue Sep 15, 2009 1:47 am

I don't know if this would save any memory because I haven't tested it out yet but......Perhaps instead of having one massive layout you could have like 4-8 smaller layouts arranged in a grid. Then on your one big layout you would place the 4-8 smaller layouts on the grid dynamically using the layout object. So lets say you are in layout one and you are approaching where layout 2 is visible. Then you would show layout 2 and your player would eventually transition to layout 2.

Of course this complicates events because you have to deal with layout transitions. The huge benefit is it could make it where only the layout your currently in is consuming memory, but still give the visual impression of a massive layout.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Tue Sep 15, 2009 2:57 am

yeah with the way im doing this that would definitely make the events more complicated, thanks for the advice though. I havent really played with the layout editor much. Heres my .cap if u want to see what Im talking about. http://dl.getdropbox.com/u/740832/SMSzil.cap
pretty much trying to remake my own version of a sega master system game. Youll notice that you lag while jumping (hold X) and falling. If you delete a bunch of bricks from the lower area you shouldnt lag. Problem is I need to make a huge map to get that good scrolling transition between areas.
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Tue Sep 15, 2009 3:10 am

Objects already stop rendering as soon as they're off-screen. If anything, I think the "Object is on-screen" condtions could actually be slowing it down. Every time that condition is checked, Construct has to loop through each instance of the object to determine if it's on screen. If there were 1000 tiles, that would be 1000 loops each time the "Object is on-screen" condition was checked.

I don't know if that's actually you're problem or not, but I'd suggest having only one event with the "Object is on screen" condition and then placing all the events that currently use the condition as subevents to said event.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Sep 15, 2009 3:26 am

there I posted the cap, once again Im haunted by my inability to make this in construct
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Tue Sep 15, 2009 3:48 am

It looks to be the collision checking for the "Ground" objects. If you turn off the solid attribute, the framerate jumps up to where it should be. I'd suggest placing stretched invisible dummy objects over the tiles to handle collisions. That or use the TiledBackground object for repeating chunks of ground. You have 5895 ground objects. :P
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Sep 15, 2009 4:35 am

*sigh* how lame, ok I dont want to have to do that but its my only choice I guess. thanks
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Tue Sep 15, 2009 4:44 am

pardon the double post but really there should be an option just to omit looping events for objects offscreen.
B
2
S
2
G
4
Posts: 239
Reputation: 1,928

Post » Tue Sep 15, 2009 5:32 am

I don't think a whole lot can be done about it. Construct doesn't know what will be colliding with an object or where it will collide at, so it has to check for a collision with each possible object. Collision checking is already one of the most expensive processes, and doing it 5000+ times every frame is going to take a lot of CPU power.
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest