C#課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告_第1頁
C#課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告_第2頁
C#課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告_第3頁
C#課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告_第4頁
C#課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告_第5頁
已閱讀5頁,還剩16頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂

2、肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇

3、衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁

4、膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈

5、羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂

6、螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆

7、聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃蕿袆聿莃蟻蠆羅莂莁裊袁莁蒃蚇腿蒀薆袃肅葿蚈蚆羈蒈莈袁袇肅薀蚄袃肄螞羀膂肅莂螂肈肂蒄羈羄肁薇螁袀肀蠆薃膈膀荿蝿肄腿蒁薂羀膈蚃螇羆膇莃蝕袂膆蒅袆膁膅薇蚈肇膄蝕襖羃芄荿蚇衿芃蒂袂螅節(jié)薄蚅膄芁莄袀肀芀蒆螃羆艿薈罿袂艿蟻螂膀羋莀薄肆莇蒃螀羂莆薅薃袈蒞芅螈螄莄蕆薁膃莃 蘇 州 市 職 業(yè) 大 學(xué)課程設(shè)計(jì)說明書 名稱 計(jì)算機(jī)語言c#課程設(shè)計(jì) 彈珠 游戲 201

8、0年 6月 21日至 2010年 7月 4日共2周院 系計(jì)算機(jī)工程系 班 級(jí) 09軟件測(cè)試 姓 名 羅苑(096307335) 系主任 李 金 祥 教研室主任 葉 良 指導(dǎo)教師 張 蘇 王德鵬 摘要:這個(gè)小程序是關(guān)于彈珠的小游戲,游戲比較簡(jiǎn)單,以小球的速度來區(qū)分游戲的難易。該小程序是用左右鍵控制游戲的開始和擋板的方向,不讓小球落到底端,當(dāng)然,小球的速度越快,該游戲的難度也就越大。此程序利用c#程序編寫,在visual studio 2005的環(huán)境下進(jìn)行調(diào)試運(yùn)行的。彈珠原理:碰撞基本都是參照“反射定理”的,就是出射角=入射角,但是做碰撞時(shí)需要角度。碰撞的運(yùn)動(dòng)和球的方向有關(guān),球的方向有好幾種。有8

9、向的,也有4向的。保證小球橫向上在允許范圍之內(nèi)運(yùn)動(dòng),當(dāng)觸發(fā)時(shí)就反方向運(yùn)動(dòng),和當(dāng)出了球拍的可擊打范圍就停止運(yùn)行了。對(duì)于該程序開發(fā),必須達(dá)到以下要求:1、熟悉.net開發(fā)環(huán)境,能夠使用c#語言在.net平臺(tái)上獨(dú)立設(shè)計(jì)、開發(fā)windows應(yīng)用程序。2、掌握c#語言的異常處理技術(shù),能夠使用.net各種調(diào)試方法調(diào)試代碼,掌握幫助的使用方法。3、掌握常用控件以及控件的常用屬性的使用方法。4、界面要做到簡(jiǎn)潔易懂,具有人性化等特點(diǎn)。5、程序沒有在使用過程中不存在任何的問題。6、可選功能應(yīng)全面,可以實(shí)施速度的選擇,游戲的是否繼續(xù),還有記錄的保存。目 錄摘要:2目 錄3一、題目說明4二、總體設(shè)計(jì)42.1系統(tǒng)開發(fā)平

10、臺(tái)4三、詳細(xì)說明4.1系統(tǒng)實(shí)施4四、遇到的問題和解決方法20五、課程設(shè)計(jì)總結(jié)22六、參考文獻(xiàn)22附錄(源程序代碼)22一、 題目說明當(dāng)今用簡(jiǎn)單的代碼編寫的小游戲越來越受人們的歡迎,所以對(duì)于小游戲的開發(fā)也成為了各大編程人士的最愛。我選擇彈珠游戲這個(gè)課題,用代碼控制游戲的等級(jí),運(yùn)用不同的函數(shù)來控制球的速度和方向,游戲簡(jiǎn)單而有趣。二、總體設(shè)計(jì)2.1系統(tǒng)開發(fā)平臺(tái)系統(tǒng)采用microsoft visual studio 2005三、詳細(xì)說明 在此彈球游戲中,對(duì)于球與擋板的位置,借助于x與y坐標(biāo)的調(diào)整來實(shí)現(xiàn)統(tǒng)計(jì),從而確定球落在板上后球的下一次方向。同時(shí)借助于visual studio中的控件來控制小球的速度

