c#拼图小游戏

这篇博客分享了一位新手开发者用C#编写的拼图小游戏的代码实现,支持用户自定义图片。博主还介绍了如何将程序打包成.msi和setup.exe安装包,并计划进一步练习算法题目。代码中包括了事件处理和图像操作,适合初学者参考学习。
摘要由CSDN通过智能技术生成

最近两天写了个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;
            }

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值