Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Which is faster?
- - By EdwinOdesseiron Date 2013-09-11 20:12
I've got a small question regarding performance. Since Fog of War in my project is based on 32x32 tiles, I use a single .png graphic, completely black. It's 2.75kb in size.
I draw it in 2 states: with alpha set to 255 and 128, depending on what did player see. At most, there are 1,248 of these tiles drawn on screen (if player is looking at the part of map which has no player characters on). I was wondering, if replacing:
@sprite =$window, "Graphics/Sprites/fow_frame.png", false)
@sprite = $window.record { $window.draw_quad(x, y, @color, x + 32, y, @color, x + 32, y + 32, @color, x, y+32, @color, Z::FOW) }
Would be faster? I would like to use a bit smaller grid, but halving both width and height of single FOW tile (to 16x16) increases amount of tiles being drawn 4 times, which drops FPS really bad.

Also I wouldn't mind some good alternatives on creating FOW effect.
Parent - By Spooner Date 2013-09-12 12:03
Those two snippets aren't equivalent and there isn't really any point drawing a quad that is rectangular and orthogonal to the screen (just use regular draw).

I'd consider using a single image for the whole level, containing grey pixels. Turn those pixels permanently transparent as the player sees them and scale this image up by 32 and draw it as the "what I've seen before" indicator.

Also create a smaller image that is a bit larger than the screen (when scaled by 32) which is black with a transparent center, to represent what you can currently see. This could alternatively be less pixelly and/or containing greyscales, since it never actually changes, just being offset based on the current player position in relation to the tile grid.

I suspect these methods would vastly increase your FPS with the same effect as you have now.
Up Topic Gosu / Gosu Exchange / Which is faster?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill