Scrolling Camera

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Guest

Scrolling Camera

Post by Guest »

I have been working on my first RPG.


What is a "camera" and what does it have to do with scrolling?
User avatar
Pete
Site Admin
Posts: 887
Joined: Sun Dec 07, 2003 9:10 pm
Location: Candor, NY
Contact:

Post by Pete »

The camera is the area of your map that you can see.

Say your map is 200 tiles wide by 100 tiles high, and your tiles are 20*20 pixels.

If you're using Screen 13, you'll only be able to see a grid of 16 tiles wide by 10 high. That's a whole lot smaller than the total size of your map. At any particular time, you can show any 16*10 area of your map on the screen....

.....but there's usually only one area that you're really interested in. Somewhere on that map is your hero character that the player is moving around. In order to have a good game, you always want your character to be on the screen. Otherwise it would be pretty tough to play the game. So in your program, you write a routine that makes sure that your character is always somewhere on the screen. The camera scrolls to always keep the on screen.

Occasionally, though, you don't want your character right in the middle, such as when he gets near the edge of the map. Since beyond the edge of the 200x100 of your map, there is nothing. It will probably show up as empty black tiles -- which is pretty ugly compared to your actual map.

So when you get to an edge or a corner, you want the camera to stay ON THE MAP. Your character can keep on moving, but the map will stop scrolling until he's heading back toward the center (where you don't have edges and corners).

It's not really that hard of a concept...you probably already understood it, but didn't know that the term was "camera". :)
Last edited by Pete on Tue Aug 10, 2004 11:29 pm, edited 1 time in total.
Rel.

Post by Rel. »

Yep, Camera is your viewport

http://rel.betterwebber.com/junk.php?id=16
Post Reply