Move the camera on DirectDraw7, if we have one... |
Saga | Ok, first of all lemme explain what I wanna do:
I'm making a isometric-viewed RPG, and, as any other RPG, the camera gotta "pan" thru the scene sometimes, or follow the main guy. How do I move the camera (if we have one) thru the scene without having to move each DD7Surface? hope u have understood it. thanx and c ya! |
Eric Coleman | Are you using 3D? |
sdw | I'm not sure what you mean by 'not moving each DD7Surface', but I can tell you how the camera works. You draw the tilemap based on the camera's coordinates and you can set the camera coordinates based on the playing character's coordinates. Example:
[code]
Private Type MAP_TILE
X as long
Y as long
End Type
Private Type CAMERA_POS
X as long
Y as long
End Type
Dim Tile(100,100) as MAP_TILE
Dim CameraPos as CAMERA_POS
Private sub DrawMap()
Dim X as long, Y as long
For X = CameraPos.X \ 32to CameraPos.X \ 32 + 20 'Based on 640x480 and 32x32 tiles
For Y = CameraPos.Y \ 32 to CameraPos.Y \ 32 + 15 'Again, based on 640x480 resolution and 32x32 tiles
Draw Tile(X,Y)
Next Y
Next X
End Sub
[/code]
Of course you fill in whatever the tilesize you're using and change the 20 and 15 to the number of tiles that will fit across the screen vertically and horrizontally. Then if you wanted to make the camera follow your main character then you would just add something to ur code like:
[code]
CameraPos.X = MyChar.X - 320 'based on 640x480
Camerapos.Y = MyChar.Y - 240 'based on 640x480
If CameraPos.X < 0 Then CameraPos.X = 0
If CameraPos.Y < 0 Then CameraPos.Y = 0
If CameraPos.X + 640 > MapWidth Then CameraPos.X = Mapwidth - 640
If CameraPos.Y + 480 > MapHeight Then CameraPos.Y = MapHeight - 480
[/code] |
sdw | My previous post is for 2D |
Saga | hey! I didn't tested it out yet but, thanx in advance, really! c ya around! |