2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩28頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、<p><b>  《VB課程設(shè)計(jì)》</b></p><p><b>  系統(tǒng)簡(jiǎn)介</b></p><p><b>  背景與意義</b></p><p>  由于現(xiàn)在跑酷游戲非常流行,其快餐的游戲方式符合了當(dāng)今人們的娛樂思維。簡(jiǎn)潔傻瓜的操作方式與記錄系統(tǒng)的引入更是刺激了人們對(duì)其的熱情?;?/p>

2、此,我便想用VB在PC端上做一個(gè)類似的跑酷小游戲,并且加入一些較為有趣的元素,使玩家能在這款小游戲中找到些許樂趣?;诖讼敕ǎ疫x擇了以公路賽車為背景素材,制作一款簡(jiǎn)介的跑酷小游戲。游戲中,玩家操作賽車躲避途中隨即出現(xiàn)的車輛,行駛的距離越長(zhǎng)得分越高,如若撞到途中車輛游戲結(jié)束。在設(shè)計(jì)程序中,為了實(shí)現(xiàn)車輛行駛的效果,使用了計(jì)時(shí)器,通過計(jì)時(shí)器短周期移動(dòng)背景,產(chǎn)生車輛在向前行駛的效果。在程序中,額外加入了不同的車輛外形供玩家選擇,增加了趣味性,

3、并且寫入了計(jì)分系統(tǒng)與道具系統(tǒng),使游戲更有目標(biāo)性與可玩性。</p><p><b>  需求分析</b></p><p>  既然是一個(gè)游戲,首先必須能與人互動(dòng),因此程序必須引入接受鍵盤和鼠標(biāo)信息輸入的功能。其次,游戲中總是要有動(dòng)畫效果的,這個(gè)可以通過VB中的定時(shí)器實(shí)現(xiàn)。對(duì)于其他的一些額外功能,通過VB的一些基礎(chǔ)功能、寫與讀外部文件等方式也均能實(shí)現(xiàn),如記錄系統(tǒng),便通過讀

4、、寫外部TXT文件內(nèi)容實(shí)現(xiàn)。</p><p><b>  二.功能介紹</b></p><p><b>  程序的功能有:</b></p><p> ?、儋愜囉螒蛳到y(tǒng):玩家可以通過鍵盤上的左右方向鍵操作賽車躲避路途中的障礙,在途中賽車的速度會(huì)隨著時(shí)間越來越快;</p><p> ?、谟?jì)分與記錄系統(tǒng):

5、隨著游戲時(shí)間的增長(zhǎng),玩家在游戲中得到得分?jǐn)?shù)會(huì)越來越高。同時(shí)游戲中有一個(gè)歷史分?jǐn)?shù)系統(tǒng),會(huì)記錄下玩家所得的最高分與玩家的姓名、創(chuàng)造紀(jì)錄的時(shí)間,并且玩家可以在菜單中的“記錄”選項(xiàng)中查看;</p><p> ?、弁庥^系統(tǒng):玩家可以選擇不同的賽車外觀進(jìn)行游戲;</p><p> ?、艿谰呦到y(tǒng):游戲途中會(huì)隨機(jī)出現(xiàn)功能不同的道具,不同的道具有不同的功能。</p><p><

6、b>  三.程序設(shè)計(jì)</b></p><p><b>  界面設(shè)計(jì)</b></p><p><b>  主界面:</b></p><p>  在游戲制作中,主要想采用比較清新簡(jiǎn)單的風(fēng)格,因此主界面整體設(shè)計(jì)采用黑白簡(jiǎn)潔的色調(diào),由于對(duì)VB自帶按鈕外觀不是很滿意,自行通過picturebox控件制作了一主界面按

7、鈕。</p><p><b>  車庫界面:</b></p><p>  游戲中內(nèi)置兩種不同風(fēng)格外貌的車體供玩家選擇,單擊按鍵即可完成更換。</p><p><b>  游戲說明界面:</b></p><p><b>  記錄界面:</b></p><p&g

8、t;  顯示創(chuàng)造紀(jì)錄的玩家姓名,最高分與創(chuàng)紀(jì)錄的時(shí)間。</p><p><b>  游戲界面:</b></p><p><b>  創(chuàng)新紀(jì)錄時(shí)的界面:</b></p><p>  游戲界面也是才有黑白風(fēng)格,所有車子的外貌風(fēng)格比較童真(=。= 我自己畫的)。</p><p><b>  功能

