国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

基于VB6.0射擊游戲的實現

2019-11-18 17:55:03
字體:
來源:轉載
供稿:網友

基于VB6.0射擊A.Right=A.Left imgA.Width-1
A.Bottom=A.Top imgA.Height-1
B.Right=B.Left imgB.Width-1
B.Bottom=B.Top imgB.Height-1
'IntersectRectwillonlyreturn0(false)ifthe
'tworectanglesdoNOTintersect.
Collided=IntersectRect(ResultRect,A,B)
EndFunction

'Double-clickingthemousefiresPlayer1'sgun.
PrivateSubForm_DblClick()
DimrcAsInteger
IfNotTimer1.EnabledThenExitSub
GunFired(1)=True
rc=sndPlaySound(App.Path&"/BANG.WAV",SND_ASYNC)
EndSub

'ThiseventhandlesPlayer0'sgameactionviathekeyboard.
PrivateSubForm_KeyDown(KeyCodeAsInteger,ShiftAsInteger)
DimrcAsInteger
StaticInKeyDownAsInteger
IfNotTimer1.EnabledThenExitSub
IfInKeyDownThenExitSub
InKeyDown=True
DoEvents
SelectCaseKeyCode
CaseKEY_UP
imgPlayer(0).Top=imgPlayer(0).Top-PlayerIncrement
IfimgPlayer(0).Top<0ThenimgPlayer(0).Top=0
CaseKEY_SPACE
GunFired(0)=True
rc=sndPlaySound(App.Path&"/BANG.WAV",SND_ASYNC)
CaseKEY_DOWN
imgPlayer(0).Top=imgPlayer(0).Top PlayerIncrement
IfimgPlayer(0).Top>(picDesert.ScaleHeight-
imgPlayer(0).Height)Then
imgPlayer(0).Top=picDesert.ScaleHeight-
imgPlayer(0).Height
EndIf
EndSelect
InKeyDown=False
EndSub

PrivateSubForm_Load()
DimiAsInteger
Timer1.Interval=22
Timer1.Enabled=False
MouseButtonDown=NO_BUTTON
Fori=1ToNUM_BULLETS-1
LoadimgLBullet(i)
LoadimgRBullet(i)
Next
EndSub

PrivateSubForm_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
MouseButtonDown=Button
EndSub

PrivateSubForm_MouseUp(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)
MouseButtonDown=NO_BUTTON
EndSub

'Themaingametimer.
PrivateSubTimer1_Timer()
ConstCactusIncrement=30
ConstBulletIncrement=300
ConstNumCacti=2

DimiAsInteger
DimrcAsInteger
'Movetherovingcacti.
Fori=0ToNumCacti-1
imgCactus(i).Top=imgCactus(i).Top-CactusIncrement
IfimgCactus(i).Top<-imgCactus(i).HeightThen
imgCactus(i).Top=picDesert.Height
EndIf
Next
'Didplayer0fireabullet?
IfGunFired(0)Then
GunFired(0)=False
'Find
aspare(invisible)bullet.
Fori=0ToNUM_BULLETS-1
IfNotimgLBullet(i).VisibleThen
imgLBullet(i).Top=imgPlayer(0).Top
imgLBullet(i).Left=imgPlayer(0).Left
(imgPlayer(0).Width/2)
imgLBullet(i).Visible=True
ExitFor
EndIf
Next
EndIf
'Didplayer1fireabullet?
IfGunFired(1)Then
GunFired(1)=False
'Findaspare(invisible)bullet.
Fori=0ToNUM_BULLETS-1
IfNotimgRBullet(i).VisibleThen
imgRBullet(i).Top=imgPlayer(1).Top
imgRBullet(i).Left=imgPlayer(1).Left-
(imgPlayer(1).Width/2)
imgRBullet(i).Visible=True
ExitFor
EndIf
Next
EndIf
'MoveVisibleBullets
Fori=0ToNUM_BULLETS-1
'Moveplayer0'sbullets.
IfimgLBullet(i).VisibleThen
imgLBullet(i).Left=imgLBullet(i).Left BulletIncrement
IfCollided(imgLBullet(i),imgCactus(0))Then
imgLBullet(i).Visible=False
ElseIfCollided(imgLBullet(i),imgCactus(1))Then
imgLBullet(i).Visible=False
ElseIfimgLBullet(i).Left>picDesert.ScaleWidthThen
imgLBullet(i).Visible=False
ElseIfCollided(imgLBullet(i),imgPlayer(1))Then
imgLBullet(i).Visible=False
imgPlayer(1).Picture=imgRIP.Picture
Timer1.Enabled=False
rc=sndPlaySound(App.Path&"/OH!!.WAV",SND_ASYNC)
EndIf
EndIf
'Moveplayer1'sbullets.
IfimgRBullet(i).VisibleThen
imgRBullet(i).Left=imgRBullet(i).Left-BulletIncrement
IfCollided(imgRBullet(i),imgCactus(0))Then
imgRBullet(i).Visible=False
ElseIfCollided(imgRBullet(i),imgCactus(1))Then
imgRBullet(i).Visible=False
ElseIfimgRBullet(i).Left<-imgRBullet(i).WidthThen
imgRBullet(i).Visible=False
ElseIfCollided(imgRBullet(i),imgPlayer(0))Then
imgRBullet(i).Visible=False
imgPlayer(0).Picture=imgRIP.Picture
Timer1.Enabled=False
rc=sndPlaySound(App.Path&"/OH!!.WAV",SND_ASYNC)
EndIf
EndIf
Next
EndSub

'HandlePlayer1'smovement(upanddown).
PrivateSubtmrMouseCntl_Timer()
IfNotTimer1.EnabledThenExitSub
SelectCaseMouseButtonDown
CaseRBUTTON
imgPlayer(1).Top=imgPlayer(1).Top-PlayerIncrement
IfimgPlayer(1).Top<0ThenimgPlayer(1).Top=0
CaseLBUTTON
imgPlayer(1).Top=imgPlayer(1).Top PlayerIncrement
IfimgPlayer(1).Top>(picDesert.ScaleHeight-
imgPlayer(1).Height)Then
imgPlayer(1).Top=picDesert.ScaleHeight-
imgPlayer(1).Height
EndIf
EndSelect
EndSub


  文章的上述內容對射擊游戲中的各個實現功能進行了詳細的介紹,讀者朋友可以根據文章中的程序代碼自己動手實驗一下。本程序在Windows2000、VisualBasic6.0環境下編譯通過,運行正常。

->


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台中县| 左权县| 阿尔山市| 阿合奇县| 克什克腾旗| 奉化市| 托里县| 托里县| 银川市| 德清县| 资兴市| 沅陵县| 电白县| 汽车| 衡南县| 江陵县| 澜沧| 察哈| 元阳县| 尤溪县| 鹤山市| 湄潭县| 伊金霍洛旗| 新民市| 高唐县| 巴南区| 武威市| 临泽县| 固阳县| 临海市| 库尔勒市| 六安市| 交口县| 新乐市| 裕民县| 云霄县| 赤壁市| 昌邑市| 咸阳市| 固阳县| 东光县|