做出一个小游戏,多长时间?你们老师也挺有创意啊,二维数组编辑地图,楼主可以参考数据结构中图的算法实现,其实核心就是这个,别的有兴趣大家可以一起研究!
namespace MapEditor
{
public partial class Form1 : Form
{
private int picContent = 0;
private Point currentPoint;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void panel1_Click(object sender, EventArgs e)
{
}
private void panel1_MouseClick(object sender, MouseEventArgs e)
{
int xPoint = e.Location.X/50 ;
int yPoint = e.Location.Y /50;
currentPoint = new Point(xPoint*50 , yPoint*50);
PictureBox tmpPic = new PictureBox();
tmpPic.Size = new Size(50, 50);
tmpPic.BorderStyle = BorderStyle.None;
tmpPic.Location = currentPoint;
tmpPic.SizeMode = PictureBoxSizeMode.StretchImage;
tmpPic.Margin = new Padding(0);
if (picContent == 0)
{
tmpPic.Image = MapEditor.Properties.Resources.Route;
}
if (picContent == 1)
{
tmpPic.Image = MapEditor.Properties.Resources.backgroundImage;
}
this.panel1.Controls.Add(tmpPic);
}
private void pictureBox3_Click(object sender, EventArgs e)
{
this.picContent = 1;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.picContent = 0;
}
private void button1_Click(object sender, EventArgs e)
{
Graphics g = this.panel1.CreateGraphics();
Bitmap bmp = new Bitmap(550, 550);
// g.DrawImage(bmp, 550, 550);
this.panel1.DrawToBitmap(bmp, new Rectangle(0,0,550,550));
if (File.Exists(@"D:\1.jpg&qu