PDA

Click to See Complete Forum and Search --> : maps with bitblt


drewski
Feb 2nd, 2000, 01:21 PM
I think I've go a pretty good grasp on bitblt but I don't know how to make a map like for an rpg bigger than the drawing area and make it scroll.Any help here would be appreciated.

Thank you,
drewski

Fox
Feb 2nd, 2000, 06:18 PM
(Everyone wants to make a RPG now... ;)

OK,

I think you're making a tile-based game, huh?
If yes you can take a simple map like this:

-
'Declaration
Dim Map() as Long

'On load
ReDim Map(100, 100)
-

Well, now it's bigger than the screen I think ;). There are many ways to make it scroll...
I have a Camera -class and calculating the tile positions on the screen from the camera coordinates, so i just have to move the camera.
Last year I just took some vars like ScrollX and ScrollY to move. If you want to have an example send me a mail. hope this helps ;).


Fox

------------------
fox_mccloud@gmx.net
...
Every program can be reduced to one instruction which doesn't work.

KENNNY
Feb 3rd, 2000, 03:30 AM
Fox, can u explain more about your camera class?
im making an RTS, and have tiling working (i think), but ive done it differently :)

------------------
cintel rules :p
www.cintelsoftware.co.uk

Fox
Feb 3rd, 2000, 06:09 AM
[What the heck is a RTS :confused:]

There's not much to say about the class itselfs, there are 2 vars (x as single, y as single) and a function LookAt(x as single, y as single).
The code you want (I think) is in the Draw -function. I don't know if you can understand THIS, but I hope so. Look at my draw code:

(Note that my map array is 1-dimensional!)
-
Public Sub Draw()
On Error Resume Next 'Only for the demo
Dim A As Long
Dim B As Long
Dim Index As Long

Dim TempX As Single
Dim TempY As Single

TempX = (Camera.X / TileW)
TempY = (Camera.Y / TileH)

'Draw map
For B = 0 To Viewport.TilesY
Index = Int(B + TempY) * Level(AktLevel).w + Int(TempX)

For A = 0 To Viewport.TilesX
BitBlt Viewport.BackDC, (A - (TempX - Int(TempX))) * TileW, (B - (TempY - Int(TempY))) * TileH, TileW, TileH, Tile(Level(AktLevel).Map(Index).Layer(0)).DC, Tile(Level(AktLevel).Map(Index).Layer(0)).SrcX + Tile(Level(AktLevel).Map(Index).Layer(0)).Ani.Akt * TileW, Tile(Level(AktLevel).Map(Index).Layer(0)).SrcY, vbSrcCopy
Index = Index + 1
Next
Next
End Sub
-

Well, it's a bit different to draw a 1D-map but I have no more code for 2D maps...

You can also download the whole sample project from our website ( And don't steel my code ;) ).

Fox
Feb 3rd, 2000, 06:10 AM
Hm, you meant Real Time Simulation?

drewski
Feb 3rd, 2000, 01:18 PM
Thanks for the help Fox. Now I just have to sit down for a while nad try to decipher what you wrote :) Hopefully it'll clear things up.

Fox
Feb 3rd, 2000, 08:10 PM
Good Luck!
Note that it's just the draw function, you cxan download the whole project if you don't understand something like 'Tile(Level(AktLevel).Map(Index).Layer(0)).DC'. I know that it's a bit complex, but it's real code from my game...

KENNNY
Feb 5th, 2000, 12:39 AM
Fox, why dont you use Direct X 7?
its actaully easier than BitBlt :)
by the way, RTS = real time strategy ;)

------------------
cintel rules :p
www.cintelsoftware.co.uk

Fox
Feb 6th, 2000, 02:25 PM
Well, AFAIK you can't use DirectX on WindowsNT :(

I know that DX is much faster and easier to use and I'm also programming in DX, but in C++, you know ;). And BTW, it doesn't much matter which method you use to draw that all, the important thing is the system, the *real* engine. I can easy switch to DX if I want ;).

------------------
fox_mccloud@gmx.net
...
Every program can be reduced to one instruction which doesn't work.

KENNNY
Feb 8th, 2000, 04:30 AM
indeeed :)
i prefer writing in DX from the start. Also, with Dx you dont have to make masks for sprites, which is good ;)

------------------
cintel rules :p
www.cintelsoftware.co.uk

Fox
Feb 8th, 2000, 04:37 AM
Masks are no problem (wrote a little program). But you don't have to set or include anything for Blitting. Just copy the one line API code and let's go...