資源簡介
2048小游戲C#源代碼,3種游戲模式,音效、背景音樂播放
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.Threading.Tasks;
using?System.Media;
using?System.IO;
using?System.Threading;
namespace?Game2048
{
????public?partial?class?Form1?:?Form
????{
????????static?int[]?table?=?new?int[4?4];
????????static?int[]?oldtable?=?new?int[104?4];
????????static?int[]?movedone;
????????static?int?flag;
????????static?int[]?dir_x?=?{?1?-1?0?0?};????//進行移動的方向
????????static?int[]?dir_y?=?{?0?0?1?-1?};
????????static?int?currentscore?=?0;
????????static?int?endcurrentscore?=?0;
????????static?int[]?oldcurrentscore?=?new?int[10];
????????static?int?highscore?=?0;
????????static?int?change;
????????private?string?filePath?=?@“HighScore.data“;
????????static?string?bgText?=?“關(guān)“;???????????//背景音樂
????????static?string?yxText?=?“關(guān)“;???????????//音效設(shè)置
????????static?string?ztText?=?“普通“;?????????//主題設(shè)置
????????static?int?closeflag?=?0;
????????static?Form3?f3?=?new?Form3();
????????static?Form6?f6?=?new?Form6();
????????static?Random?rand?=?new?Random();
????????public?Form1()
????????{
????????????InitializeComponent();
????????????InitGame();
????????????ReadHighScore();
????????????ReadCurrentScore();
????????}
????????
????????public?void?renewGame()??//結(jié)束界面后重新開始
????????{
????????????InitGame();
????????}
????????public?string?getCS()
????????{
????????????return?endcurrentscore+““;
????????}
????????public?string?getHS()
????????{
????????????return?highscore?+?““;
????????}
????????public?string?getBGState()
????????{
????????????return?bgText;
????????}
????????public?string?getYXState()
????????{
????????????return?yxText;
????????}
????????public?string?getTheme()
????????{
????????????return?ztText;
????????}
????????public?void?playYX(int?i)???//音效
????????{
????????????yxText?=?f3.getYX();
????????????if?(yxText?==?“開“)
????????????{
???????????????
????????????????
????????????????????f6.playYX(i);
????????????}
????????}
????????//初始化游戲界面?
????????private?void?InitGame()
????????{
????????????table?=?new?int[4?4];
????????????product();
????????????product();
????????????currentscore?=?0;
????????????ReadHighScore();
????????????drawTable();
????????????SaveScore(10);
????????}
????????public?void?drawTable()
????????{
????????????PictureBox[]?pb?=?new?PictureBox[4?4]
????????????{
????????????????{PB1PB2PB3PB4}
????????????????{PB5PB6PB7PB8}
????????????????{PB9PB10PB11PB12}
????????????????{PB13PB14PB15PB16}
????????????};
????????????for?(int?i?=?0;?i?4;?i++)
????????????{
????????????????for?(int?j?=?0;?j?4;?j++)
????????????????{
????????????????????setImage(pb[i?j]?table[i?j]);
????????????????}
????????????}
????????}
????????private?void?setImage(PictureBox?p?int?num)
????????{
?????????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-09?00:58??程序源代碼\
?????目錄???????????0??2017-12-09?00:31??程序源代碼\bin\
?????目錄???????????0??2017-12-09?00:33??程序源代碼\bin\Debug\
?????文件??????106576??2010-02-28?07:04??程序源代碼\bin\Debug\aqua.wav
?????文件??????114768??2010-02-28?07:04??程序源代碼\bin\Debug\aqua2.wav
?????文件???????53760??2019-03-21?14:31??程序源代碼\bin\Debug\AxInterop.WMPLib.dll
?????文件??????974928??2010-02-28?07:04??程序源代碼\bin\Debug\clap.wav
?????文件???????28752??2010-02-28?07:04??程序源代碼\bin\Debug\click.wav
?????文件???????????4??2018-11-05?16:07??程序源代碼\bin\Debug\HighScore.data
?????文件??????330752??2019-03-21?14:31??程序源代碼\bin\Debug\Interop.WMPLib.dll
?????文件????14267636??2017-12-07?13:24??程序源代碼\bin\Debug\music.wav
?????文件???????45136??2010-02-28?07:07??程序源代碼\bin\Debug\shutter.wav
?????文件??????341504??2019-03-21?17:42??程序源代碼\bin\Debug\WindowsFormsApplication2.exe
?????文件??????105984??2019-03-21?17:42??程序源代碼\bin\Debug\WindowsFormsApplication2.pdb
?????文件???????24224??2019-03-21?17:45??程序源代碼\bin\Debug\WindowsFormsApplication2.vshost.exe
?????目錄???????????0??2019-03-21?14:34??程序源代碼\bin\Release\
?????文件???????24224??2019-03-21?14:34??程序源代碼\bin\Release\WindowsFormsApplication2.vshost.exe
?????文件?????????490??2013-06-18?20:28??程序源代碼\bin\Release\WindowsFormsApplication2.vshost.exe.manifest
?????文件???????21404??2018-09-16?13:41??程序源代碼\Form1.cs
?????文件???????25768??2018-09-07?14:16??程序源代碼\Form1.Designer.cs
?????文件???????31696??2018-09-07?14:16??程序源代碼\Form1.resx
?????文件????????1196??2017-12-12?00:15??程序源代碼\Form2.cs
?????文件????????6810??2017-12-11?23:45??程序源代碼\Form2.Designer.cs
?????文件????????5817??2017-12-11?23:45??程序源代碼\Form2.resx
?????文件????????3577??2017-12-24?00:16??程序源代碼\Form3.cs
?????文件????????8001??2017-12-24?00:14??程序源代碼\Form3.Designer.cs
?????文件????????5817??2017-12-24?00:14??程序源代碼\Form3.resx
?????文件?????????711??2017-12-09?00:41??程序源代碼\Form4.cs
?????文件????????5255??2017-12-09?00:41??程序源代碼\Form4.Designer.cs
?????文件????????6632??2017-12-09?00:41??程序源代碼\Form4.resx
?????文件?????????986??2017-12-23?23:30??程序源代碼\Form5.cs
............此處省略97個文件信息
評論
共有 條評論