代码来着网络,这个拼图游戏还是有些bug的,因为很多地方没有做的很好。。
一共分为两个界面,一个是启动界面(Menus),一个为游戏界面(form)
Menus的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 拼图游戏
{
public partial class Menu : Form
{
public Menu()
{
InitializeComponent();
GamePage.img = Image.FromFile(@"F:\\拼图游戏\\拼图游戏\\Resources\\1.jpg");
Control.CheckForIllegalCrossThreadCalls = false;
}
private void button1_Click_1(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
GamePage.dif = puzzle.Diff.ordinary;
this.Hide();
Form1 ff = new Form1();
ff.closefather += new 拼图游戏.Form1.childclose(this.closethis);
ff.Show();
}
private void button3_Click(object sender, EventArgs e)
{
GamePage.dif = puzzle.Diff.difficulty;
this.Hide();
Form1 ff = new Form1();
ff.closefather += new 拼图游戏.Form1.childclose(this.closethis);
ff.Show();
}
public void closethis()
{
this.Show();
}
private void button4_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog();
GamePage.img = Image.FromFile(ofd.FileName).GetThumbnailImage(600, 600, new Image.GetThumbnailImageAbort(delegate { return false; }), IntPtr.Zero);
}
private void Menu_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
GamePage.dif = puzzle.Diff.simple;
this.Hide();
Form1 ff = new Form1();
ff.closefather += new 拼图游戏.Form1.childclose(this.closethis);
ff.Show();
}
}
}
form代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 拼图游戏
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private puzzle puzzle;
private int Num = 0;
private Image img;