9、設(shè)計(jì)</b></p><p><b>  代碼中變量:</b></p><p>  Dim lr '左右控制變量</p><p>  Dim ud '上下控制變量</p><p>  Dim a '游戲開始倒計(jì)時(shí)變量</p><p>  Dim b '調(diào)

10、試變量</p><p>  Dim max '最高分記錄系統(tǒng)變量</p><p>  Dim buff '道具系統(tǒng)變量</p><p>  Dim mus '音效變量</p><p>  Dim muss '音效變量</p><p>  Label10.Caption:游戲速度</

11、p><p>  Label7.Caption:玩家得分</p><p>  Label1.Caption:玩家操作賽車左右移動(dòng)速度</p><p>  ①基本車輛移動(dòng)與操作功能:</p><p>  主要通過TIMER1實(shí)現(xiàn),Label10中的數(shù)字為車輛移動(dòng)速度,通過定時(shí)器不斷移動(dòng)程序中的相關(guān)圖片,產(chǎn)生汽車跑動(dòng)的效果。路途上的車輛通過Random

12、ize函數(shù)產(chǎn)生隨機(jī)數(shù),使其出現(xiàn)在隨機(jī)位置,當(dāng)然一定是從窗口上方出現(xiàn),移動(dòng)到窗口最下方然后消失。玩家賽車的控制,通過KEYDOWN與KEYUP實(shí)現(xiàn),定義控制全局變量lr,來控制玩家賽車左右移動(dòng)。代碼如下:</p><p><b>  '鍵盤控制:</b></p><p>  Private Sub Form_KeyDown(KeyCode As Integer,

13、 Shift As Integer)</p><p>  If KeyCode = vbKeyLeft Then lr = "left"</p><p>  If KeyCode = vbKeyRight Then lr = "right"</p><p>  If KeyCode = vbKeyUp Then ud = &q

14、uot;down"</p><p>  If KeyCode = vbKeyDown Then ud = "up"</p><p><b>  End Sub</b></p><p>  Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)<

15、/p><p>  If KeyCode = vbKeyLeft Then lr = "leftstop"</p><p>  If KeyCode = vbKeyRight Then lr = "rightstop"</p><p>  If KeyCode = vbKeyUp Then ud = ""<

16、/p><p>  If KeyCode = vbKeyDown Then ud = ""</p><p><b>  End Sub</b></p><p><b>  ‘定時(shí)器控制:</b></p><p>  Private Sub Timer1_Timer()</p>

17、;<p>  Label7.Caption = Label7.Caption + 1 '計(jì)分</p><p>  Shape1(0).Top = Shape1(0).Top + Label10.Caption + 60 '道路中心線移動(dòng)動(dòng)畫</p><p>  If Shape1(0).Top > Form1.Height Then Shape1(0).

18、Top = 0 - Shape1(0).Height</p><p>  Shape1(1).Top = Shape1(1).Top + Label10.Caption + 60</p><p>  If Shape1(1).Top > Form1.Height Then Shape1(1).Top = 0 - Shape1(1).Height</p><p>

19、;  '撞車記錄成績(jī)與吃道具代碼:</p><p>  If car.Left + car.Width > Picture3(0).Left And car.Left < Picture3(0).Left + Picture3(0).Width And car.Top + car.Height > Picture3(0).Top And car.Top < Picture3(0).

20、Top + Picture3(0).Height Then</p><p>  Label7.Caption = Label7.Caption + 50’加分道具</p><p>  Picture3(0).Left = 9000’吃到道具后使道具消失</p><p><b>  End If</b></p><p> 

21、 If car.Left + car.Width > Picture3(1).Left And car.Left < Picture3(1).Left + Picture3(1).Width And car.Top + car.Height > Picture3(1).Top And car.Top < Picture3(1).Top + Picture3(1).Height Then</p>&l

22、t;p>  buff = 1’加速道具</p><p>  Picture3(1).Left = 9000’吃到道具后使道具消失</p><p><b>  End If</b></p><p>  For s = 0 To 2 '判斷撞車代碼</p><p>  If car.Left + car.Wid

23、th - 100 > Picture1(s).Left And car.Left + 100 < Picture1(s).Left + Picture1(s).Width And car.Top + car.Height > Picture1(s).Top + 200 And car.Top + 200 < Picture1(s).Top + Picture1(s).Height Then</p>

24、<p>  Timer1.Enabled = False</p><p>  Timer3.Enabled = False</p><p>  Frame2.Visible = True</p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC3.wav" '游戲結(jié)束更

