VB課程設(shè)計(jì)報(bào)告打字游戲_第1頁(yè)
VB課程設(shè)計(jì)報(bào)告打字游戲_第2頁(yè)
VB課程設(shè)計(jì)報(bào)告打字游戲_第3頁(yè)
VB課程設(shè)計(jì)報(bào)告打字游戲_第4頁(yè)
VB課程設(shè)計(jì)報(bào)告打字游戲_第5頁(yè)
已閱讀5頁(yè),還剩3頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、1108320134 冒震宇 課程設(shè)計(jì)題目 打字游戲一 功能:本程序?yàn)闊o(wú)聲版打字練習(xí):有四個(gè)窗體,其中一個(gè)為開始窗體frmstart,游戲界面frmplay,還有一個(gè)為彈出鍵盤的界面frmkeyboard,還有一個(gè)為察看成績(jī)界面frmscore其中frmstart為啟動(dòng)窗體還有一個(gè)模塊用來存放全局變量和一個(gè)控制字母生成的全局過程 ziti。還有一個(gè)文本文件用來儲(chǔ)存玩家的信息。二課程詳細(xì)設(shè)計(jì):1)程序開始顯示“打字設(shè)置”窗口,在“你的姓名”文本框中輸入姓名。若未輸入姓名就單擊“開始練習(xí)”或“查看成績(jī)”按鈕,則在屏幕上出現(xiàn)一個(gè)消息框。在”打字屏幕上隨機(jī)產(chǎn)生并下落各種字符.若用戶在字符落到屏幕底下之

2、前,敲擊了鍵盤上的相應(yīng)的鍵,則該字符被“擊中”,然后消失。程序根據(jù)速度和難度的設(shè)置自動(dòng)計(jì)分,分?jǐn)?shù)實(shí)時(shí)顯示在窗口的頂部。計(jì)分標(biāo)準(zhǔn)如下:1、慢速+小寫字母:打中一個(gè)1分2、慢速+大寫字母:打中一個(gè)2分3、慢速+混合字符:打中一個(gè)3分 4、中速+小寫字母:打中一個(gè)4分5、中速+大寫字母:打中一個(gè)5分6、中速+混合字符:打中一個(gè)6分7、高速+小寫字母:打中一個(gè)7分8、高速+大寫字母:打中一個(gè)8分9、高速+混合字符:打中一個(gè)9分 所有字符包括大小寫字母,數(shù)字和符號(hào)字符.2)當(dāng)下落字符中有相同字符時(shí),一次只能打掉一個(gè).如果按了屏幕上沒有的字符則扣1分,如果有字符落到屏幕底下則扣10分.3)為了增加游戲的趣

3、味性,可增加背景音樂和打中時(shí)的打擊聲.在此不作要求。4)時(shí)間一到則顯示用戶本次的得分并提示是否繼續(xù)進(jìn)行.打字過程中可以按esc鍵則中止游戲,返回打字設(shè)置窗口.5)打字練習(xí)過程中,屏幕的頂部顯示已用的時(shí)間和當(dāng)前的分?jǐn)?shù),按f1功能鍵則彈出鍵盤布局窗口以供用戶參考.6)單擊”查看成績(jī)”按鈕,彈出“成績(jī)”對(duì)話框,顯示當(dāng)前用戶每次的練習(xí)時(shí)間和成績(jī).三、程序代碼展示frmstart:option explicitdim strtime as string 得到輸入時(shí)間文本框的時(shí)間private sub cmdexit_click() 退出按鈕unload frmplay: unload frmstart:

4、 unload frmscoreend subprivate sub cmdscore_click() 察看成績(jī)按鈕dim int7 as integeropen score.txt for input as 3 do while not eof(3) input #3, str1, str2, str3 str4 = str1 + + str2 + + str3 if str1 = frmstart.txtname.text then 如果找到則添加到列表框中 frmscore.lstscore.additem str4 end if if frmstart.txtname.text = t

