Results 1 to 11 of 11

Thread: maps with bitblt

  1. #1

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    Post

    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

  2. #2
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    (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

    ------------------
    [email protected]
    ...
    Every program can be reduced to one instruction which doesn't work.


  3. #3
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    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
    www.cintelsoftware.co.uk

  4. #4
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post


    [What the heck is a RTS ]

    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 ).

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    Hm, you meant Real Time Simulation?

  6. #6

    Thread Starter
    Addicted Member drewski's Avatar
    Join Date
    Feb 2000
    Location
    WA
    Posts
    242

    Post

    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.


  7. #7
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    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...

  8. #8
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    Fox, why dont you use Direct X 7?
    its actaully easier than BitBlt
    by the way, RTS = real time strategy

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

  9. #9
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    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 .

    ------------------
    [email protected]
    ...
    Every program can be reduced to one instruction which doesn't work.


  10. #10
    Hyperactive Member
    Join Date
    Jan 2000
    Posts
    355

    Post

    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
    www.cintelsoftware.co.uk

  11. #11
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088

    Post

    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width