RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Mon Mar 26, 2007 1:42 am    Post subject: infinite scrolling backgrounds [quote]

anyone know an easy way to make a background image scroll?

like say I have an image that is 1024x480 and I want it to scroll to the left, but I want it to look like it never ends by wrapping to the other side.

every approach I've tried has been either too jerky or simply doesn't give the right effect.

I know its something like parallax scrolling...but I cannot seem to find a reliable resource of information on how to do it.

if you know how, would you mind letting me know how.. please? :)
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
Ninkazu
Demon Hunter


Joined: 08 Aug 2002
Posts: 945
Location: Location:

PostPosted: Mon Mar 26, 2007 4:28 am    Post subject: [quote]

Is this... Allegro? DirectDraw? SDL? What are you using?
Back to top  
Rainer Deyke
Demon Hunter


Joined: 05 Jun 2002
Posts: 672

PostPosted: Mon Mar 26, 2007 5:51 am    Post subject: [quote]

In pseudo-code:
Code:

scroll_rate = 1
bm = the bitmap to scroll
offset = 0
repeat forever:
  offset = (offset + scroll_rate) % bm.width
  blit bm to screen at (offset, 0)
  blit bm to screen at (offset - bm.width, 0)


The blitting function is assumed to perform basic clipping. If this is too slow, then your blitting function is too slow. In SDL, this can be caused by a mismatch between the pixel format of the bitmap and the pixel format of the screen.
Back to top  
DeveloperX
202192397


Joined: 04 May 2003
Posts: 1626
Location: Decatur, IL, USA

PostPosted: Mon Mar 26, 2007 6:35 am    Post subject: [quote]

Ninkazu wrote:
Is this... Allegro? DirectDraw? SDL? What are you using?

I didnt think it really mattered, since the concept can be translated to any language & api.

but I'm using c++ & Allegro. compiling using GCC or Mingw32 (Dev-C++)
_________________
Principal Software Architect
Rambling Indie Games, LLC

See my professional portfolio
Back to top  
Terry
Spectral Form


Joined: 16 Jun 2002
Posts: 798
Location: Dublin, Ireland

PostPosted: Mon Mar 26, 2007 8:11 am    Post subject: [quote]

I posted something about half an hour ago and then deleted it, because I wasn't sure that I was answering the right question :)

Rainer's algorithm sounds like it should work perfectly - is the problem just that the screen is jerky? If so, there are a few things you can do about that.

It sounds to me like you haven't limited the frame rate, in which case the screen will be jerky because the screen isn't refreshing at a consistant rate. Check this out, if you haven't seen it before.

Quote:
I know its something like parallax scrolling...but I cannot seem to find a reliable resource of information on how to do it.


I think parallax scrolling is just the technical name for where you have more than one scrolling background, where they move at different speeds, so that it looks like some are further away than others (i.e. distant backgrounds scroll slower than near backgrounds).
_________________
http://www.distractionware.com
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum