I got to play with this some more tonight.
direct link
Tonight, my goal was to simply make sure I could occlude tiles correctly using the technique illustrated in the 2D camera article.
A 200 x 200 tile grid of tiles is defined, each tile is 64x64 pixels. A 320x240 camera is affixed to the player's ship (you can see it's white outline in the video), and as the ship moves around, the camera position is transformed, a bounding box is created around the transformed camera, this bounding box is "snapped" to the grid, and a subset of the grid is readily obtained for drawing. I ended up using even less / more simplistic math than I had assumed it would require, you don't really have to use mod arithmetic to do this, you can just mix & match Math.Clamp, .Floor & .Ceiling and pretty much get your array indexes straight away (there will be a fully verbose tutorial on all this when it's done, skip the details for now).
Now that the occlusion works, hopefully I'll get a chance to finish this tomorrow by adding the necessary transforms to make it behave like a camera (ship stays in the center of the screen, game world scrolls, that sort of thing). I think I'll need to use a viewport object to physically clip the excess, although I'm not sure yet. Lots of fun stuff to learn still.
12/15/07
2D camera progress
by
emachine74
@
1:18 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment