Game Slowdown

Get help using Construct 2

Post » Wed Nov 06, 2013 4:25 pm

I have a very simple prototype of a farmville-style mechanic that hits a wall pretty quickly on the performance side. The user clicks on the canvas to create a small plot of dirt which will wait 5 seconds, turn yellow, wait 5 seconds, and turn green. The problem is that after adding about 14 of the plots, the frame-rate will just plummet and the game becomes unplayable.

The brown, yellow and green plots are each a separate object. The brown and yellow objects each have a timer, the green does not. When a timer is triggered, the next object is spawned and the previous object destroys itself (brown spawns yellow, yellow spawns green, green has no timer - spawns nothing).

Which part of my design is leading to this performance "crash"?

The game:
http://gregorygiles.com/dustbowl/index.html

picture of the event sheet:
http://imgur.com/a/piriy

project:
http://www.sendspace.com/file/o26nkf
B
5
S
1
Posts: 11
Reputation: 397

Post » Wed Nov 06, 2013 5:03 pm

If you run it via Debug, you'll see that there is an exponential increase in the creation of objects that rapidly gets out of hand.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,393
Reputation: 58,468

Post » Wed Nov 06, 2013 5:29 pm

Yes, I was about to say this.. Your "Green" tile is doubling each time in the debugger and causing the slowdown.


@jggiles


Why don't you spawn once each time("brown") when you first plot your grass and then change the animation over time aka ("yellow" then green") This should save memory too instead of just constantly spawning objects. KazaaMafia2013-11-06 17:30:24
Image
B
81
S
16
G
4
Posts: 503
Reputation: 8,953

Post » Wed Nov 06, 2013 5:52 pm

Woah, I didn't know about that debug feature at all! Thanks so much, I see exactly what is going wrong.
B
5
S
1
Posts: 11
Reputation: 397

Post » Wed Nov 06, 2013 5:52 pm

I'll build that approach too. Thanks!
B
5
S
1
Posts: 11
Reputation: 397

Post » Wed Nov 06, 2013 6:08 pm

@jggiles- I would like to see my method if it works if you do try it.
Image
B
81
S
16
G
4
Posts: 503
Reputation: 8,953

Post » Wed Nov 06, 2013 6:16 pm

Actually, I don't entirely understand why this is happening. My event sheet seems to plainly instruct the engine to spawn the green object, then destroy the yellow object (and I assume the yellow object timer by estension). Why, then, is it spawning hundreds of green objects on top of each other?

I'll probably take KazaaMafia's advice, but I'd still like to understand what is going wrong here.
B
5
S
1
Posts: 11
Reputation: 397

Post » Wed Nov 06, 2013 8:36 pm

I figured out one reason for the crazyness - I accidentally created two "brown_ghost" objects at the game start. because this is the location of the very first spawn point for a new object, the fact that there were two meant everything after was double spawning.

That alone doesn't explain the exponential increase, but it doesn't matter because the method suggested by @KazaaMafia is infinitely less cpu / memory intensive.

Thanks all!
B
5
S
1
Posts: 11
Reputation: 397

Post » Wed Nov 06, 2013 8:45 pm

Glad my approach seemed a bit better for you.
Image
B
81
S
16
G
4
Posts: 503
Reputation: 8,953


Return to How do I....?

Who is online

Users browsing this forum: amazingdream and 22 guests