導航:首頁 > 源碼編譯 > h5打地鼠游戲源碼

h5打地鼠游戲源碼

發布時間:2024-03-21 10:02:44

❶ c語言中怎麼寫打地鼠的游戲

在一個二維數組中,存放標記。

設置難度:分:

對應產生2*N個隨機數,對應(x,y),設置為1,其它空的設置為0.



大概的游戲流程循環:

結束條件: 打到M個停止。

1,產生隨機數,且不相同

2,在對應的坐標中,畫出地鼠,

在N秒內,沒有擊中,地鼠消失;擊中,加分。

(擊中的坐標,要與用戶點的坐標想比較即可,在這個范圍就得分)


❷ 如何用VB程序設計打地鼠游戲

下面是源代碼:
Form1:
Private Sub Form_Load() Dim temp As Integer Randomize
temp = Int(Rnd * 3) + 1
Form1.Picture = LoadPicture("C:\Users\Administrator\Desktop\打地鼠\picture" & temp & ".jpg") WindowsMediaPlayer1.URL = "C:\Users\Administrator\Desktop\打地鼠\Heaven's Devils.wma" End Sub
Private Sub Label1_Click() Form2.Show Form2.num = -1 Form1.Hide
WindowsMediaPlayer1.URL = ""
Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '寫操作 Close #1
Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2 Close #2
Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3 Close #3 End Sub
Private Sub Label2_Click() End End Sub
Form2:
Dim allnum As Integer, oknum As Integer '定義變化次數 打中次數 Public num As Integer '判別是否第一次開始游戲 Dim flags1 As Boolean '判別文件是否保存 Public flags As Boolean '判別是否播放聲音 Private Sub countine_Click() pause.Enabled = True Timer1.Enabled = True countine.Enabled = False WLXZ.Enabled = True End Sub
Private Sub exit_Click() Dim X As Integer Dim tt As Integer
X = MsgBox("是否真的退出?", vbYesNo, "退出遊戲框")
If X = 6 Then
tt = MsgBox("退出遊戲之前,是否保存", vbYesNo, "保存提示") If tt = 6 Then
If flags1 = True Then End Else
If Timer1.Interval = 1000 Then
Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '寫操作
Print #1, Text1.Text + " " + Format(Date, "M/d/yy") Close #1
ElseIf Timer1.Interval = 500 Then
Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2
Print #2, Text1.Text + " " + Format(Date, "M/d/yy") Close #2 Else
Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3
Print #3, Text1.Text + " " + Format(Date, "M/d/yy") Close #3 End If End If End If End End If End Sub
Private Sub Form_Load() Form4.Check1.Value = 1
WindowsMediaPlayer1.Controls.stop countine.Enabled = False pause.Enabled = False WLXZ.Enabled = False
Form5.Top = Form2.Top + 700 Form5.Left = Form2.Left flags1 = False flags = True End Sub
Private Sub help_Click() Form3.Show End Sub
Private Sub new_game_Click() num = num + 1 Dim t As Integer
If (num > 0) Then
t = MsgBox("新游戲開始之前,是否保存", vbYesNo, "保存提示") If t = 6 Then
flags1 = True
If Timer1.Interval = 1000 Then
Open "C:\Users\Administrator\Desktop\打地鼠\primary.dat" For Append As #1 '寫操作
Print #1, Text1.Text + " " + Format(Date, "M/d/yy") Close #1
ElseIf Timer1.Interval = 500 Then
Open "C:\Users\Administrator\Desktop\打地鼠\intermediate.dat" For Append As #2
Print #2, Text1.Text + " " + Format(Date, "M/d/yy") Close #2 Else
Open "C:\Users\Administrator\Desktop\打地鼠\advanced.dat" For Append As #3
Print #3, Text1.Text + " " + Format(Date, "M/d/yy") Close #3 End If End If End If
Call Form_Load
allnum = 0 '變化次數初始為0 oknum = 0 '打中次數初始為0 Timer1.Enabled = True pause.Enabled = True WLXZ.Enabled = True End Sub
Private Sub options_Click() Timer1.Enabled = False Form4.Show
WLXZ.Enabled = False countine.Enabled = True End Sub
Private Sub pause_Click() Dim r, g, b As Integer Timer1.Enabled = False countine.Enabled = True pause.Enabled = False WLXZ.Enabled = False
Form5.Top = Form2.Top + 700 Form5.Left = Form2.Left Form5.Show

閱讀全文

與h5打地鼠游戲源碼相關的資料

熱點內容
哪裡app可以上高中生物課 瀏覽:472
cad粗糙度快捷鍵命令大全 瀏覽:521
騰訊雲伺服器無法運行軟體 瀏覽:342
奔跑吧哪個app 瀏覽:97
哪個app聽音樂最好 瀏覽:281
考研英語2真題pdf 瀏覽:699
煙台編程積木教育環境好不好 瀏覽:214
python優秀代碼 瀏覽:620
androidtop命令 瀏覽:455
你平時怎麼排解壓力 瀏覽:68
表格中的文件夾怎樣設置 瀏覽:476
em78單片機 瀏覽:960
splitjava空格 瀏覽:248
電腦怎麼谷歌伺服器地址 瀏覽:515
nx自定義工具啟動宏命令 瀏覽:101
程序員怎麼解決無法訪問互聯網 瀏覽:303
java訪問本地文件 瀏覽:747
瓦斯琪伺服器怎麼用 瀏覽:22
安卓主題用什麼app 瀏覽:747
修改伺服器pci地址空間 瀏覽:321