Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2D single screen game - how to implement background?

Author
Message
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Apr 2005 09:32
In a simple game where the background is static, what is the best way to create the background image?

I'm using a sprite at the moment, but I'm not convinced it is the most efficient way. It also concerns me that gfx cards that can only do square textures would struggle with a screen-shaped sprite.

In front of the background I have a number of sprites moving around.

BatVink
pizzaman
21
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 5th Apr 2005 11:32 Edited at: 5th Apr 2005 11:33
I always use tiles for my backgrounds (usually 32 by 32 pixels). The reason for this is I can check which tiles need redrawing and only redraw those tiles, gaining extra fps.

The problem with this method is if you have lots of sprites spread accross the whole screen at anyone time (especially if their large), as it may be quicker to just redraw all the tiles rather than check which ones need drawing and then drawing them

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Apr 2005 17:10
How do you display the tiles? As sprites, or something else?

BatVink
pizzaman
21
Years of Service
User Offline
Joined: 18th Feb 2004
Location: Gateshead, UK
Posted: 6th Apr 2005 01:39
If any of the tiles are animated, need to be rotated or special effects applied to them, I use sprites. For anything else I use paste image.

UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 6th Apr 2005 13:54
the paste image command works well....should work just as well for backgrounds...

When we talk to god, we're praying. When god talks to us, we're schizophrenic.
Schizophrenic beats eating alone.
D Ogre
21
Years of Service
User Offline
Joined: 19th Nov 2003
Location:
Posted: 7th Apr 2005 12:55
I've used COPY BITMAP and it seems to execute very fast even on the entire screen (1024x768x32).
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Apr 2005 16:50
Cheers chaps. I'm going to set up a test with a sprite, PASTE IMAGE and COPY BITMAP. I'll post my results.

BatVink
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 7th Apr 2005 23:35 Edited at: 7th Apr 2005 23:37
OK, we have a winner!!

Here's the code if you want to run your own tests. Select the method to test. Rerun it for each test.



My results, compared with the fastest are:

1. PASTE IMAGE - 100%
2. COPY BITMAP - 81%
3. SPRITE - 55%

So it looks like I used the worst possible method!

BatVink
Emperor Baal
21
Years of Service
User Offline
Joined: 1st Dec 2003
Location: The Netherlands - Oudenbosch
Posted: 14th May 2005 03:16
you can make sprites a lot faster by using:

set sprite 1, 0, 1

this turns off the backsave state. Use it after your first sprite command (the user presses 3) and your fps will go up by 30% or so.

BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th May 2005 19:41
Cheers. Never though about it but yes, you don't need to backsave the background sprite!

BatVink

Login to post a reply

Server time is: 2025-05-17 23:09:47
Your offset time is: 2025-05-17 23:09:47