Results 1 to 3 of 3

Thread: small question

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    10

    Question small question

    I have this sprite that I want to set on a certan part of the screen.I did the bitblt thing and when i push my command button the sprite is autimatically placed at the corner of the background.Iwant to make it so that whenever I push the command button,the sprite wll already be in a certain place on the background,maybe the center.how do I do this?

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Israel
    Posts
    636
    Show me the BitBlt command line you did and I'll tell you.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    10

    here is the code

    Option Explicit

    'Vars
    Dim Active As Boolean


    Public Sub Draw()
    Dim A As Long
    Dim B As Long

    'Draw the background tiles (grass)
    For A = 0 To front.Width / Tile.w
    For B = 0 To front.Height / Tile.h
    BitBlt BackDC, A * Tile.w, B * Tile.h, Tile.w, Tile.h, Tile.DC, 0, 0, vbSrcCopy 'Just copy the memory so no mask
    Next
    Next

    'And now the player
    BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, Player.w, 0, vbSrcPaint 'The mask, important for transparency
    BitBlt BackDC, Player.x, Player.y, Player.w, Player.h, Player.DC, 0, 0, vbSrcAnd 'The player himself

    'Flip (Copy the buffer to the screen)
    BitBlt FrontDC, 0, 0, front.Width, front.Height, BackDC, 0, 0, vbSrcCopy
    End Sub


    Public Sub Main()
    While Active
    'Check the keys we set in Front_KeyDown


    'Draw scene
    Draw

    'And get new windows messages
    DoEvents
    Wend

    cmdrun.Enabled = True
    End Sub


    Private Sub cmdRun_Click()
    Active = True

    cmdrun.Enabled = False
    front.SetFocus

    Main
    'set the sprite to a certain location

    End Sub


    Private Sub Form_Load()
    'Setup back buffer
    back.Move 0, 0, front.Width, front.Height

    'Get DCs of the picture boxes
    BackDC = back.hDC
    FrontDC = front.hDC

    Player.DC = picplayer.hDC
    Tile.DC = pictile.hDC

    'Get size of pictures
    Player.w = picplayer.Width / 2 'Because of the mask
    Player.h = picplayer.Height

    Tile.w = pictile.Width
    Tile.h = pictile.Height
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    'Abort main loop
    Active = False
    End Sub

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