25、換音效</p><p>  If mus = 0 Then '判斷背景音樂是開啟還是關(guān)閉</p><p>  WindowsMediaPlayer1.Controls.stop</p><p><b>  End If</b></p><p>  If mus = 1 Then</p><p&

26、gt;<b>  muss = 0</b></p><p><b>  mus = 0</b></p><p><b>  End If</b></p><p>  Label6.Caption = Label7.Caption</p><p>  If Val(Label6.

27、Caption) > Val(Labelmax.Caption) Then</p><p>  Labelmax.Caption = Label6.Caption</p><p>  Label11.Visible = True</p><p>  max = Labelmax.Caption</p><p>  Open App.Pa

28、th & "\point.txt" For Output As #1</p><p>  Write #1, max</p><p><b>  Close #1</b></p><p>  nn = InputBox("創(chuàng)造了新紀(jì)錄!請(qǐng)問您尊姓大名!", " ")</p

29、><p>  tt = Format(Date)</p><p>  Open App.Path & "\name.txt" For Output As #1</p><p>  Write #1, nn</p><p>  Write #1, tt</p><p><b>  Clo

30、se #1</b></p><p><b>  End If</b></p><p>  If Picture1(s).BackColor = RGB(0, 200, 0) Then</p><p>  Timer1.Enabled = False</p><p>  Timer3.Enabled = Fal

31、se</p><p>  Frame2.Visible = True</p><p>  Label6.Caption = Label7.Caption</p><p>  If Val(Label6.Caption) > Val(Labelmax.Caption) Then</p><p>  Labelmax.Caption = L

32、abel6.Caption</p><p>  Label11.Visible = True</p><p>  max = Labelmax.Caption</p><p>  Open App.Path & "\point.txt" For Output As #1</p><p>  Write #1, ma

33、x</p><p><b>  Close #1</b></p><p>  nn = InputBox("創(chuàng)造了新紀(jì)錄!請(qǐng)問您尊姓大名!", " ")</p><p>  tt = Format(Date)</p><p>  Open App.Path & "

34、\name.txt" For Output As #1</p><p>  Write #1, nn</p><p>  Write #1, tt</p><p><b>  Close #1</b></p><p><b>  End If</b></p><p>

35、;<b>  End If</b></p><p>  Picture1(s).BackColor = RGB(200, 0, 0)</p><p><b>  End If</b></p><p><b>  Next s</b></p><p>  '玩家汽車移動(dòng)代

36、碼:</p><p>  If lr = "left" Then</p><p>  Label1.Caption = -55 - Val(Label10.Caption) / 10</p><p><b>  End If</b></p><p>  If lr = "leftstop&q

37、uot; Then</p><p>  If Label1.Caption < 0 Then Label1.Caption = 0</p><p>  Else: Label1.Caption = Label1.Caption</p><p><b>  End If</b></p><p>  If lr = &

38、quot;right" Then</p><p>  Label1.Caption = 55 + Val(Label10.Caption) / 10</p><p><b>  End If</b></p><p>  If lr = "rightstop" Then</p><p>  I

39、f Label1.Caption > 0 Then Label1.Caption = 0</p><p>  Else: Label1.Caption = Label1.Caption</p><p><b>  End If</b></p><p>  If car.Left < 0 Then '判斷車子是否在游戲窗口最左

40、右兩端</p><p>  Label1.Caption = 0</p><p>  car.Left = 0</p><p><b>  Else</b></p><p>  car.Left = car.Left + Label1.Caption</p><p><b>  End

41、If</b></p><p>  If car.Left + car.Width > Form1.Width Then</p><p>  Label1.Caption = 0</p><p>  car.Left = Form1.Width - car.Width</p><p><b>  Else</b

42、></p><p>  car.Left = car.Left + Label1.Caption</p><p><b>  End If</b></p><p>  '隨機(jī)產(chǎn)生道路車輛:</p><p>  Picture1(0).Top = Picture1(0).Top + Label10.Capti

43、on</p><p>  If Picture1(0).Top > Form1.Height Then</p><p>  Picture1(0).BackColor = RGB(0, 200, 0)</p><p>  Picture1(0).Top = -Picture1(0).Height</p><p><b>  R

44、andomize</b></p><p>  xx = Int(4 * (Rnd + 0))</p><p>  Picture1(0).Picture = Image3(xx).Picture</p><p>  X = Int(6400 * (Rnd + 0))</p><p>  Picture1(0).Left = X&l

45、t;/p><p><b>  End If</b></p><p>  Picture1(1).Top = Picture1(1).Top + Label10.Caption</p><p>  If Picture1(1).Top > Form1.Height Then</p><p>  Picture1(1).B

