Game Slowdown

0 favourites
  • 9 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
  • 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:

    gregorygiles.com/dustbowl/index.html

    picture of the event sheet:

    imgur.com/a/piriy

    project:

    sendspace.com/file/o26nkf

  • 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.

  • 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.

  • Woah, I didn't know about that debug feature at all! Thanks so much, I see exactly what is going wrong.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'll build that approach too. Thanks!

  • I would like to see my method if it works if you do try it.

  • 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.

  • 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 is infinitely less cpu / memory intensive.

    Thanks all!

  • Glad my approach seemed a bit better for you.

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