Low FPS

New releases and general discussions.

Post » Sun Sep 28, 2008 2:54 pm

Deadeye, will that method save processing time? What i mean is, do you think containers are so much faster that having some invisible objects will still be faster that using the current method? I'd probably only have a maximum of 5 turrets per ship so it could work. Does this mean i have to make different objects for each of those 5 turrets? Or can i multiple instances?

Also, i got rid of a bunch of the For Each conditions and the code is now more efficient with it still working, however its still HELLA slow :( After creating 40 ships, it drops from 200FPS to 40FPS. (Better than the 30fps i had before).

Can i do better in optimization? Are containers faster? I would have hoped I wouldn't get any FPS drop from this...
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Sun Sep 28, 2008 2:56 pm

Try deleting sections of your events (after a backup!) and finding what the culprit is. Is it still the for-each events? If so, how many of them are there and what do they look like?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Sep 28, 2008 3:10 pm

[quote="alee":3e5yli23]Deadeye, will that method save processing time? What i mean is, do you think containers are so much faster that having some invisible objects will still be faster that using the current method?[/quote:3e5yli23]

Honestly I really have no idea if it would be faster, I was just suggesting something else to try besides loops.

I am wondering something though... do your ships really need separate turrets? Like, is it purely cosmetic or do the turrets themselves take damage/get destroyed? I'm asking because maybe you can fake it with different ship sprites. Like, have one animation for your ship that has one turret, have a second animation that has two turrets, a third with three, etc. It would cut down on the total number of objects dramatically.

It seems to me that even without loops you're eventually going to hit a wall where you start getting sucky fps. Six hundred ships, each with multiple guns, each gun firing multiple bullets... that adds up pretty quick even without loops. It just sounds to me like you're going to have to make some sacrifices and cut some corners somewhere. Be as frugal as possible with your assets while still retaining the core of your gameplay idea.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Sep 28, 2008 5:39 pm

I made an example using a for loop and comparing distance etc.

viewtopic.php?f=16&t=1737

Works pretty good :)
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sun Sep 28, 2008 5:48 pm

Although I'm starting to think now that an 'object pairer' plugin might be a better direction to go.

So you could just create something like this:

[code:1pdae0ze]Loop 600 times
Create spaceship
Loop number of turrets
Create turret
Pair turret to spaceship[/code:1pdae0ze]


And then when you want to position all the objects you would just do

[code:1pdae0ze]Pair: Loop each
Set turret position to spaceship[/code:1pdae0ze]
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Sun Sep 28, 2008 6:38 pm

Pairer plugin sounds really useful, would be cool if as well as loop each pair you could also have

always: set turret X to pairer.X("sprite420")

would always set turret X to the paired instance of sprite420's X
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

Post » Sun Sep 28, 2008 8:35 pm

Yeah, or something to do with a parent/child relationship with sprite objects?
B
2
S
2
G
5
Posts: 448
Reputation: 2,546

Post » Mon Sep 29, 2008 6:07 am

I dont think you completely understand, the condition loop

Pair: Loop each

Would repeat the actions for each parent, and select the spaceships and turrets accordingly. So if you have 600 spaceships and 1200 turrets, it would loop 600 times, selecting the turrets for the one selected spaceship.
B
4
S
2
G
5
Posts: 641
Reputation: 3,011

Post » Mon Sep 29, 2008 9:39 am

[quote="David":3k4bf0jl]I dont think you completely understand, the condition loop

Pair: Loop each

Would repeat the actions for each parent, and select the spaceships and turrets accordingly. So if you have 600 spaceships and 1200 turrets, it would loop 600 times, selecting the turrets for the one selected spaceship.[/quote:3k4bf0jl]

So it's a bit like container, but editable in runtime and capable of having many instances of same object per a parent object. That sounds like what I was originally hoping for containers to be, when Scirra released the first public builds :D. Great!
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Mon Sep 29, 2008 10:17 am

[quote="David":3bba9fyx]I dont think you completely understand, the condition loop

Pair: Loop each

Would repeat the actions for each parent, and select the spaceships and turrets accordingly. So if you have 600 spaceships and 1200 turrets, it would loop 600 times, selecting the turrets for the one selected spaceship.[/quote:3bba9fyx]

I just mean so the pairer object would have all the expressions that a sprite does, but with a parameter for the other object.

so if you have multiple instances of Sprite1 and Sprite2 paired with the pairer,
when you have some instances of sprite1 picked in a condition, the expression " Pairer.X("Sprite2") " would give you the X of the sprite2.

Much like if sprite1 and sprite2 were in a container if sprite1 was picked then sprite2.x would give the paired instance of sprite2's X.
B
2
S
2
G
5
Posts: 236
Reputation: 2,122

PreviousNext

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 2 guests