46、ackColor = RGB(0, 200, 0)</p><p>  Picture1(1).Top = -Picture1(1).Height</p><p><b>  Randomize</b></p><p>  xx = Int(4 * (Rnd + 0))</p><p>  Picture1(1).Pic

47、ture = Image3(xx).Picture</p><p>  X = Int(6400 * (Rnd + 0))</p><p>  Picture1(1).Left = X</p><p><b>  End If</b></p><p>  Picture1(2).Top = Picture1(2).Top

48、 + Label10.Caption</p><p>  If Picture1(2).Top > Form1.Height Then</p><p>  Picture1(2).BackColor = RGB(0, 200, 0)</p><p>  Picture1(2).Top = -Picture1(2).Height</p><p

49、><b>  Randomize</b></p><p>  xx = Int(4 * (Rnd + 0))</p><p>  Picture1(2).Picture = Image3(xx).Picture</p><p>  X = Int(6400 * (Rnd + 0))</p><p>  Pictur

50、e1(2).Left = X</p><p><b>  End If</b></p><p>  Picture3(0).Top = Picture3(0).Top + Label10.Caption</p><p>  If Picture3(0).Top - 1740 > Form1.Height Then</p>&

51、lt;p>  Picture3(0).Top = -Picture3(0).Height</p><p><b>  Randomize</b></p><p>  X = Int(6400 * (Rnd + 0))</p><p>  Picture3(0).Left = X</p><p><b> 

52、 End If</b></p><p>  Picture3(1).Top = Picture3(1).Top + Label10.Caption</p><p>  If Picture3(1).Top - 1740 > Form1.Height Then</p><p>  Picture3(1).Top = -Picture3(1).Heig

53、ht</p><p><b>  Randomize</b></p><p>  X = Int(6400 * (Rnd + 0))</p><p>  Picture3(1).Left = X</p><p><b>  End If</b></p><p><b&g

54、t;  End Sub</b></p><p>  ②計(jì)分與記錄系統(tǒng)功能:</p><p>  此部分功能,計(jì)分功能通過定時(shí)器不斷進(jìn)行加法運(yùn)算即可,而記錄系統(tǒng),則通過讀、寫外部文件的功能實(shí)現(xiàn),當(dāng)玩家查看紀(jì)錄時(shí),或者結(jié)束游戲時(shí),程序會(huì)讀取外部TXT文件中的內(nèi)容,里面記錄著紀(jì)錄及其時(shí)間等信息,然后顯示。如果游戲結(jié)束時(shí),分?jǐn)?shù)大于文件中記錄的紀(jì)錄,那么會(huì)出發(fā)INPUTBOX窗口,讓玩家

55、輸入其信息,從新寫入紀(jì)錄數(shù)據(jù),代碼如下:</p><p>  '初始化,清零全局變量,讀取外部紀(jì)錄文件數(shù)據(jù)與背景音樂</p><p>  Private Sub Form_Load()</p><p><b>  a = 0</b></p><p><b>  b = 0</b></p

56、><p><b>  buff = 0</b></p><p>  Open App.Path & "\point.txt" For Input As #1</p><p>  Input #1, max</p><p><b>  Close #1</b></p>

57、;<p>  Labelmax.Caption = max</p><p>  Label10.Caption = 50</p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC1.wma"</p><p><b>  End Sub</b></

58、p><p>  基于TIMER1功能:</p><p>  For s = 0 To 2’判斷是否撞車代碼</p><p>  If car.Left + car.Width - 100 > Picture1(s).Left And car.Left + 100 < Picture1(s).Left + Picture1(s).Width And car.T

59、op + car.Height > Picture1(s).Top + 200 And car.Top + 200 < Picture1(s).Top + Picture1(s).Height Then</p><p>  Timer1.Enabled = False</p><p>  Timer3.Enabled = False</p><p>  

60、Frame2.Visible = True</p><p>  Label6.Caption = Label7.Caption ‘Label6為記錄紀(jì)錄用,Label7為計(jì)分用</p><p>  If Val(Label6.Caption) > Val(Labelmax.Caption) Then</p><p>  Labelmax.Caption = L

61、abel6.Caption</p><p>  Label11.Visible = True’新紀(jì)錄紅色NEW字樣</p><p>  max = Labelmax.Caption</p><p>  Open App.Path & "\point.txt" For Output As #1 ‘寫文件</p><p&g

62、t;  Write #1, max</p><p><b>  Close #1</b></p><p>  nn = InputBox("創(chuàng)造了新紀(jì)錄!請(qǐng)問您尊姓大名!", " ")</p><p>  tt = Format(Date)</p><p>  Open App.P