5、hen 如果搜索內(nèi)容為空則全部顯示 frmscore.lstscore.additem str4 end if str1 = str2 = str3 = str4 = loop if frmscore.lstscore.listcount = 0 then 如果為空即姓名不存在則顯示提示框 int7 = msgbox(沒有您的成績(jī)紀(jì)錄, 48, 成績(jī)查看) if int7 = 1 then unload frmscore end if else frmscore.show end ifclose 3end subprivate sub form_load() frmstart.lbltime.

6、caption = nowtxttime.text = 1optspeed(0).value = true: optzimu(0).value = truetxtname.text = end sub private sub cmdstart_click() 開始按鈕dim m as integerif frmstart.txtname.text = then m = msgbox(請(qǐng)您輸入您的姓名, 32, 錯(cuò)誤) exit subend iffrmstart.visible = falsefrmplay.showend subprivate sub txttime_change() 輸入游

7、戲時(shí)間,默認(rèn)一分鐘dim int3 as single 用來在strtime 和inttime 中間轉(zhuǎn)換的一個(gè)變量strtime = txttime.textint3 = csng(strtime)inttime = int3 * 60end subfrmplay:option explicitdim intsecond as integerdim intminute as integerprivate x as integer 控制爆炸圖畫的出現(xiàn)和消失private intend as integer 控制游戲的結(jié)束private sub form_deactivate()if intend

8、 = inttime then intend = 0: timer2.enabled = false 如果是時(shí)間到了以后退出,則往文本文件里面寫文件 open score.txt for append as 1 write #1, frmstart.txtname.text, cstr(t), frmstart.lbltime.caption close 1 end ifend subprivate sub form_keydown(keycode as integer, shift as integer)dim int4 as integerif keycode = 27 then 用戶按了

9、esc int4 = msgbox(真的要結(jié)束練習(xí)嗎?, 36, 打字練習(xí)) if int4 = 6 then unload frmplay: frmstart.visible = true end ifend ifif keycode = 112 then 用戶按了f1 frmkeyboard.show 1end ifend subprivate sub form_load()intsecond = 0: intminute = 0: intend = 0: t = 0timer2.enabled = true: image1.visible = falsefrmplay.windowsta

10、te = 2dim h as integer, z as integer 循環(huán)變量for z = 0 to 9 標(biāo)簽控件賦初值 lblshow(z).backcolor = frmplay.backcolor lblshow(z).forecolor = rgb(rnd * 255, rnd * 255, rnd * 255) lblshow(z).top = frmplay.top - lblshow(z).heightnext zfor h = 0 to 2 根據(jù)速度的設(shè)定來控制下落的速度 if frmstart.optspeed(h).value = true then timer1.i

11、nterval = 50 * (3 - h) call ziti 隨機(jī)生成字體 end ifnext hlabel1.backcolor = frame1.backcolor: label2.backcolor = frame1.backcolor: label3.backcolor = frame1.backcolorframe1.width = frmplay.width + 1000end subprivate sub timer1_timer() 搜索是否有字母到底randomizedim intx as integerfor intx = 0 to 9 if lblshow(intx

12、).top = frmplay.height - lblshow(intx).height then t = t 10 有字母到底即扣去十分 if frmstart.optzimu(0).value = true then randomize frmplay.lblshow(intx).caption = chr(rnd * 25 + 97) end if if frmstart.optzimu(1).value = true then randomize frmplay.lblshow(intx).caption = chr(rnd * 47 + 65) if asc(frmplay.lbl

13、show(intx).caption) 90 then frmplay.lblshow(intx).caption = chr(rnd * 47 + 65) end if end if if frmstart.optzimu(2).value = true then randomize frmplay.lblshow(intx).caption = chr(rnd * 57 + 65) end if lblshow(intx).top = frmplay.top - lblshow(intx).height lblshow(intx).forecolor = rgb(rnd * 255, rn

14、d * 255, rnd * 255) end if lblshow(intx).top = lblshow(intx).top + rnd * 200next intx label3.caption = 歡迎 & frmstart.txtname.text & _您現(xiàn)在的得分是 & tend subprivate sub timer2_timer() 控制游戲的結(jié)束 dim int5 as integerif intend = inttime then 若大于游戲時(shí)間,則退出 int5 = msgbox(本次練習(xí)你的成績(jī)是 & cstr(t) & 分 & chr(13) & chr(10)

15、& _ 游戲結(jié)束,要繼續(xù)嗎?, 36, 打字練習(xí)) if int5 = 6 then call form_load elseif int5 = 7 then unload frmplay: frmstart.visible = true end ifend ifintend = intend + 1 下面的代碼控制窗體頂部時(shí)間的顯示intsecond = intsecond + 1if intsecond = 60 thenintsecond = intsecond - 60: intminute = intminute + 1end iffrmplay.label1.caption = cs

