拼图的EXE文件
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
拼图 原创 游戏 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; namespace WindowsFormsApplication1 { public partial class Form1 : Form { Random r = new Random();//随机种子 Point pi = new Point();//出界返回 Point[] pt = new Point[8];//判断胜负 string[] st = new string[8];//判断胜负 public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { pictureBox1.Left -= 800; tianjia(); panduan(); } void tianjia()//添加图片 { string si;//获取坐标 int i = 7;//图片数量 int n = 0;//变量 string[] s = { "000000", "000100", "000200", "100000", "100100", "100200", "200000", "200100"}; ComboBox cb = new ComboBox(); ComboBox cc = new ComboBox(); cb.Items.AddRange(s);//确定坐标 cc.Items.AddRange(s);//确定图像 for (n = 0; n < 8; n++) { PictureBox p = new PictureBox();//创建拼图 p.Name = "i" + i; p.Size = new Size(100, 100); p.BackColor = Color.Red; si = cb.Items[r.Next(0,i)].ToString();//打乱拼图坐标 p.Location = new Point(Convert.ToInt32(si) / 1000, Convert.ToInt32(si) % 1000); cb.Items.Remove(si); Bitmap bit = new Bitmap(99, 99);//给拼图添加背景图片 Graphics g = Graphics.FromImage(bit); g.DrawImageUnscaled(pictureBox1.Image, -Convert.ToInt32(cc.Items[i]) / 1000, -Convert.ToInt32(cc.Items[i]) % 1000); p.Image = bit; Controls.Add(p);//把拼图画到窗体上 pt[n] = new Point(Convert.ToInt32(cc.Items[i]) / 1000, Convert.ToInt32(cc.Items[i]) % 1000); st[n] = p.Name; i--; } } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { pi = pictureBox2.Location; string key = e.KeyChar.ToString(); switch (key)//图片移动 { case "w": pictureBox2 .Top -= 100; break; case "s": pictureBox2.Top += 100; break; case "a": pictureBox2.Left -= 100; break; case "d": pictureBox2.Left += 100; break; } if (pictureBox2.Location.X < 0 || pictureBox2.Location.X > 200 || pictureBox2.Location.Y < 0 || pictureBox2.Location.Y > 200) pictureBox2.Location = pi;//判断出界 foreach (Control i in Controls)//反向移动 if (i.Location == pictureBox2.Location&&i.Name!="pictureBox2") { switch (key) { case "w": i.Top += 100; break; case "s": i.Top -= 100; break; case "a": i.Left += 100; break; case "d": i.Left -= 100; break; } } panduan(); } void panduan() { int ai = 0; for (int n = 0; n < 8; n++) foreach (Control i in Controls) if (i.Name == st[n] && i.Location == pt[n]) ai++; label1.Text = ai.ToString(); if (ai == 8) { MessageBox.Show("恭喜你,通关了"); Close(); } } private void button1_Click(object sender, EventArgs e) { if (pictureBox1.Location.X == -800) pictureBox1.Left += 800; else pictureBox1.Left -= 800; } } }
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-dosexec](https://img-home.csdnimg.cn/images/20210720083343.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
- 1
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/121cca16ef90491d878089750fed037d_woshileer02.jpg!1)
- 粉丝: 2
- 资源: 3
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)