63、ath & "\name.txt" For Output As #1</p><p>  Write #1, nn</p><p>  Write #1, tt</p><p><b>  Close #1</b></p><p><b>  End If</b><

64、/p><p>  If Picture1(s).BackColor = RGB(0, 200, 0) Then</p><p>  Timer1.Enabled = False</p><p>  Timer3.Enabled = False</p><p>  Frame2.Visible = True</p><p>

65、  WindowsMediaPlayer1.URL = App.Path & "\MUSIC3.wav"</p><p>  If mus = 0 Then '判斷背景音樂是開啟還是關(guān)閉</p><p>  WindowsMediaPlayer1.Controls.stop</p><p><b>  End If<

66、;/b></p><p>  If mus = 1 Then</p><p><b>  muss = 0</b></p><p><b>  mus = 0</b></p><p><b>  End If</b></p><p>  Label

67、6.Caption = Label7.Caption</p><p>  If Val(Label6.Caption) > Val(Labelmax.Caption) Then</p><p>  Labelmax.Caption = Label6.Caption</p><p>  Label11.Visible = True</p><

68、p>  max = Labelmax.Caption</p><p>  Open App.Path & "\point.txt" For Output As #1</p><p>  Write #1, max</p><p><b>  Close #1</b></p><p>  

69、nn = InputBox("創(chuàng)造了新紀(jì)錄!請(qǐng)問您尊姓大名!", " ")</p><p>  tt = Format(Date)</p><p>  Open App.Path & "\name.txt" For Output As #1</p><p>  Write #1, nn</p&

70、gt;<p>  Write #1, tt</p><p><b>  Close #1</b></p><p><b>  End If</b></p><p><b>  End If</b></p><p>  Private Sub Maxp_Click(

71、)’打開紀(jì)錄面板</p><p>  Form2.Show</p><p><b>  End Sub</b></p><p>  紀(jì)錄面板FORM2代碼:</p><p>  Dim Name1 '紀(jì)錄者姓名</p><p>  Dim Time '紀(jì)錄時(shí)間</p>

72、<p>  Dim max '紀(jì)錄分?jǐn)?shù)</p><p>  Private Sub Command1_Click()</p><p>  Unload Form2</p><p><b>  End Sub</b></p><p>  Private Sub Form_Load()</p>

73、<p>  Open App.Path & "\name.txt" For Input As #1</p><p>  Input #1, Name1</p><p>  Input #1, Time</p><p><b>  Close #1</b></p><p>  La

74、bel2.Caption = Name1</p><p>  Label4.Caption = Time</p><p>  Open App.Path & "\point.txt" For Input As #1</p><p>  Input #1, max</p><p><b>  Close #

75、1</b></p><p>  Label3.Caption = max</p><p><b>  End Sub</b></p><p><b> ?、圮噹煜到y(tǒng):</b></p><p>  此部分功能為提供兩種萌萌的外貌的車體供玩家選擇=。=:</p><p&g

76、t;<b>  '車體外貌選擇:</b></p><p>  Private Sub Command5_Click()</p><p>  car.Picture = Picture2(0).Picture</p><p>  Frame3.Visible = False</p><p><b>  E

77、nd Sub</b></p><p>  Private Sub Command6_Click()</p><p>  car.Picture = Picture2(1).Picture</p><p>  Frame3.Visible = False</p><p><b>  End Sub</b><

78、;/p><p><b>  ④道具系統(tǒng):</b></p><p>  游戲途中會(huì)隨機(jī)出現(xiàn)兩種道具,一種為加分道具,一種為加速道具,代碼如下:</p><p>  基于TIMER1吃道具代碼:</p><p>  If car.Left + car.Width > Picture3(0).Left And car.Lef

79、t < Picture3(0).Left + Picture3(0).Width And car.Top + car.Height > Picture3(0).Top And car.Top < Picture3(0).Top + Picture3(0).Height Then</p><p>  Label7.Caption = Label7.Caption + 50’計(jì)分系統(tǒng),吃了道具+50

80、分</p><p>  Picture3(0).Left = 9000’ 吃到道具后使道具消失</p><p><b>  End If</b></p><p>  If car.Left + car.Width > Picture3(1).Left And car.Left < Picture3(1).Left + Picture

81、3(1).Width And car.Top + car.Height > Picture3(1).Top And car.Top < Picture3(1).Top + Picture3(1).Height Then</p><p><b>  buff = 1</b></p><p>  Picture3(1).Left = 9000’ 吃到道具后使道

