-
New program, need help
Code:
Dim Running As Boolean
Dim velocity As Double
Dim x As Double
Dim y As Double
Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long 'Just ignore this, it's an API call.
Option Explicit
Public Sub drawShipUp()
ShipDown.Visible = False
ShipRight.Visible = False
ShipLeft.Visible = False
BitBlt frmBitBlt.hDC, x, y, 26, 26, frmBitBlt.ShipUp.hDC, 0, 0, vbSrcCopy 'Puts the Ship up picture on the screen.
End Sub
Public Sub drawShipDown()
ShipUp.Visible = False
ShipRight.Visible = False
ShipLeft.Visible = False
BitBlt frmBitBlt.hDC, x, y, 25, 25, frmBitBlt.ShipDown.hDC, 0, 0, vbSrcCopy 'Puts the ship down picture on the screen.
End Sub
Public Sub drawShipLeft()
ShipDown.Visible = False
ShipRight.Visible = False
ShipUp.Visible = False
BitBlt frmBitBlt.hDC, x, y, 25, 25, frmBitBlt.ShipLeft.hDC, 0, 0, vbSrcCopy 'Puts the ship down picture on the screen.
End Sub
Public Sub drawShipRight()
ShipDown.Visible = False
ShipUp.Visible = False
ShipLeft.Visible = False
BitBlt frmBitBlt.hDC, x, y, 25, 25, frmBitBlt.ShipRight.hDC, 0, 0, vbSrcCopy 'Puts the ship down picture on the screen.
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyUp Then
drawShipUp
ElseIf KeyCode = vbKeyDown Then
drawShipDown
ElseIf KeyCode = vbKeyLeft Then
drawShipLeft
ElseIf KeyCode = vbKeyRight Then
drawShipRight
End If
End Sub
Private Sub Form_Load()
x = frmBitBlt.ScaleWidth / 2 ' Gets the center of the form for the x axis.
y = frmBitBlt.ScaleHeight / 2 ' Gets the center of the form for the y axis.
End Sub
Me and my partner are new to VB, our first project is to make an Asteroids program. We just started the "BitBlt" function becasue we were having problems with images distorting one another. As we have it now, when we change directions with the arrow keys the
ShipUp.Visible = False
line's are not hiding the other 3 pictures, as we thought it was set up. We believe our problem is that with "BitBlt" we cannot hide the other pictures with the .visible = false
commands. Any help would be greatly appreciated. For clarification, when we press the left arrow, the up down and right should be hidden, and the same with the other keys. Thanks