drawing what's not on the screen (and best practices?)
Posted: Mon Sep 17, 2012 11:30 pm
I've been playing around with love2d for a few weeks now and, thanks to how easy it is to use and how fun Lua is to learn, I think I've got a pretty good grasp on what I'm doing. But I have a general best practices question.
I've got a scrolling (in all directions) space-themed 'playground' set up; thanks to quite a bit of help from the community (parallax scrolling, hump and so many others) I've got a 'world' with four layers:
So I have three layers that are essentially static, but much bigger than the screen. My questions all revolve around the stuff not currently being seen.
I've got a scrolling (in all directions) space-themed 'playground' set up; thanks to quite a bit of help from the community (parallax scrolling, hump and so many others) I've got a 'world' with four layers:
- a base star layer (a layer of 512x512 tiles that are black with white dots) moving at 1/16 of the primary layer
- a 'closer' star layer (a layer of 512x512 tiles that are transparent with white dots) moving at 1/8 of the primary layer
- a layer of semi-randomly placed colored 'stars' (chance based to have one or more positioned within each 512x512 grid moving at 1/2 of the primary layer
- the primary layer on which foreground objects are drawn (the player, asteroids, etc)
- a mostly static layer on top which provides some hud-type elements.
So I have three layers that are essentially static, but much bigger than the screen. My questions all revolve around the stuff not currently being seen.
- Should I try to avoid drawing what is not on the screen? Currently I'm just looping through all of my tiles and drawing them. I have an if statement to check whether some part of the tile was on the screen, but does that really save me anything? I guess this boils down to 'does the draw method simply ignore things that aren't being shown'? I think there were some hints about this in another recent topic, but I'm still not sure it was answered.
- Would I gain any benefit by drawing each static layer to a frame buffer? I read this conversation to the end, but I don't think I reached a conclusion as to whether it's beneficial in some way for my scenario. And it really made me more curious about my first question.
- Am I going to cause severe strain by piling layers over layers with the uppermost layers having lots of transparency?