Skip to main content
GameDev.net gamedev.net
🔒 Locked

2D wrap-scrolling backgrounds

Started by Icefox Jul 4, 2004 at 12:28 PM 1 replies 750+ views
Original Post
Icefox
Icefox
All right. I'm making a 2D top-down game where the player can move in a large, nearly-unlimited area. I want to be able to make a background for this, something like an ocean or starfield or so on. All the sprites are free-moving, not tile based. The question I have is, what's the best way to make a background for such a world? So far the best idea I've come up with is a large image that wraps at the edges, but now that I actually think of it, a tile-based system may be better/simpler/more flexible... Any suggestions?
-----http://alopex.liLet's Program: http://youtube.com/user/icefox192
NMercy
NMercy
If you're doing something like a star field or an ocean, unless there's a lot of extras in the background, you probably want to just use a big wrapping image, that is the same size as the screen resolution you'll be using.

Since you're using a wraparound with unlimited motion in any direction this would probably be the easiest for you to make as it has the least amount of border checking, you won't have to worry about what tile to place, and you won't have to worry about tile wrapping when they've moved farther in one direction than your tile map accounts for.

However if you're going to have a lot of changes, planets, coral, etc in the background a tile map may work out better for you.

Just my opinion, hope it helps...
Icefox
Icefox
Yeah, it helps... thanks. I suppose one of my problems is I'm not entirely certain yet how regular the background is going to be. I suppose that'd be one thing I'd have to decide...

However, then, I still have a problem that I know in theory how to solve, but am having issues implementing... Namely, how to make an image (background, tile, whatever) wrap correctly to the screen. In theory I suppose it seems pretty simple: check to see if the screen is beyond the edge of the image, if so, measure how much, chop that much off the other side, and blit it onto the screen. But for some reason whenever I try to write the code to do this, it ends up utterly tangled... Where might I find a good tutorial on this, and other such tiling issues?

Thanks.
-----http://alopex.liLet's Program: http://youtube.com/user/icefox192

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.