Hi lövers! I've been thinking about an alternative way of implementing fine tile-scrolling, that basically works like this:
At start of a level in a game, the entire level's tiles are drawn to a framebuffer (which will be larger than the screen) which is then saved and kept untouched for the rest of that level. Then, the world can be scrolled by simply moving where on the screen the framebuffer is drawn.
As I see it, there are both good and bad aspects of this approach.
Good:
Easy to implement
Fast, since picking tiles and stuff is only done once
Bad:
Uses more memory (since the entire level is graphically loaded at all times)
Inflexible, since changing any tiles in the middle of the game would require the world to be redrawn, which would be slow.
Are there any probllems with this approach that I've overlooked? If not, do you think it would work well, if I make a game designed to work this way (like not having too large maps and not chaning the tiles in the middle of gameplay)?
Alternative tile implementation
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Alternative tile implementation
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Alternative tile implementation
Framebuffer support is the big question mark here. Some people don't support very large framebuffers, or even no framebuffers at all.
Also, if you want to use FBs, you will probably need to make them both square and PO2 to maximize your audience.
Also, if you want to use FBs, you will probably need to make them both square and PO2 to maximize your audience.
Help us help you: attach a .love.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Alternative tile implementation
I would go with an intermediate solution and render the world in "patches"; maybe 512x512 pixels. This would be minimally slower than having everything rendered on a single call, but less taxing on the graphics memory (If I remember correctly, it's easier to allocate 4 patches of 512x512 px than 1 area of 1024x1024).
What about spritebatches?
What about spritebatches?
When I write def I mean function.
Re: Alternative tile implementation
Really? My computer can't handle SpriteBatches at all, but all Framebuffer's I've thrown at it has worked just fine, and it's just a netbook. Perhaps my computer is different from the norm?Robin wrote:Framebuffer support is the big question mark here. Some people don't support very large framebuffers, or even no framebuffers at all.
Also, if you want to use FBs, you will probably need to make them both square and PO2 to maximize your audience.
I was thinking about using a single 512*1024 framebuffer (the game window is 320*240, upscaled), do you think it would be too large? And is not having square framebuffers really an issue?kikito wrote:I would go with an intermediate solution and render the world in "patches"; maybe 512x512 pixels. This would be minimally slower than having everything rendered on a single call, but less taxing on the graphics memory (If I remember correctly, it's easier to allocate 4 patches of 512x512 px than 1 area of 1024x1024).
What about spritebatches?
Maybe using multiple 512*512 is better though. Still very easy to implement but much more flexible. I'll try that.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Alternative tile implementation
There is a bug in the current version of LÖVE which prevents spritebatches from working on integrated intel cards. Perhaps you'll be able to use SB's in 0.8.0, if you have an Intel card.
Re: Alternative tile implementation
Indeed I do. Good to know, thanks!slime wrote:There is a bug in the current version of LÖVE which prevents spritebatches from working on integrated intel cards. Perhaps you'll be able to use SB's in 0.8.0, if you have an Intel card.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Alternative tile implementation
From my experiences with Isome, spritebatches proved to be better for this situation in every way (faster, less memory, more compatible). Just keep in mind that this works best for static stuff (remaking a huge spritebatch can be slow) - anything that moves or interacts are better with regular draws. Also, last time I checked, Love had positioning issues with huge spritebatches (more than 63,000 sprites on one sheet, if I recall), so there's another reason to break your map into chunks.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: Alternative tile implementation
Obviously, I had planned to use regular drawing for all game objects, destructable blocks etc.Taehl wrote:From my experiences with Isome, spritebatches proved to be better for this situation in every way (faster, less memory, more compatible). Just keep in mind that this works best for static stuff (remaking a huge spritebatch can be slow) - anything that moves or interacts are better with regular draws. Also, last time I checked, Love had positioning issues with huge spritebatches (more than 63,000 sprites on one sheet, if I recall), so there's another reason to break your map into chunks.
The idea of spritebatches being more compatible than framebuffers seem really wierd to me for obvious reasons Integrated Intel graphics aren't excactly uncommon. Are Framebuffers really that incompatible?
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- BlackBulletIV
- Inner party member
- Posts: 1261
- Joined: Wed Dec 29, 2010 8:19 pm
- Location: Queensland, Australia
- Contact:
Re: Alternative tile implementation
If you're worried about framebuffer support and are using images for your tiles, you could always use ImageData. Just load the tile images as ImageData objects, paste them into bigger ImageData objects (say, 256x256), then convert them into Image objects.
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: Alternative tile implementation
Aside from this one specific bug, spritebatches should be compatible with everything. Framebuffers, on the other hand, aren't supported by a wide range of old and/or cheap graphics hardware. You can think of a spritebatch as simply an optimized list of things to draw. But framebuffers require hardware support and decent drivers.T-Bone wrote:The idea of spritebatches being more compatible than framebuffers seem really wierd to me for obvious reasons Integrated Intel graphics aren't excactly uncommon. Are Framebuffers really that incompatible?
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Who is online
Users browsing this forum: Bing [Bot] and 4 guests