日期:2014-05-18 浏览次数:20824 次
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace Maze { public partial class Form1 : Form { public Form1() { //This SoundPlayer plays a sound whenever the player hits a wall. System.Media.SoundPlayer startSoundPlayer = new System.Media.SoundPlayer(@"E:\KwDownload\song\Jimi Hendrix-Voodoo Chile Blues.mp3"); // This SoundPlayer plays a sound when the player finishes the game. System.Media.SoundPlayer finishSoundPlayer = new System.Media.SoundPlayer(@"E:\KwDownload\song\Jimi Hendrix-Red House.mp3"); InitializeComponent(); MoveToStart(); } private void finishLabel_MouseEnter(object sender, EventArgs e) { //Show a congratulatory Messagebox,then close the form MessageBox.Show("Congratulations!"); Close(); } /// <summary> /// Move the pointer to a point 10 pixels down and to the right /// of the starting point in the upper-left corner of the maze. /// Play a sound, then move the mouse pointer to a point 10 pixels down and to /// the right of the starting point in the upper-left corner of the maze. /// </summary> private void MoveToStart() { [color=#FF0000] startSoundPlayer.Play();[/color] Point startingPoint = panel1.Location; startingPoint.Offset(10,10); Cursor.Position = PointToScreen(startingPoint); } private void wall_MouseEnter(object sender, EventArgs e) { // When the mouse pointer hits a wall or enters the panel, // call the MoveToStart() method. MoveToStart(); } } }