82、具消失</p><p><b>  End If</b></p><p>  游戲速度越來越快的代碼,吃了道具會(huì)加快增速:</p><p>  Private Sub Timer3_Timer()</p><p>  If buff = 0 Then</p><p>  Label10.Capti

83、on = Label10.Caption + 5</p><p>  ElseIf buff = 1 Then</p><p>  Label10.Caption = Label10.Caption + 15</p><p><b>  buff = 0</b></p><p><b>  End If<

84、/b></p><p>  If Label10.Caption > 200 Then</p><p>  Label10.Caption = 200</p><p><b>  End If</b></p><p><b>  End Sub</b></p><p&

85、gt;<b> ?、荼尘耙魳废到y(tǒng):</b></p><p>  在主菜單會(huì)有背景音樂,開始游戲后與游戲結(jié)束時(shí)均會(huì)有不同的音效,并且在菜單中可以選擇開啟音樂或者關(guān)閉,代碼如下:</p><p>  '初始化,清零全局變量,讀取外部紀(jì)錄文件數(shù)據(jù)與背景音樂</p><p>  Private Sub Form_Load()</p>

86、<p><b>  a = 0</b></p><p><b>  b = 0</b></p><p><b>  buff = 0</b></p><p><b>  mus = 1</b></p><p><b>  muss

87、= 1</b></p><p>  Open App.Path & "\point.txt" For Input As #1</p><p>  Input #1, max</p><p><b>  Close #1</b></p><p>  Labelmax.Caption

88、= max</p><p>  Label10.Caption = 50</p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC1.wma"</p><p><b>  End Sub</b></p><p><b>  '

89、;音樂循環(huán)</b></p><p>  Private Sub WindowsMediaPlayer1_PlayStateChange(ByVal NewState As Long)</p><p>  If NewState = 1 And mus = 1 Then</p><p>  WindowsMediaPlayer1.Controls.play

90、</p><p><b>  End If</b></p><p><b>  End Sub</b></p><p><b>  '打開背景音樂:</b></p><p>  Private Sub OPENMUSIC_Click()</p><p

91、>  WindowsMediaPlayer1.Controls.play</p><p><b>  mus = 1</b></p><p><b>  End Sub</b></p><p><b>  '關(guān)閉背景音樂:</b></p><p>  Privat

92、e Sub CLOSEMUSIC_Click()</p><p>  WindowsMediaPlayer1.Controls.stop</p><p><b>  mus = 0</b></p><p><b>  End Sub</b></p><p><b>  ‘結(jié)束時(shí)音效:<

93、;/b></p><p>  For s = 0 To 2</p><p>  If car.Left + car.Width - 50 > Picture1(s).Left And car.Left + 50 < Picture1(s).Left + Picture1(s).Width And car.Top + car.Height > Picture1(s).

94、Top + 50 And car.Top + 50 < Picture1(s).Top + Picture1(s).Height Then</p><p>  Timer1.Enabled = False</p><p>  Timer3.Enabled = False</p><p>  Frame2.Visible = True</p>&l

95、t;p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC3.wav"</p><p>  If mus = 0 Then</p><p>  WindowsMediaPlayer1.Controls.stop</p><p><b>  End If</b></

96、p><p>  If mus = 1 Then</p><p><b>  muss = 0</b></p><p><b>  mus = 0</b></p><p><b>  End If</b></p><p>  ‘再來一次時(shí)重啟背景音樂</

97、p><p>  Private Sub Command4_Click()</p><p><b>  …………</b></p><p>  If mus = 0 And muss = 0 Then</p><p><b>  mus = 1</b></p><p><b&g

98、t;  muss = 1</b></p><p><b>  End If</b></p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC2.mp3"</p><p>  If mus = 0 Then</p><p>  Wi

99、ndowsMediaPlayer1.Controls.stop</p><p><b>  End If</b></p><p><b>  四、使用說明書</b></p><p>  在主界面上單擊“開始游戲”即可進(jìn)行游戲,使用鍵盤上左右方向鍵操作賽車躲避途中的車輛,撞到其他車輛游戲結(jié)束。隨著游戲進(jìn)行車速會(huì)越來越快,得分

