{"id":12075,"date":"2017-05-30T00:00:00","date_gmt":"2017-05-29T16:00:00","guid":{"rendered":"https:\/\/fgchen.com\/wpedu2\/2017\/05\/30\/%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c\/"},"modified":"2026-03-30T14:49:01","modified_gmt":"2026-03-30T06:49:01","slug":"%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2017\/05\/%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c\/","title":{"rendered":"\u3010\u7a0b\u5f0f\u8a2d\u8a08-C#\u3011\u6253\u78da\u584a\u904a\u6232 \u2013 \u52d5\u4f5c"},"content":{"rendered":"<p style=\"text-align: center\"><span style=\"font-size: 14pt\"><strong>(\u5230\u4e0a\u4e00\u7bc7<a href=\"http:\/\/wp.me\/p7SbsS-1kX\" target=\"_blank\" rel=\"noopener noreferrer\">\u3010\u7a0b\u5f0f\u8a2d\u8a08\u3011\u6253\u78da\u584a\u904a\u6232 \u2013 \u8655\u7406\u7269\u4ef6\u53ca\u756b\u9762\u7f8e\u5de5<\/a>)<\/strong><\/span><\/p>\n\n<h3>\u6253\u78da\u584a\u904a\u6232\u8a2d\u8a08\u8cc7\u6e90 (\u8acb\u6309\u4e0b\u9762\u5716\u7247)\uff1a<\/h3>\n\n<a href=\"https:\/\/www.spriters-resource.com\/search\/?q=Arkanoid\" target=\"_blank\" rel=\"noopener noreferrer\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-6223 size-full\" src=\"http:\/\/www.fgchen.com\/wp\/wp-content\/uploads\/2017\/05\/Arkanoid.png\" alt=\"\" width=\"749\" height=\"683\" \/><\/a>\n\u63a5\u4e0b\u4f86\uff0c\u5728\u9019\u500b\u6559\u5b78\u88cf\uff0c\u6211\u5011\u8981\u5be6\u73fe\u5e95\u4e0b\u904a\u6232\u52d5\u4f5c\uff1a <a href=\"http:\/\/www.fgchen.com\/wp\/wp-content\/uploads\/2017\/05\/\u6253\u78da\u584a\u904a\u623220180522.zip\" target=\"_blank\" rel=\"noopener noreferrer\">\u6253\u78da\u584a\u5c08\u6848\u6a9420180522<\/a>\n\n<ol>\n    <li><span style=\"font-size: 14pt\"><strong>\u7403\u7684\u79fb\u52d5\u53ca\u78b0\u5230\u908a\u754c\u7684\u8655\u7406<\/strong><\/span><\/li>\n    <li><span style=\"font-size: 14pt\"><strong>\u8655\u7406\u7403\u62cd\u7684\u79fb\u52d5 (\u9375\u76e4 + \u6ed1\u9f20)<\/strong><\/span><\/li>\n    <li><span style=\"font-size: 14pt\"><strong>\u7403\u62cd\u64ca\u4e2d\u7403\u7684\u5224\u65b7\u53ca\u8655\u7406<\/strong><\/span><\/li>\n    <li><span style=\"font-size: 14pt\"><strong>\u7403\u64ca\u4e2d\u78da\u584a\u7684\u5224\u65b7\u53ca\u8655\u7406<\/strong><\/span><\/li>\n    <li><span style=\"font-size: 14pt\"><strong>\u904a\u6232\u7d50\u675f\u689d\u4ef6\uff1a1\uff0e\u7403\u6389\u51fa\u4e0b\u908a\u754c\uff1b2\uff0e\u6309ESC\u9375<\/strong><\/span><\/li>\n    <li><span style=\"font-size: 14pt\"><strong>\u9032\u5165\u5230\u4e0b\u4e00\u95dc\uff1a\u64ca\u4e2d\u5168\u90e8\u78da\u584a\uff0c\u6240\u6709\u78da\u584a\u6d88\u5931\u3002(\u4f60\u6703\u600e\u9ebc\u505a\uff1f)<\/strong><\/span><\/li>\n<\/ol>\n\n\u9996\u5148\uff0c\u6211\u5011\u6240\u6709\u7684\u52d5\u4f5c\u7686\u900f\u904e\u8a08\u6642\u5668\u7269\u4ef6\u4f86\u5be6\u73fe\uff0c\u5c07\u8a08\u6642\u5668\u7269\u4ef6\u62d6\u62c9\u81f3\u7a0b\u5f0f\u4e3b\u756b\u9762\uff0c\u8a2d\u5b9ainterval\uff0c\u4f9d\u7167\u4eba\u985e\u8996\u89ba\u66ab\u7559\u7279\u6027\uff0c\u6bcf\u79d2\u53ea\u8981\u9ad8\u65bc16\u500b\u5f71\u50cf\uff0c\u770b\u8d77\u4f86\u7684\u6771\u897f\u5c31\u6703\u89ba\u5f97\u662f\u9023\u8cab\u7684\uff0c\u96fb\u5f71\u7684FPS\u70ba24\uff0c\u904a\u6232\u5247\u8981\u66f4\u9ad8\uff0c\u81f3\u5c1130\u4ee5\u4e0a\uff0c\u6240\u4ee5\uff0c\u6211\u5011\u7684\u8a08\u6642\u5668\u7684interval \u00a0= 1 \/ 40 \u00a0* 1000 = \u00a025\n\n<h2>\u4e00\u3001\u7403\u7684\u79fb\u52d5\u53ca\u78b0\u5230\u908a\u754c\u7684\u8655\u7406\u00a0<a href=\"http:\/\/www.fgchen.com\/wp\/%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c\/brickbreakout-2-1\/\" rel=\"attachment wp-att-5203\">BrickBreakout &#8211; 2 &#8211; 1<\/a><\/h2>\n\n\u7a0b\u5f0f\u4e00\u958b\u59cb\u5148\u5ba3\u544a\uff1a\n\n<pre class=\"theme:xcode lang:c# decode:true\">int X_Inc = 5, Y_Inc = 5;\n\/\/ \u6c34\u5e73\u79fb\u52d5\u589e\u91cf X_Inc (\u6b63\uff1a\u5f80\u53f3\u908a\uff0c\u8ca0\uff1a\u5f80\u5de6\u908a)\n\/\/ \u5782\u76f4\u79fb\u52d5\u589e\u91cf Y_Inc(\u6b63\uff1a\u5f80\u4e0b\u908a\uff0c\u8ca0\uff1a\u5f80\u4e0a\u9762)<\/pre>\n\n\u8a08\u6642\u5668\u7684Tick\u4e8b\u4ef6\uff1a\n\n<pre class=\"theme:xcode lang:c# decode:true\">private void timer1_Tick(object sender, EventArgs e)\n{\n    ball.Left += Y_Inc; \/\/\u6c34\u5e73\n    ball.Top += X_Inc; \/\/\u5782\u76f4\n    \/\/\u908a\u754c\u78b0\u649e\n    if (ball.Left &lt; 0 || ball.Left &gt; this.Bounds.Width) Y_Inc = -Y_Inc; \/\/\u5de6\u53f3\u908a\u754c\n    if (ball.Top &gt; this.Bounds.Height || ball.Top &lt; 0) X_Inc = -X_Inc; \/\/\u4e0a\u4e0b\u908a\u754c\n}<\/pre>\n\n<h2>\u4e8c\u3001<span style=\"font-size: 14pt\"><strong>\u8655\u7406\u7403\u62cd\u7684\u79fb\u52d5 (\u9375\u76e4 + \u6ed1\u9f20)<\/strong><\/span><\/h2>\n\n\u5728timer1\u7684Tick\u4e8b\u4ef6\u4e2d\u52a0\u5165\uff1a\n\n<pre class=\"theme:classic lang:c# mark:11-14 decode:true\">private void timer1_Tick(object sender, EventArgs e)\n{\n    \/\/\u7403\u7684\u79fb\u52d5\u8655\u7406\n    ball.Left += Y_Inc;\n    ball.Top += X_Inc;\n    \/\/\u7403\u7684\u908a\u754c\u78b0\u649e\n    if (ball.Left &lt; 0 || ball.Left &gt; this.Bounds.Width) Y_Inc = -Y_Inc; \/\/\u5de6\u53f3\u908a\u754c\n    if (ball.Top &gt; this.Bounds.Height || ball.Top &lt; 0) X_Inc = -X_Inc; \/\/\u4e0a\u4e0b\u908a\u754c\n    \/\/\u7403\u62cd\u7684\u79fb\u52d5\n    if (Cursor.Position.X &gt;= (this.Bounds.Width - racket.Width))\/\/\u5982\u679c\u6e38\u6a19\u5728\u53f3\u908a\u754c\u8655\n        racket.Left = this.Bounds.Width - racket.Width;\/\/\u6e1b\u53bb \u7403\u62cd\u7684\u6c34\u5e73\u4f4d\u7f6e\uff0c\u5426\u5247\u7684\u8a71\uff0c\u7403\u62cd\u6703\u5728\u8996\u7a97\n    else racket.Left = Cursor.Position.X; \/\/\u7403\u62cd\u7684\u6c34\u5e73\u4f4d\u7f6e = \u6e38\u6a19\u7684\u6c34\u5e73\u4f4d\u7f6e\n}<\/pre>\n\n\u9664\u4e86\u4f7f\u7528\u6ed1\u9f20\u79fb\u52d5\u6e38\u6a19\u4f86\u79fb\u52d5\u7403\u62cd\uff0c\u6211\u5011\u53e6\u5916\u6293\u53d6\u6309\u9375\u4e8b\u4ef6\u4f86\u79fb\u52d5\u7403\u62cd\uff0c\u4f5c\u6cd5\u662f\u5728Form\u8868\u55ae\u4e2d\u7684KeyDown\u4e8b\u4ef6\u6293\u53d6\u5de6\u53f3\u6309\u9375\uff1a\n\n<pre class=\"theme:classic lang:c# decode:true\">private void Form1_KeyDown(object sender, KeyEventArgs e)\n{\n    if (e.KeyCode == Keys.Left) Cursor.Position = new Point(Cursor.Position.X  - 20, Cursor.Position.Y);\n    if (e.KeyCode == Keys.Right) Cursor.Position = new Point(Cursor.Position.X + 20, Cursor.Position.Y);\n}<\/pre>\n\n<h2><span style=\"font-size: 14pt\"><strong>\u4e09\u3001\u7403\u62cd\u64ca\u4e2d\u7403\u7684\u5224\u65b7\u53ca\u8655\u7406\u00a0<a href=\"http:\/\/www.fgchen.com\/wp\/%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c\/brickbreakout-2-2\/\" rel=\"attachment wp-att-5216\">BrickBreakout &#8211; 2-2<\/a><\/strong><\/span><\/h2>\n\n<a href=\"http:\/\/www.fgchen.com\/wp\/%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c\/ball-racket-collision\/\" rel=\"attachment wp-att-5213\"><img decoding=\"async\" class=\"wp-image-5213 aligncenter\" src=\"http:\/\/www.fgchen.com\/wp\/wp-content\/uploads\/2017\/05\/Ball-Racket-collision.png\" alt=\"\" width=\"621\" height=\"400\" \/><\/a>\n\u5224\u65b7\u7403\u62cd\u662f\u5426\u64ca\u4e2d\u7403\uff0c\u4e26\u4e14\u5728\u78ba\u8a8d\u64ca\u4e2d\u4e4b\u5f8c\uff0c\u7403\u7684\u5782\u76f4\u79fb\u52d5\u65b9\u5411\u7531\u5f80\u4e0b\u8b8a\u5f80\u4e0a\u3002\n\n<pre class=\"theme:classic lang:c# mark:7-8 decode:true\">private void timer1_Tick(object sender, EventArgs e)\n{\n    \/\/\u7403\u7684\u908a\u754c\u78b0\u649e\n    if (ball.Left &lt;= 0 || ball.Left &gt;= (this.Bounds.Width - ball.Width)) X_Inc = -X_Inc; \/\/\u5de6\u53f3\u908a\u754c\n    if (ball.Top &gt;= (this.Bounds.Height - ball.Height) || ball.Top &lt;= 0) Y_Inc = -Y_Inc; \/\/\u4e0a\u4e0b\u908a\u754c\n    \/\/\u7403\u62cd\u662f\u5426\u64ca\u4e2d\u7403\uff1a\n    if (ball.Left &gt;= racket.Left &amp;&amp; ball.Left &lt;= (racket.Left + racket.Width) &amp;&amp; ball.Top &gt;= (racket.Top - ball.Height)) Y_Inc = -Y_Inc;\n    \/\/\u7403\u62cd\u7684\u79fb\u52d5\n    if (Cursor.Position.X &gt;= (this.Bounds.Width - racket.Width))\/\/\u5982\u679c\u6e38\u6a19\u5728\u53f3\u908a\u754c\u8655\n        racket.Left = this.Bounds.Width - racket.Width;\/\/\u6e1b\u53bb \u7403\u62cd\u7684\u6c34\u5e73\u4f4d\u7f6e\uff0c\u5426\u5247\u7684\u8a71\uff0c\u7403\u62cd\u6703\u5728\u8996\u7a97\n    else racket.Left = Cursor.Position.X; \/\/\u7403\u62cd\u7684\u6c34\u5e73\u4f4d\u7f6e = \u6e38\u6a19\u7684\u6c34\u5e73\u4f4d\u7f6e\n    \/\/\u7403\u79fb\u52d5\n    ball.Left += X_Inc;\n    ball.Top += Y_Inc;\n}<\/pre>\n\n\n\n<h2><span style=\"font-size: 14pt\"><strong>\u56db\u3001\u7403\u64ca\u4e2d\u78da\u584a\u7684\u5224\u65b7\u53ca\u8655\u7406\u00a0<a href=\"http:\/\/www.fgchen.com\/wp\/%e3%80%90%e7%a8%8b%e5%bc%8f%e8%a8%ad%e8%a8%88%e3%80%91%e6%89%93%e7%a3%9a%e5%a1%8a%e9%81%8a%e6%88%b2-%e5%8b%95%e4%bd%9c\/brickbreakout-2-3\/\" rel=\"attachment wp-att-5218\">BrickBreakout &#8211; 2-3<\/a><\/strong><\/span><\/h2>\n\n\u7403\u64ca\u4e2d\u78da\u584a\u7684\u5224\u65b7\u8ddf\u7403\u62cd\u662f\u5426\u64ca\u4e2d\u7403\u4f5c\u6cd5\u985e\u4f3c\uff0c\u64ca\u4e2d\u78ba\u8a8d\u5f8c\uff0c\u6211\u5011\u53ea\u9700\u8981\u5c07\u8a72\u78da\u584a\u7684Visible\u8a2d\u70bafalse\uff0c\u4f7f\u78da\u584a\u770b\u4e0d\u898b\u5c31\u597d\u4e86\uff01(\u7c21\u55ae\u5427\uff1f\uff01)\n\u7a0b\u5f0f\u5728timer1\u7684Tick\u4e8b\u4ef6\u4e2d\u52a0\u4e86\u9019\u500b\u90e8\u4efd\u7684\u8655\u7406\uff1a\n\n<pre class=\"theme:classic lang:c# decode:true\">\/\/\u4e00\u4e00\u6e2c\u8a66\u6bcf\u9846\u78da\u584a\u662f\u5426\u88ab\u7403\u64ca\u4e2d\nfor (int i = 0; i &lt; bricks.GetLength(0); i++)\n{\n    for (int j = 0; j &lt; bricks.GetLength(1); j++)\n    {\n        if (bricks[i, j].Visible == true) \/\/ \u82e5\u78da\u584a\u662f\u53ef\u898b\u7684\u8a71\u2026\uff0c\u8868\u793a\u78da\u584a\u5c1a\u672a\u88ab\u64ca\u4e2d\n        {\n            if (ball.Left &gt;= bricks[i, j].Left &amp;&amp; ball.Left &lt;= (bricks[i, j].Left + bricks[i, j].Width) &amp;&amp; ball.Top &lt;= (bricks[i, j].Top + bricks[i, j].Height))\n            {\n                Y_Inc = -Y_Inc;\n                bricks[i, j].Visible = false; \/\/\u5224\u5b9a\u64ca\u4e2d\u5f8c\uff0c\u7403\u7684\u5782\u76f4\u79fb\u52d5\u65b9\u5411\u6539\u8b8a\uff0c\u4e26\u5c07\u78da\u584a\u7684Visible\u5c6c\u6027\u8a2dfalse\uff0c\u4f7f\u5176\u770b\u4e0d\u898b\n                goto HitBrickExit; \/\/\u4e00\u65e6\u64ca\u4e2d\uff0c\u5c31\u4e0d\u7528\u6e2c\u8a66\u5176\u4ed6\u7684\u78da\u584a\u2026\uff0c\u8df3\u96e2\u9019\u500b\u6e2c\u8a66\u4ee5\u7bc0\u7701\u6642\u9593\n            }\n        }\n    }\n}\nHitBrickExit:<\/pre>\n\n\u53e6\u5916\uff0c\u518d\u52a0\u4e0a\u7403\u6389\u51fa\u4e0b\u908a\u754c\u5916\u7684\u8655\u7406\uff1a\n\n<pre class=\"theme:classic lang:c# decode:true\">\/\/\u7403\u6389\u5230\u4e0b\u908a\u754c\u5916\uff0c\u4e5f\u5c31\u662f\u7403\u62cd\u6c92\u64ca\u4e2d\u7403\u2026\uff0c\u904a\u6232\u7d50\u675f\nif (ball.Top &gt;= (this.Bounds.Height - ball.Height))\n{\n    timer1.Enabled = false; \/\/\u4e2d\u6b62\u8a08\u6642\u56681\n    lblGameOver.Visible = true; \/\/\u986f\u793a\u51fa\u904a\u6232\u7d50\u675f\u8a0a\u606f\n}<\/pre>\n\n\u518d\u52a0\u4e0a\u5e7e\u500b\u6309\u9375\u7684\u8655\u7406\uff1a\n\n<pre class=\"theme:classic lang:c# decode:true \">private void Form1_KeyDown(object sender, KeyEventArgs e)\n{\n    if (e.KeyCode == Keys.Left) Cursor.Position = new Point(Cursor.Position.X - 20, Cursor.Position.Y);\n    if (e.KeyCode == Keys.Right) Cursor.Position = new Point(Cursor.Position.X + 20, Cursor.Position.Y);\n    if (e.KeyCode == Keys.Escape) this.Close(); \/\/\u6309Esc\u96e2\u958b\u904a\u6232\n    if (e.KeyCode == Keys.F1) \/\/\u91cd\u65b0\u958b\u59cb\u904a\u6232\n    {\n        ball.Left = (this.Bounds.Width - ball.Width) \/ 2; \/\/\u7403\u4f4d\u7f6e\uff0c\u7f6e\u65bc\u8996\u7a97\u4e2d\u5fc3\n        ball.Top = (this.Bounds.Height - ball.Height) \/ 2;\n        timer1.Enabled = true; \/\/\u91cd\u65b0\u555f\u52d5\u8a08\u6642\u56681\n        lblGameOver.Visible = false; \/\/\u904a\u6232\u8a0a\u606f\u96b1\u85cf\n        place_bricsk(); \/\/\u91cd\u65b0\u6392\u5217\u6240\u6709\u7684\u78da\u584a\n    }\n}<\/pre>\n\n\u904a\u6232\u9304\u5f71\uff1a\n\n\n\n\u97f3\u6548\u7684\u8655\u7406\u8acb\u53c3\u8003\u4e0b\u4e00\u7bc7\uff1a<a href=\"http:\/\/wp.me\/p7SbsS-1ik\" target=\"_blank\" rel=\"noopener noreferrer\">\u3010\u7a0b\u5f0f\u8a2d\u8a08\u3011\u6253\u78da\u584a\u904a\u6232 \u2013 \u64ad\u653e\u80cc\u666f\u97f3\u6a02\u8207\u97f3\u6548 (\u540c\u6642)<\/a>\u3002\n\u554f\u984c\u3001\u610f\u898b\u3001\u904a\u6232\u6539\u9032\u63d0\u8b70\u7b49\u6b61\u8fce\u5728\u6587\u7ae0\u4e0b\u9762\u7684\u8ff4\u97ff\u4ea4\u6d41\u3002\u8b1d\u8b1d\u3002","protected":false},"excerpt":{"rendered":"<p>(\u5230\u4e0a\u4e00\u7bc7\u3010\u7a0b\u5f0f\u8a2d\u8a08\u3011\u6253\u78da\u584a\u904a\u6232 \u2013 \u8655\u7406\u7269\u4ef6\u53ca\u756b\u9762\u7f8e\u5de5) \u6253\u78da\u584a\u904a\u6232\u8a2d\u8a08\u8cc7\u6e90  &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[266],"tags":[150,110,143],"class_list":["post-12075","post","type-post","status-publish","format-standard","hentry","category-266","tag-brickbreakout","tag-game","tag-143"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/12075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/comments?post=12075"}],"version-history":[{"count":1,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/12075\/revisions"}],"predecessor-version":[{"id":13452,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/12075\/revisions\/13452"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=12075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=12075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=12075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}