Help to optimize very graphics heavy game.

Get help using Construct 2

Post » Sat May 25, 2013 1:00 pm

Before you read this I need to point out that I've read and fully understood Scirra's tutorial on optimizing for the game engine.

Hi. I've been working on an adventure/rythm game for roughly a month now. I've designed the game with node-webkit in mind, due to my ambitions with the in-game graphics. I feel like I'm only getting started on the art side, but I'm already experiencing slow downs on fairly decent computers. It's obvious that I can do a lot more to optimize the game, but I need your help to figure out if the problem lies with the art assets, the use of filters or the game code?

I would appreaciate it if someone could comment on the code, how I've implemented the assets, and generally how they liked playing the game.
The project is in its very early stages, so constructive criticism is appreaciated.

Here's the exe file: http://www.mediafire.com/download/4k3oylo9otft04o/Klang(2).zip

Here's the Capx:
http://www.mediafire.com/download/35cu4304mkwf163/Klang+Optimization.zip

The heavy hitters on the art-side:
The main character ("Player" object) sticks out since he has over 140 different animations, with an avarage of 8 frames each. Every frame has a size of 128x128.

There's also the sprite based tile sheet lying in the "environment art" subfolder of the object type folder. Every tile has 9 frames at 256x256 size. I've refrained from using tiled backgrounds since I couldn't animate them.

The assets that really kills it though is the Ascending blocks in the same folder. These are 9 frames each, with the baffling size of 256x1472 pixels. I know this is too much, and therefore have only used them at the first prototype stages I made called "Tutorial level 4" and "Test level 2". This is also where the slowdown was the most profound.

Then there's the filters, which I'm unsure wether how much they really affect the performance. I use 3 filters on every stage, all of them are layout specific (Hue, Inverse and Grayscale). Can anyone comment on how much these filters halters the performance?


Here's how the game works:
Each level uses 2 event sheets. "Core mechanics indepentent" covers all of the game's core gameplay. The level specific sheets are "Tutorial level 1,2,3,4". However since I don't think the problem lies here, I won't go into too much detail.


Again I would really appreciate it if someone could help me out here.

Thanks
Tom
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Sat May 25, 2013 2:34 pm

I'm downloading now, but it takes ages, for your capx is 115MB in size. I will try to take a look.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Sat May 25, 2013 2:53 pm

Sounds like your graphics are too big or you're using too many tiles. Layout\layer effects are substantially better performance-wise than applying them to individual objects. How big are the levels? If your tiles don't NEED to be tiles I recommend pasting all of them to a grid of 1024x1024 or 2048x2048 canvases, then loading those images into blank sprite objects in the same fashion, then destroying both canvases and tiles.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sat May 25, 2013 3:09 pm

My memory usage keeps going up the longer I play.. Have you made sure to destroy sprites that are not needed (like the explosion after animation has ended)?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
53
S
16
G
8
Posts: 6,157
Reputation: 19,744

Post » Sat May 25, 2013 7:02 pm

@Tokinsom
The levels vary in size.
The first, second and third stage is 12500, 4096.
The fourth (The one with actual rythm and music) is 24576, 4096

I can probably reduce the height without too much effort on the 3 first, but the fourth used pretty much all of the space. How much does map size crunch the performance?

Could you go a bit deeper on the whole "loading images into blanks and destroying them?" Can I have an animated environment using this technique?

@LittleStain:
Yes I make sure that the explosions always gets destroyed. There's one place at the end of the fourth level where they don't disappear though. But that's just a quick bugfix away.
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Sat May 25, 2013 10:46 pm

Wow. Minitroid's entire world map was 20000x20000 :P

The size of the layout shouldn't affect anything, just what you put in it.
I'm not sure if it'll work for your game but since mine use hundreds and hundreds of tiles I just stretch a canvas across the layout, then paste all the tiles into the canvas, then load the image from the canvas into a sprite object (because webgl and canvas don't go well together) and then delete the canvas and tiles - effectively turning hundreds of performance-killing tiles into 1 image.

You don't want that 1 image to be too big though, so for the really big levels you might want to make a grid of canvases & sprite objects instead of just that one.

Sounds crazy but I get a smooth 60fps with a bunch of particle FX and everything this way, whereas I used to get ~30 with just the tiles.
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Sat May 25, 2013 10:57 pm

Clever. Will definately check it out when the levels are pretty much done. It probably should work, but would need a lot of extra work considering I've also animated the tiles.

http://www.youtube.com/watch?v=snZN8EfjgrI here's a video of a much older build. I've improved a fair amount on the art since then. I might be able to turn all the tiles into 9 images if I animate everything into the same sprite?Tinimations2013-05-25 23:02:22
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Sun May 26, 2013 12:04 am

After looking at the video I'm not sure that'd be the best approach ^^; Your game isn't really tile-based, so. Seems to me you just have too many large sprite objects with the solid attribute and the BGs are probably massive as well. The shaders on top of all that definitely don't help. Maybe you can deactivate the solid attribute for platforms/walls that aren't on-screen? (that'd break most games but it looks like it might work here)Another thing to consider is breaking up the levels into multiple acts.Tokinsom2013-05-26 00:05:37
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Mon May 27, 2013 11:29 am

Alright I've been doing some experiments on a slower computer. It's clear that the filters had some effect on the performance, with removing them I got roughly a 15% performance boost. However completely removing the art barely made any difference.

Here's the big issue I found. With all art gone, no shaders, with a canvas of only 1280x720 consisting of only two boxes (one platform and one solid), and no events running, the game only ran at 40 FPS. Mimicking the same setup in an empty project gave me flawless 60. These missing 20 frames is a big mystery too me. What settings can I have turned on/off in my main project to crunch the performance this much? It ran in preview mode on google chrome if that's any relevant.Tinimations2013-05-27 11:31:13
B
22
S
7
Posts: 316
Reputation: 2,490

Post » Mon May 27, 2013 12:47 pm

Few things that I noticed:

- You could use TiledBackground objects on many occasions, they give far better performance than using multiple identical sprites next to each other.

- You have lots of overlap on your objects: DarknessUpperMid, DarknessUpperLeft etc. Why not just have a single 'Darkness' object and copy, size and rotate it to fit everywhere?
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Next

Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt and 32 guests