100、也會(huì)越來越高,系統(tǒng)將會(huì)記錄最高分,最高分可以通過窗口左上角菜單中的“紀(jì)錄”選項(xiàng)查詢,同時(shí)背景音樂的開與關(guān)可以通過菜單中的音樂選項(xiàng)選擇。。車庫中有兩種車體外貌供玩家選擇。游戲途中會(huì)隨機(jī)出現(xiàn)兩種道具,吃到他們會(huì)產(chǎn)生不同的效果。左上方菜單中還可以重新啟動(dòng)游戲或者退出游戲。</p><p>  五、總結(jié)及進(jìn)一步完善建議</p><p>  雖然只經(jīng)過短短的三天時(shí)間學(xué)習(xí)VB語言,但是由于其精簡(jiǎn)的風(fēng)格

101、,我已經(jīng)掌握了其一些基本的語法及其編程思想,可以編寫出一些比較基礎(chǔ)的小程序。由于學(xué)過C、匯編等語言,不難發(fā)現(xiàn),其實(shí)不同的編程語言在其編程思想、邏輯與語法等方面都有相似之處,結(jié)合之前對(duì)C和匯編語言的一些學(xué)習(xí)與理解,在學(xué)習(xí)與運(yùn)用VB語言上,還是較為上手的。</p><p>  當(dāng)然,由于是第一次較為嚴(yán)格、深入地去接觸與學(xué)習(xí)VB語言,難免在一開始會(huì)感到不適與遇到一些困難,但是這也是編程的樂趣之一。在遇到困難與問題時(shí),通

102、過不斷地對(duì)程序進(jìn)行調(diào)試與修改,并通過網(wǎng)絡(luò)查詢信息與資料,最終解決問題,這不僅對(duì)自己是一種鍛煉,也是一種能力的提高。</p><p>  在排查與解決程序問題中,我自身感覺,單步運(yùn)行與調(diào)試是很好的一種辦法,通過單步運(yùn)行與調(diào)試,觀察程序運(yùn)行的邏輯、變量的值或者其他效果,對(duì)比自身的期望與程序出現(xiàn)的錯(cuò)誤情況,便能很快地找出問題所在,對(duì)癥下藥,去修改與完善程序。同時(shí),在編寫程序的時(shí)候,命名與備注十分重要,無論是變量或者控件

103、的命名,都會(huì)有助于后期的測(cè)試與修改。</p><p>  在制作本次的課程設(shè)計(jì)中,其實(shí)有過不同的版本程序,如圖:</p><p>  游戲整體風(fēng)格與外貌沒有最后版本的好看和萌=。= ,功能也沒有如今豐富,一開始并沒有加入紀(jì)錄系統(tǒng)與道具系統(tǒng),總體感覺比較山寨。</p><p>  其實(shí)學(xué)習(xí)也就是這樣一個(gè)過程,在過程中不斷克服困難,而后又不斷產(chǎn)生好玩甚至瘋狂的想法,然后

104、再努力去實(shí)現(xiàn),自己都會(huì)感覺很開心(/ 3 \)。</p><p>  完善的建議,我覺得可以加入更多的道具與車體,甚至可以加入不懂難度的賽道供玩家選擇,使游戲更加有趣,同時(shí),由于TXT文件外部讀入并不是非常合適,可以使用數(shù)據(jù)庫替換,使玩家不能輕易更改紀(jì)錄。</p><p><b>  六.參考資料</b></p><p>  1.《Visual

105、 Basic程序設(shè)計(jì)教程(第3版)》</p><p><b>  2.百度知道</b></p><p><b>  附:</b></p><p><b>  源程序完全代碼:</b></p><p>  Dim lr '左右控制變量</p><p&g

106、t;  Dim ud '上下控制變量</p><p>  Dim a '游戲開始倒計(jì)時(shí)變量</p><p>  Dim b '調(diào)試變量</p><p>  Dim max '最高分記錄系統(tǒng)變量</p><p>  Dim buff '道具系統(tǒng)變量</p><p>  Dim mu

107、s '音效變量</p><p>  Dim muss '音效變量</p><p>  '主界面四個(gè)按鈕代碼:</p><p>  Private Sub anniu1_Click()</p><p><b>  a = 0</b></p><p><b>  b

108、= 0</b></p><p>  Frame1.Visible = False</p><p>  Label10.Caption = 50</p><p>  Timer2.Enabled = True</p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSI

109、C2.mp3"</p><p>  If mus = 0 Then</p><p>  WindowsMediaPlayer1.Controls.stop</p><p><b>  End If</b></p><p><b>  End Sub</b></p><p

110、>  Private Sub anniu1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)</p><p>  anniu1.Picture = an1</p><p><b>  End Sub</b></p><p>  Private

111、Sub anniu2_Click()</p><p>  Frame3.Visible = True</p><p><b>  End Sub</b></p><p>  Private Sub anniu2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Si

