Jump to content


Photo

Incremental lag.


  • Please log in to reply
9 replies to this topic

#1 mn_beta

mn_beta

    GMC Member

  • GMC Member
  • 81 posts
  • Version:GM7

Posted 27 April 2012 - 06:08 PM

I have an issue where my game I have been making lags incrementally the more pickup instances have been created AND destroyed.
It will run perfectly fine again if I restart the room, but continues to lag again the more enemies I kill. I have doubled checked my code for any overflowing variables, and have subsequently found none. Any help would be greatly appreciated.

Creation code for powerup.
i=random(360)
gravity=.05
hspeed=random(1)-.5
vspeed=random(-.5)
peef=0
fry=choose(1,0)
ic=random(10)

Destroy code for powerup.
repeat(5)
instance_create(x,y,Oallef);
sound_play(sebuz);
i=0

Step code for powerup
if i>360
i=0
if i<0
i=360
if fry=1
i+=ic
if fry=0
i-=ic

Download link: http://sandbox.yoyog...-monogatari-iko
(controls: arrow keys left right move character, arrow keys up/down aim, z is jump, x is fire. R restarts room if you die or overcome by lag)

Edited by mn_beta, 27 April 2012 - 06:15 PM.

  • 0

#2 Misu

Misu

    Awesometasticness!

  • GMC Member
  • 435 posts
  • Version:GM:Studio

Posted 27 April 2012 - 06:38 PM

Does the pick up object haves a draw event? If so, post it here please. Does it draw anything in the room when it is created or destroyed? Perhaps you are drawing the sparkle animation and the sprite persist in the room even if it faded away.
  • 0

#3 mn_beta

mn_beta

    GMC Member

  • GMC Member
  • 81 posts
  • Version:GM7

Posted 27 April 2012 - 06:47 PM

Does the pick up object haves a draw event? If so, post it here please. Does it draw anything in the room when it is created or destroyed? Perhaps you are drawing the sparkle animation and the sprite persist in the room even if it faded away.


Draw event:
draw_sprite_ext(Samiam,image_index,x,y,1,1,i,c_white,image_alpha);
if peef=1
{
draw_sprite_ext(Samci,0,x,y,1,1,i,c_white,image_alpha);
peef=0
}

Peef is the variable activated upon collision with floors. It is NOT an animation, just a separate frame.

Edited by mn_beta, 27 April 2012 - 06:47 PM.

  • 0

#4 Misu

Misu

    Awesometasticness!

  • GMC Member
  • 435 posts
  • Version:GM:Studio

Posted 27 April 2012 - 06:58 PM

Hmm... seems fine. What about object "Oallef"? ... Wait, what is object Oallef and does it destroy itself after being used?
  • 0

#5 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14384 posts
  • Version:GM:Studio

Posted 27 April 2012 - 07:00 PM

Providing an exe to debug is like asking a mechanic to determine what is wrong with your car and only allow him to kick the tires.
  • 0

#6 Misu

Misu

    Awesometasticness!

  • GMC Member
  • 435 posts
  • Version:GM:Studio

Posted 27 April 2012 - 07:16 PM

I don't debug but perhaps it could be the "Oallef" object but I don't know much about this object. The thing is that many objects in a room can cause a game to lag (well it depends on how it is executing its events in a room) and maybe you are creating this object but not destroying after used. Or maybe it is drawing something and turns invisible after animation ends but still persist in the room.
  • 0

#7 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1587 posts
  • Version:GM8.1

Posted 27 April 2012 - 07:53 PM

Watch your instance count. Because you're creating 5 new Oallef objects whenever the powerup is destroyed, the instance count will increase when you destroy powerups (Keep in mind that in GM, even an empty object will waste CPU cycles). Chances are good that you're slowing GM down with a large number of instances.

Also, icuurd has a point. It's far easier for us to debug if we can tweak things ourselves.

EDIT: Fixed typo.

Edited by Gamer3D, 27 April 2012 - 07:53 PM.

  • 0

#8 mn_beta

mn_beta

    GMC Member

  • GMC Member
  • 81 posts
  • Version:GM7

Posted 27 April 2012 - 08:42 PM

It is an effect particle that appears temporarily.
The incremental lag does not come from it.
Here is a scale comparison: If I remove the code to create the Drop object (the one creating the lag I presume), there are still about 35 of those particles generated with firing your weapon, jumping, destroying enemies, etcetera. It does not cause any noticeable lag even after elongated playtime.

For those who request the editable: http://sandbox.yoyog...ri-iko-editable

EDIT: Please also give feedback on the gameplay.

Edited by mn_beta, 27 April 2012 - 09:48 PM.

  • 0

#9 Gamer3D

Gamer3D

    Human* me = this;

  • GMC Member
  • 1587 posts
  • Version:GM8.1

Posted 27 April 2012 - 10:46 PM

It is an effect particle that appears temporarily.
The incremental lag does not come from it.

The effect particle is (effectively) never destroyed. Create:
i=random(1)+.7
Step:
i-=.05
if i =0
instance_destroy();

See the problem? No? Well, here's a solution:
i-=.05;
if i<=0
instance_destroy();

Edited by Gamer3D, 27 April 2012 - 10:48 PM.

  • 1

#10 mn_beta

mn_beta

    GMC Member

  • GMC Member
  • 81 posts
  • Version:GM7

Posted 28 April 2012 - 12:15 AM

Seems to have fixed, Thank you.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users