11、。此項(xiàng)游戲的計(jì)分運(yùn)用函數(shù)count+,打中一個(gè)磚塊即可得到一分,看你最多能打多少磚塊。.1系統(tǒng)實(shí)施 timer1.interval = dlg.speed; protected override void dispose( bool disposing )if( disposing )if (components != null) components.dispose();base.dispose( disposing ); private string m_strcurrentsoundfile = ballout.wav; public void playasound() if (m_st

12、rcurrentsoundfile.length 0) m_strcurrentsoundfile = ; othread.abort(); public void playsoundinthread(string wavefile) m_strcurrentsoundfile = wavefile; othread = new thread(new threadstart(playasound); othread.start(); #region windows form designer generated codeprivate void initializecomponent() po

13、nents = new system.componentmodel.container(); system.componentmodel.componentresourcemanager resources = new system.componentmodel.componentresourcemanager(typeof(form1); this.timer1 = new system.windows.forms.timer(ponents); this.suspendlayout(); this.timer1.tick += new system.eventhandler(this.ti

14、mer1_tick); this.autoscalebasesize = new system.drawing.size(6, 14); this.clientsize = new system.drawing.size(552, 389); this.icon = (system.drawing.icon)(resources.getobject($this.icon); this.keypreview = true; this.name = form1; this.text = 打磚塊; this.paint += new system.windows.forms.painteventha

15、ndler(this.form1_paint); this.keydown += new system.windows.forms.keyeventhandler(this.form1_keydown); this.load += new system.eventhandler(this.form1_load); this.resumelayout(false); #endregionstathreadstatic void main() application.run(new form1(); private void form1_paint(object sender, system.wi

16、ndows.forms.painteventargs e) graphics g = e.graphics; g.fillrectangle(brushes.white, 0, 0, this.clientrectangle.width, this.clientrectangle.height); thescore.draw(g); thepaddle.draw(g); drawrows(g); theball.draw(g); private void drawrows(graphics g) for (int i = 0; i knumberofrows; i+) rowsi.draw(g

17、); private void checkforcollision() if (theball.position.x 0) theball.xstep *= -1; theball.position.x += theball.xstep; playsoundinthread(wallhit.wav); if (theball.position.y this.clientrectangle.right - theball.width ) theball.xstep *= -1; theball.position.x += theball.xstep; playsoundinthread(wall

18、hit.wav); if (theball.position.y this.clientrectangle.bottom - theball.ystep) incrementgameballs(); reset(); playsoundinthread(ballout.wav); if (rowscollide(theball.position) theball.ystep *= -1; playsoundinthread(brickhit.wav); int hp = hitspaddle(theball.position); if (hp -1) playsoundinthread(pad

19、dlehit.wav); switch (hp) case 1: theball.xstep = -7; theball.ystep = -3; break; case 2: theball.xstep = -5; theball.ystep = -5; break; case 3: theball.xstep = 5; theball.ystep = -5; break; default: theball.xstep = 7; theball.ystep = -3; break; private int hitspaddle(point p) rectangle paddlerect = t

20、hepaddle.getbounds(); if (p.y = this.clientrectangle.bottom - (paddlerect.height + theball.height) ) if (p.x paddlerect.left) & (p.x paddlerect.left) & (p.x paddlerect.left + paddlerect.width/4) & (p.x paddlerect.left + paddlerect.width/2) & (p.x = knumberoftries) timer1.stop(); string msg = 游戲結(jié)束,您一

21、共打了 + numtotalbricks; if (numtotalbricks = 1) msg += brick.; else msg += bricks. + 繼續(xù)努力哦!; messagebox.show(msg); application.exit(); private void reset() theball.xstep = 5; theball.ystep = 5; theball.position.y = this.clientrectangle.bottom - 190; theball.position.x = 5; timer1.stop(); theball.updat

22、ebounds(); invalidate(theball.getbounds(); private int sumbricks () int sum = 0; for (int i = 0; i knumberofrows; i+) sum += rowsi.brickout; return sum; private bool rowscollide (point p) for (int i = 0; i knumberofrows; i+) if (rowsi.collides(theball.getbounds() rectangle rrow = rowsi.getbounds();

23、invalidate(rrow); return true; return false; private void timer1_tick(object sender, system.eventargs e) theball.updatebounds(); invalidate(theball.getbounds(); theball.move(); theball.updatebounds(); invalidate(theball.getbounds(); checkforcollision(); numtotalbricks = sumbricks(); thescore.count =

24、 numtotalbricks; invalidate(thescore.getframe(); if (numtotalbricks = knumberofrows*row.knumberofbricks) timer1.stop(); form4 form1 = new form4(); form1.showdialog(); application.exit(); private void form1_keydown(object sender, system.windows.forms.keyeventargs e) string result = e.keydata.tostring

25、(); invalidate(thepaddle.getbounds(); switch (result) case left: thepaddle.moveleft(); invalidate(thepaddle.getbounds(); if (timer1.enabled = false) timer1.start(); break; case right: thepaddle.moveright(clientrectangle.right); invalidate(thepaddle.getbounds(); if (timer1.enabled = false) timer1.sta

26、rt(); break; default: break; private void form1_load(object sender, eventargs e) 四、遇到的問題和解決方法1.錯(cuò)誤:圖片的路徑錯(cuò)誤,在做此程序的時(shí)候?qū)τ螒蛑谐霈F(xiàn)的擋板進(jìn)行選擇的時(shí)候,選擇了在桌面上的圖片,后來將此程序拷到自己的電腦上的時(shí)候運(yùn)行代碼出現(xiàn)了路徑錯(cuò)誤。圖一:路徑錯(cuò)誤解決方案:將圖片重新拷到游戲文件夾中,并且將路徑改到相應(yīng)的游戲文件夾中,在此拷貝的時(shí)候就不會(huì)造成圖片的損壞和丟失。2.錯(cuò)誤:游戲結(jié)束時(shí)因?yàn)槿鄙俳Y(jié)束代碼,使得游戲雖然結(jié)束,但是窗口無法結(jié)束,造成窗口無限堆疊,使程序變成死循環(huán)。解決方案:在窗口fo

27、rm1中加入代碼timer1.stop();用來結(jié)束前一個(gè)窗口。五、課程設(shè)計(jì)總結(jié)經(jīng)過兩周的課程設(shè)計(jì),使我對(duì)c#編程有了更深一層的了解。在這兩周的課程設(shè)計(jì)中我不斷地改錯(cuò),不斷的調(diào)試,我的努力終于有了成果。最讓我受益匪淺的是整個(gè)設(shè)計(jì)的過程,這個(gè)過程也是我不斷學(xué)習(xí)的一個(gè)過程,我們?cè)谶\(yùn)用舊知識(shí)的同時(shí)也學(xué)到了不少新知識(shí)。本次課程設(shè)計(jì)我發(fā)現(xiàn)自己對(duì)知識(shí)掌握還存在著很多的不足之處,同時(shí)我也明白了自己還有哪些地方需要改進(jìn),自己要在哪些地方進(jìn)行自我的提升。尤為重要的是,這次課程設(shè)計(jì)使我們懂得了理論與實(shí)際相結(jié)合是很重要的。在這次課程設(shè)計(jì)中,我雖然遇到一些困難,但我仍能堅(jiān)持克服。通過這個(gè)小小的課題,我也學(xué)到了一些課外

28、的東西,多謝學(xué)校給了我一次體驗(yàn)的機(jī)會(huì),謝謝老師在我困難的時(shí)候給我的指導(dǎo),也謝謝在這段時(shí)間給過我們幫助的同學(xué)。在此期間我也失落過,也曾一度熱情高漲。從開始時(shí)滿腹盛激情到最后汗水背后的復(fù)雜心情,點(diǎn)點(diǎn)滴滴無不令我回味無窮。課程設(shè)計(jì)是培養(yǎng)學(xué)生綜合運(yùn)用所學(xué)知識(shí),發(fā)現(xiàn),提出,分析和解決實(shí)際問題,鍛煉實(shí)踐能力的重要環(huán)節(jié),是對(duì)學(xué)生實(shí)際工作能力的具體訓(xùn)練和考察過程.隨著科學(xué)技術(shù)發(fā)展的日新月異,編程已經(jīng)成為當(dāng)今計(jì)算機(jī)應(yīng)用中空前活躍的領(lǐng)域, 在生活中可以說得是無處不在。在設(shè)計(jì)過程中,我們遇到許多無法解決的問題,都一一通過網(wǎng)絡(luò)解決了,同時(shí)還問過許多學(xué)得比較扎實(shí)的同學(xué),是他們讓我們有了更多的了解,更好的讓我們?cè)谶@個(gè)問題

29、上著手設(shè)計(jì). 這次課程設(shè)計(jì)終于順利完成了,在設(shè)計(jì)中遇到了很多編程問題,最后在老師的細(xì)心指導(dǎo)下,終于得到解決。同時(shí),在老師的身上我學(xué)得到很多實(shí)用的知識(shí),在次我表示感謝!對(duì)給過我?guī)椭乃型瑢W(xué)和各位指導(dǎo)老師再次表示忠心的感謝!六、參考文獻(xiàn)1鄭阿奇、梁敬東、錢曉軍等,c#實(shí)用教程,電子工業(yè)出版社,2009年。2錢雪忠、黃學(xué)光等,數(shù)據(jù)庫原理及應(yīng)用,北京郵電大學(xué)出版社,2005年。3王進(jìn)強(qiáng). visual basic.net基礎(chǔ)教程m, 北京:清華大學(xué)出版社,2004年。附錄(源程序代碼)using system;using system.drawing;using system.collections

30、;using system.componentmodel;using system.windows.forms;using system.data;using system.runtime.interopservices;using system.threading;namespace brickoutpublic class form1 : system.windows.forms.form private system.componentmodel.icontainer components; private const int knumberofrows = 8; private con

31、st int knumberoftries = 3; private int numtotalbricks = 0; private int numballs = 0; private ball theball = new ball(); private paddle thepaddle = new paddle(); private system.windows.forms.timer timer1; private row rows = new rowknumberofrows; private score thescore = null; private thread othread =

32、 null; dllimport(winmm.dll) public static extern long playsound(string lpszname, long hmodule, long dwflags);public form1()initializecomponent(); for (int i = 0; i knumberofrows; i+) rowsi = new row(i); thepaddle.position.x = 5; thepaddle.position.y = this.clientrectangle.bottom - thepaddle.height;

33、theball.position.y = this.clientrectangle.bottom - 200; this.setbounds(this.left, this.top, rows0.getbounds().width, this.height); thescore = new score(clientrectangle.right - 50, clientrectangle.bottom - 180); / choose level speeddialog dlg = new speeddialog(); if (dlg.showdialog() = dialogresult.o

34、k) timer1.interval = dlg.speed; / todo: add any constructor code after initializecomponent call/ / clean up any resources being used./ protected override void dispose( bool disposing )if( disposing )if (components != null) components.dispose();base.dispose( disposing ); private string m_strcurrentso

35、undfile = ballout.wav; public void playasound() if (m_strcurrentsoundfile.length 0) playsound(application.startuppath + + m_strcurrentsoundfile, 0, 0); m_strcurrentsoundfile = ; othread.abort(); public void playsoundinthread(string wavefile) m_strcurrentsoundfile = wavefile; othread = new thread(new

36、 threadstart(playasound); othread.start(); #region windows form designer generated code/ / required method for designer support - do not modify/ the contents of this method with the code editor./ private void initializecomponent() ponents = new system.componentmodel.container(); this.timer1 = new sy

37、stem.windows.forms.timer(ponents); this.suspendlayout(); / / timer1 / this.timer1.tick += new system.eventhandler(this.timer1_tick); / / form1 / this.autoscalebasesize = new system.drawing.size(6, 14); this.clientsize = new system.drawing.size(552, 389); this.keypreview = true; this.name = form1; th

38、is.text = brick out; this.paint += new system.windows.forms.painteventhandler(this.form1_paint); this.keydown += new system.windows.forms.keyeventhandler(this.form1_keydown); this.load += new system.eventhandler(this.form1_load); this.resumelayout(false); #endregion/ / the main entry point for the application./ stathreadstatic void main() application.run(new form1(); private void form1_paint(object sender, system.windows.forms.painteventargs e) graphics g = e.graphics; g.

溫馨提示

  • 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. 人人文庫網(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)論