HELP me to edit the codes of my VB space shooter
Author |
Message |
chrisantos
|
Posted: Mon Jul 05, 2010 6:40 am Post subject: HELP me to edit the codes of my VB space shooter |
|
|
@FORMS
Option Explicit
Dim j
Dim i
Dim LaserX As Integer
Dim LaserY As Integer
Dim ShootLaser As Boolean
Dim RockNum As Integer
Dim RockXPos As Integer
Dim RockYPos As Integer
Dim XDest As Integer
Dim YDest As Integer
Dim XLoader As Integer
Dim YLoader As Integer
Dim StarXPos(1 To 400)
Dim StarYPos(1 To 400)
Dim RandX As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyEscape
j = sndPlaySound(vbNullString, SND_ASYNC)
End
End Select
End Sub
Private Sub Form_Load()
Show
RockYPos = 425
j = sndPlaySound(App.Path + "\Needle.wav", SND_ASYNC Or SND_LOOP)
For XLoader = 1 To 400
Randomize Timer
RandX = Int(Rnd * 500 + 1)
StarXPos(XLoader) = RandX
Next XLoader
For YLoader = 1 To 400
StarYPos(YLoader) = YLoader
Next YLoader
Do
DoEvents
Cls
For i = 1 To 399
StarXPos(i) = StarXPos(i + 1)
Next i
For i = 1 To 400
PSet (StarXPos(i), StarYPos(i)), vbWhite
Next i
RandX = Int(Rnd * 500 + 1)
StarXPos(400) = RandX
'Draw Ship
j = BitBlt(Me.hDC, XDest, YDest, 150, 112, ShipMask.hDC, 0, 0, vbSrcAnd)
j = BitBlt(Me.hDC, XDest, YDest, 150, 112, Ship.hDC, 0, 0, vbSrcPaint)
If ShootLaser = True Then 'if the laser has been activated then:
j = BitBlt(Me.hDC, LaserX + 55, LaserY, 150, 112, LaserMask.hDC, 0, 0, vbSrcAnd)
j = BitBlt(Me.hDC, LaserX + 55, LaserY, 150, 112, Laser.hDC, 0, 0, vbSrcPaint)
LaserY = LaserY + 10
If LaserY >= Me.ScaleHeight Then
ShootLaser = False
End If
End If
RockYPos = RockYPos - 1
j = BitBlt(Me.hDC, RockXPos, RockYPos, 150, 112, AsteroidMask(RockNum).hDC, 0, 0, vbSrcAnd)
j = BitBlt(Me.hDC, RockXPos, RockYPos, 150, 112, Asteroid(RockNum).hDC, 0, 0, vbSrcPaint)
If RockYPos + 100 < 0 Then
RockYPos = 425
RockXPos = Int(Rnd * Me.ScaleWidth)
RockNum = Int(Rnd * 4)
End If
Loop
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
ShootLaser = True
LaserX = XDest
LaserY = YDest + Ship.Height - 20
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
XDest = x - Ship.Width / 2
YDest = y - Ship.Height / 2
End Sub
Private Sub Form_Unload(Cancel As Integer)
j = sndPlaySound(vbNullString, SND_ASYNC)
End
End Sub
@MODULES
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVallpszSoundName As String, ByVal uFlags As Long) As Long
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
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Const SND_SYNC = &H0
Public Const SND_ASYNC = &H1
Public Const SND_LOOP = &H8
Public Const SND_NODEFAULT = &H2
Public Const SRCCOPY = &HCC020
Public Const SRCPAINT = &HEE0086
Public Const SRCINVERT = &H660046
Public Const SRCERASE = &H440328
**im doing this for almost a month can some one help me to hit the asteroids?
Description: |
this is my project please help me |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
chris's spaceship.rar |
Filesize: |
153.62 KB |
Downloaded: |
210 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
jison_ma
![](http://compsci.ca/v3/uploads/user_avatars/12040307254cf3855c60d9f.gif)
|
Posted: Mon Nov 29, 2010 5:45 am Post subject: Re: HELP me to edit the codes of my VB space shooter |
|
|
If ShootLaser = True Then 'if the laser has been activated then:
j = BitBlt(Me.hDC, LaserX + 55, LaserY, 150, 112, LaserMask.hDC, 0, 0, vbSrcAnd)
j = BitBlt(Me.hDC, LaserX + 55, LaserY, 150, 112, Laser.hDC, 0, 0, vbSrcPaint)
LaserY = LaserY + 10
If LaserX + 55 > RockXPos - 10 And LaserX + 55 < RockXPos + 132 Then
j = BitBlt(Me.hDC, RockXPos, RockYPos, 150, 112, Asteroid(4).hDC, 0, 0, vbSrcAnd) 'Add one picture in Asteroid()
End If
If LaserY >= Me.ScaleHeight Then
ShootLaser = False
End If
End If
' I can just do here. I can't completely understand your codes.
' Next I think you should tell us clearly about your ideas and steps for one program.
|
|
|
|
|
![](images/spacer.gif) |
|
|