Quantcast
Channel: Cemetech
Viewing all articles
Browse latest Browse all 75345

General Programming :: RE: TheMazeGame (a precursor to a roguelike) in Axe

$
0
0
Author: Compynerd255
Posted: 29 Jan 2013 09:42:10 am (GMT -5)

GinDiamond wrote:
I've been fooling around with a scrolling map.

How the heck do I do that?

It's elementary, really. I use it all the time in my games:
1. Define two extra variables (I'd recommend U and V) for the top left corner of the camera space.
2. Before you draw, use the position of the player to determine where the camera should be, typically subtracting half the screen width and height (which would be 48 and 36, respectively, on a calculator, although if you're centering an 8x8 sprite, you'd want to subtract 44 and 32).
3. Set up your For() loops that draw your tiles so that they only go in the range of tiles that will appear on your screen (e.g. go from 0 to 12 and 0 to 8 for 8x8 tiles)
4. Whenever you draw anything on the screen, subtract U and V from its X and Y in world space to get its screen space.

Does that help?
_________________
Visit Betafreak Games: http://www.betafreak.com
Help Me Pay for College:
- Sign up for Fastweb through my referal link!


Viewing all articles
Browse latest Browse all 75345

Trending Articles