16、tr(intminute) & : & cstr(intsecond)end subprivate sub form_keypress(keyascii as integer) dim inty as integer 循環(huán)變量 for inty = 0 to 9 if keyascii = asc(lblshow(inty).caption) then 生成新的字符 if frmstart.optzimu(0).value = true then randomize frmplay.lblshow(inty).caption = chr(rnd * 25 + 97) end if if frm

17、start.optzimu(1).value = true then randomize frmplay.lblshow(inty).caption = chr(rnd * 25 + 65) end if if frmstart.optzimu(2).value = true then randomize frmplay.lblshow(inty).caption = chr(rnd * 57 + 65) end if image1.visible = true: image1.left = lblshow(inty).left: image1.top = lblshow(inty).top

18、timer3.enabled = true lblshow(inty).top = frmplay.top - lblshow(inty).height 加分 dim intxunhuan as integer 循環(huán)變量 dim temp as integer 循環(huán)變量 for intxunhuan = 0 to 2 if frmstart.optspeed(intxunhuan).value = true then for temp = 0 to 2 if frmstart.optzimu(temp) = true then t = t + 1 + temp + 3 * intxunhuan

19、 end if next end if next exit sub end if next intyif inty = 10 then 若沒有則減去一分 t = t - 1end if end subprivate sub timer3_timer() 控制爆炸圖畫的出現(xiàn)和消失dim x as integerx = x + 1if x = 1 then image1.visible = false: x = 0end ifend subfrmkeyboard:option explicitprivate sub form_load()image1.picture = loadpicture(r

20、esourcekeyboard.bmp)frmplay.keypreview = false: frmplay.timer1.enabled = false 使鍵盤出現(xiàn)時(shí),游戲窗體暫停frmplay.timer2.enabled = falseend subprivate sub form_unload(cancel as integer)frmplay.keypreview = true: frmplay.timer1.enabled = truefrmplay.timer2.enabled = trueend submodulel1:option explicitpublic t as i

21、nteger 記錄分?jǐn)?shù)public str1 as string, str2 as string, str3 as string, str4 as stringpublic inttime as singlepublic sub ziti() 控制出現(xiàn)字符的種類 dim a as integer, b as integer, c as integer if frmstart.optzimu(0).value = true then for a = 0 to 9 randomize frmplay.lblshow(a).caption = chr(rnd * 25 + 97) next a en

22、d if if frmstart.optzimu(1).value = true then for b = 0 to 9 randomize 使得隨機(jī) frmplay.lblshow(b).caption = chr(rnd * 47 + 65) if asc(frmplay.lblshow(b).caption) 90 then b = b - 1 end if next b end if if frmstart.optzimu(2).value = true then for c = 0 to 9 randomize frmplay.lblshow(c).caption = chr(rnd * 57 + 65) next c end ifend sub四.設(shè)計(jì)過程中出現(xiàn)的問題由于對(duì)程序中涉及的一些書本外的知識(shí),盡管看了資料,但是還是不能應(yīng)用自如,所以本程序的背景音樂和打擊聲沒有實(shí)現(xiàn).可用keypress事件檢測(cè)鍵入的字符是否正確。判斷esc和f1等控制鍵或功能鍵,應(yīng)該使用keydown事件.關(guān)于這兩個(gè)所涉及的鍵碼,有一些不懂得的地方,經(jīng)過翻閱書籍和詢問同學(xué),解決了這個(gè)問題.還有一些小的細(xì)節(jié)問題,經(jīng)過自己不斷地閱讀程序,把這些小的問題解決了。在編

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(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)論