Author Topic: Moveable = false is slow, really slow...  (Read 7817 times)

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Moveable = false is slow, really slow...
« on: August 17, 2011, 09:24:45 AM »
Why changing the Moveable variable to false(for around 24 asteroids) would increase the map's load time 72 fold(from 2 seconds to 144) ?

Anyone mind to reproduce this? Just so I can be sure it's not my windows-hating machine?

Also, if you are aware of any fix, or explanation, I will be pleased to ear it ;)

edit:Code example below:(This one is for a unknown reason still WAY faster than the last, but you can still notice quite a delay(2 seconds to 21)):

Code: [Select]
function LevelSetup()

-- Global Values
Globals.G.Asteroids=(0)
Globals.G.EnemyFactionsMin=(1)
Globals.G.EnemyFactionsMax=(1)

SetBackdropColor(18, 0, 0)

for i = 0, 20 do
a = AddAsteroid(i*100, 0)
a:SetRadius(50)
a.Moveable = false
end
end



function LevelLogic()



while GameRunning() do

coroutine.yield()

end

end

« Last Edit: August 17, 2011, 10:38:35 AM by Orion63 »

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #1 on: August 17, 2011, 01:10:52 PM »
Yes, MoveAble = false makes it slower, I guess it'll be better just to make them all and then set their positions in LevelLogic :P

Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Re: Moveable = false is slow, really slow...
« Reply #2 on: August 17, 2011, 01:37:25 PM »
Yes, MoveAble = false makes it slower, I guess it'll be better just to make them all and then set their positions in LevelLogic :P

Yeah...Made a MyLevelSetup function, and made it run in LevelLogic.

I would have really liked to know why.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #3 on: August 17, 2011, 02:18:44 PM »
Maybe it's not that laggy? IDK...

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Moveable = false is slow, really slow...
« Reply #4 on: August 17, 2011, 04:02:13 PM »
Hi Orion, welcome to the forums :>

That is a very strange problem.  I could understand it if setting Moveable to True was causing the lag, but setting it to False should if anything make it _more_ efficient.  I will try to replicate that behaviour with your level file today, and see if I can figure something out for you.  :>  Watch this space !

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #5 on: August 17, 2011, 04:13:28 PM »
Yes, MoveAble = false makes it slower...[snip]

No, Asteroid.MoveAble = false stops it loading. :P

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Moveable = false is slow, really slow...
« Reply #6 on: August 18, 2011, 12:32:13 AM »
It loads for me, however you're right - it takes a LONG time.  Much longer than should really be required for a map that simple.


I think the problem boils down to the fact that you have a bunch of asteroids clustered very very very close together.

Consider these lines:

Code: [Select]
a = AddAsteroid(i*100, 0)
a:SetRadius(50)

Where i is a value between 0 and 20.

You will therefore end up with 21 asteroids... the first one will be at 0,0.  The second will be at 100,0.  The third will be at 200,0, and so on.

Each asteroid has a radius of 50.  That means it has a diameter of 100.  That means all the asteroids are so close together that they are actually touching!

Also, the game seems to want to make the player's asteroid larger than all the others.  So what happens is that a bunch of the nearby asteroids are actually inside the player's asteroid.

I think that the closer-togetherness of the asteroids, and the asteroids-inside-asteroids, is what is causing the slowness.  I don't know why it happens exactly, but from my experiments it seems that is the common denominator here.

I changed those lines as follows:
Code: [Select]
a = AddAsteroid(i*700, 0)
a:SetRadius(250)

...and it loads in a snap.  :>

Hope this helps you Orion.  Let us know how you get on - it's always cool to see new designers joining! :>

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #7 on: August 18, 2011, 12:42:54 AM »
It won't load with MoveAble = false, because MoveAble is not a property of an Asteroid. Movable, however, is. I was being picky.

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #8 on: August 18, 2011, 12:48:56 AM »
Me being morr picky: "Movable" is not a variable any asteroid haz, U must use "Moveable" :D


Orion63

  • Sapling
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 73
Re: Moveable = false is slow, really slow...
« Reply #9 on: August 18, 2011, 01:12:16 AM »
...

Already finished the project actually :P
Now just retouching some things, and gaining courage to write the map topic(boring stuff compared to programming ^^).

Actually, there a thing.

Why the heck, does the game changes the radius of a planet that is owned by you...

Something like this:

Code: [Select]
copter = AddAsteroid(0, 0)
copter:SetRadius(50)
copter.Owner = 1

Radius 50 in the example above.

Code: [Select]
copter = AddAsteroid(0, 0)
copter:SetRadius(50)
copter.Owner = 3

Bigger.... Significantly.
« Last Edit: August 18, 2011, 01:17:42 AM by Orion63 »

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #10 on: August 18, 2011, 01:25:56 AM »
Me being morr picky: "Movable" is not a variable any asteroid haz, U must use "Moveable" :D

I guess I walked into that, didn't I...

Aino

  • Ent
  • ******
  • Thank You
  • -Given: 4
  • -Receive: 30
  • Posts: 1,527
  • Eufloria: Yes
Re: Moveable = false is slow, really slow...
« Reply #11 on: August 18, 2011, 01:31:56 AM »
Hah, indeed :)

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Moveable = false is slow, really slow...
« Reply #12 on: August 18, 2011, 04:05:18 PM »
Why the heck, does the game changes the radius of a planet that is owned by you...

I know not.  However, you can fix it by adjusting the asteroid radius to what it _should_ be, at the start of LevelLogic.