112、ngle)</p><p>  anniu2.Picture = an3</p><p><b>  End Sub</b></p><p>  Private Sub anniu3_Click()</p><p>  Unload Form1</p><p><b>  End Sub

113、</b></p><p>  Private Sub anniu3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)</p><p>  anniu3.Picture = an5</p><p><b>  End Sub</b><

114、/p><p>  Private Sub anniu4_Click()</p><p>  Frame4.Visible = True</p><p><b>  End Sub</b></p><p>  Private Sub anniu4_MouseMove(Button As Integer, Shift As In

115、teger, X As Single, Y As Single)</p><p>  anniu4.Picture = an7</p><p><b>  End Sub</b></p><p><b>  '關(guān)閉背景音樂:</b></p><p>  Private Sub CLOSEMU

116、SIC_Click()</p><p>  WindowsMediaPlayer1.Controls.stop</p><p><b>  mus = 0</b></p><p><b>  End Sub</b></p><p>  Private Sub Command8_Click()<

117、/p><p>  Frame4.Visible = False</p><p><b>  End Sub</b></p><p>  '初始化,清零全局變量,讀取外部紀(jì)錄文件數(shù)據(jù)與背景音樂</p><p>  Private Sub Form_Load()</p><p><b>

118、  a = 0</b></p><p><b>  b = 0</b></p><p><b>  buff = 0</b></p><p><b>  mus = 1</b></p><p><b>  muss = 1</b></p&

119、gt;<p>  Open App.Path & "\point.txt" For Input As #1</p><p>  Input #1, max</p><p><b>  Close #1</b></p><p>  Labelmax.Caption = max</p><

120、;p>  Label10.Caption = 50</p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC1.wma"</p><p><b>  End Sub</b></p><p><b>  '再來一次按鈕代碼</b>&

121、lt;/p><p>  Private Sub Command4_Click()</p><p>  Frame2.Visible = False</p><p>  Label11.Visible = False</p><p>  Label7.Caption = 0</p><p>  Picture1(0).Top

122、 = 240</p><p>  Picture1(0).Left = 1920</p><p>  Picture1(1).Top = 2520</p><p>  Picture1(1).Left = 9000</p><p>  Picture1(2).Top = 5160</p><p>  Picture1(

123、2).Left = 9000</p><p>  Picture3(0).Top = 4560</p><p>  Picture3(0).Left = 9000</p><p>  Picture3(1).Top = 7680</p><p>  Picture3(1).Left = 9000</p><p>  L

124、abel2.Caption = 3</p><p>  Label1.Caption = 0</p><p>  Label10.Caption = 50</p><p><b>  b = 0</b></p><p><b>  a = 0</b></p><p>  La

125、bel2.Visible = True</p><p>  Timer2.Enabled = True</p><p>  If mus = 0 And muss = 0 Then</p><p><b>  mus = 1</b></p><p><b>  muss = 1</b></p&

126、gt;<p><b>  End If</b></p><p>  WindowsMediaPlayer1.URL = App.Path & "\MUSIC2.mp3"</p><p>  If mus = 0 Then</p><p>  WindowsMediaPlayer1.Controls.st

127、op</p><p><b>  End If</b></p><p><b>  End Sub</b></p><p><b>  '車體外貌選擇:</b></p><p>  Private Sub Command5_Click()</p><

128、p>  car.Picture = Picture2(0).Picture</p><p>  Frame3.Visible = False</p><p><b>  End Sub</b></p><p>  Private Sub Command6_Click()</p><p>  car.Picture

129、= Picture2(1).Picture</p><p>  Frame3.Visible = False</p><p><b>  End Sub</b></p><p>  Private Sub Exit_Click()</p><p>  Unload Form1</p><p>&l

130、t;b>  End Sub</b></p><p><b>  '鍵盤控制:</b></p><p>  Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)</p><p>  If KeyCode = vbKeyLeft Then lr = &

131、quot;left"</p><p>  If KeyCode = vbKeyRight Then lr = "right"</p><p>  If KeyCode = vbKeyUp Then ud = "down"</p><p>  If KeyCode = vbKeyDown Then ud = "

132、;up"</p><p><b>  End Sub</b></p><p>  Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)</p><p>  If KeyCode = vbKeyLeft Then lr = "leftstop"<

133、;/p><p>  If KeyCode = vbKeyRight Then lr = "rightstop"</p><p>  If KeyCode = vbKeyUp Then ud = ""</p><p>  If KeyCode = vbKeyDown Then ud = ""</p>

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論