最近两天写了个c#的拼图小游戏,支持用户用自己的图片,以下是代码
新手所以比较简陋,美化的相关还没学,以下是源代码,新手可以看一下
顺带学了下打包成安装包.msi 和setup.exe虽然中间也遇到了问题,但最后也都解决了
准备最近再练练算法的题,迷宫,acm什么的
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 Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int succ = 0;
private void Form1_Paint(object sender, PaintEventArgs e) //初学gdi绘图的小代码
{
//Graphics g = e.Graphics;
//Pen p = new Pen(Color.Black, 1);
//g.DrawLine(p, 10, 10, 100, 100);
//g.DrawRectangle(p, 10, 10, 100, 100);
//g.DrawEllipse(p, 10, 10, 100, 100);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if ((pictureBox1.Location.Y == pictureBox9.Location.Y && pictureBox1.Location.X == pictureBox9.Location.X + 100) || (pictureBox1.Location.Y == pictureBox9.Location.Y && pictureBox1.Location.X == pictureBox9.Location.X - 100) || (pictureBox1.Location.X == pictureBox9.Location.X && pictureBox1.Location.Y == pictureBox9.Location.Y - 100) || (pictureBox1.Location.X == pictureBox9.Location.X && pictureBox1.Location.Y == pictureBox9.Location.Y + 100))
{
Point p = pictureBox9.Location;
pictureBox9.Location = pictureBox1.Location;
pictureBox1.Location = p;
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
if ((pictureBox2.Location.Y == pictureBox9.Location.Y && pictureBox2.Location.X == pictureBox9.Location.X + 100) || (pictureBox2.Location.Y == pictureBox9.Location.Y && pictureBox2.Location.X == pictureBox9.Location.X - 100) || (pictureBox2.Location.X == pictureBox9.Location.X && pictureBox2.Location.Y == pictureBox9.Location.Y - 100) || (pictureBox2.Location.X == pictureBox9.Location.X && pictureBox2.Location.Y == pictureBox9.Location.Y + 100))
{
Point p = pictureBox9.Location;
pictureBox9.Location = pictureBox2.Location;
pictureBox2.Location = p;
}
}
private void pictureBox3_Click(object sender, EventArgs e)
{
if ((pictureBox3.Location.Y == pictureBox9.Location.Y && pictureBox3.Location.X == pictureBox9.Location.X + 100) || (pictureBox3.Location.Y == pictureBox9.Location.Y && pictureBox3.Location.X == pictureBox9.Location.X - 100) || (pictureBox3.Location.X == pictureBox9.Location.X && pictureBox3.Location.Y == pictureBox9.Location.Y - 100) || (pictureBox3.Location.X == pictureBox9.Location.X && pictureBox3.Location.Y == pictureBox9.Location.Y + 100))
{
Point p = pictureBox9.Location;
pictureBox9.Location = pictureBox3.Location;
pictureBox3.Location = p;
}
}
private void pictureBox4_Click(object sender, EventArgs e)
{
if ((pictureBox4.Location.Y == pictureBox9.Location.Y && pictureBox4.Location.X == pictureBox9.Location.X + 100) || (pictureBox4.Location.Y == pictureBox9.Location.Y && pictureBox4.Location.X == pictureBox9.Location.X - 100) || (pictureBox4.Location.X == pictureBox9.Location.X && pictureBox4.Location.Y == pictureBox9.Location.Y - 100) || (pictureBox4.Location.X == pictureBox9.Location.X && pictureBox4.Location.Y == pictureBox9.Location.Y + 100))
{
Point p = pictureBox9.Location;
pictureBox9.Location = pictureBox4.Location;
pictureBox4.Location = p;
}