迷宫游戏
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Media;
using System.Windows.Forms;
namespace Maze迷宫
{
    public partial class Form1 : Form
    {
        //当鼠标指针碰到墙壁时,播放出声音
        SoundPlayer startSoundplayer = new SoundPlayer(@"C:\windows\Media\chord.wav");
        //当鼠标到达终点,播放声音
        private SoundPlayer finishSoundPlayer = new SoundPlayer(@"C:\windows\Media\tada.wav"); 
        public Form1()
        {
            InitializeComponent();
            //游戏开始时。鼠标之争放置在开始位置
 
            MoveToStart();
        }
        /// <summary>
        /// 鼠标到达出口,播放声音,显示祝贺说明
        /// </summary>
        private void finishlabel_MouseEnter(object sender, EventArgs e)
        {
            finishSoundPlayer.Play();
            // show a congratulatory MessageBox, then close the from.
            MessageBox.Show("Congratulations!祝贺","游戏过关提示");
            Close();
  
        }
        /// <summary>
        /// 找到适用于迷宫的指针起始点
        /// </summary>
        public void MoveToStart()
        {
            startSoundplayer.Play();
            Point startingPoint = panel1.Location;
            startingPoint.Offset(15,15);
            Cursor.Position = PointToScreen(startingPoint);
          
        }
        private void wall_MouseEnter(object sender, EventArgs e)
        {
            //鼠标指针返回起点
            MoveToStart();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
    }
}
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号