This article covers the creation of maze game, following it from a text file to a WPF, going through all the WPF animations involved with the game, as well as the non WPF animations, made by switching between differnt configurations. The article also covers how input corresponds to cell coordinates, utilizes the A* Search algorithm for the enemies, and goes over the implementation of the music for the game, which involves two sound engines, Midi Toolkit and IrrKlang.
- SnailQuest_EXE.zip
- Images
- Bob.png
- irrKlang.NET4.dll
- Mazes
- Midis
- km_crystal.mid
- km_ending.mid
- km_enemy1.mid
- km_enemy2.mid
- km_gameover.mid
- km_opstage1.mid
- km_stage1.mid
- km_stage2.mid
- km_start.mid
- Sanford.Collections.dll
- Sanford.Multimedia.dll
- Sanford.Multimedia.Midi.WPF.dll
- Sanford.Multimedia.Midi.WPF.pdb
- Sanford.Multimedia.Timers.dll
- Sanford.Threading.dll
- SnailQuest.exe
- SnailQuest.pdb
- SnailQuest.vshost.exe
- Sounds
- bjp.wav
- boomerang.wav
- bulle.wav
- intro.mp3
- quit.wav
- Reload.mp3
- Reload.wav
- SubPing02.wav
- swosh.flac
- waterdrop.wav
- SnailQuest_SRC.zip
- SnailQuest.sln
- SnailQuest
- App.xaml
- App.xaml.cs
- Assemblies
- irrKlang.NET4.dll
- Sanford.Collections.dll
- Sanford.Multimedia.dll
- Sanford.Multimedia.Midi.WPF.dll
- Sanford.Multimedia.Timers.dll
- Sanford.Threading.dll
- Controls
- Images
- Bob.png
- MainWindow.xaml
- MainWindow.xaml.cs
- Mazes
- MidiHelper.cs
- Midis
- km_crystal.mid
- km_ending.mid
- km_enemy1.mid
- km_enemy2.mid
- km_gameover.mid
- km_opstage1.mid
- km_stage1.mid
- km_stage2.mid
- km_start.mid
- Properties
- SnailQuest.csproj
- SnailQuest.csproj.user
- Sounds
- bjp.wav
- boomerang.wav
- bulle.wav
- intro.mp3
- quit.wav
- Reload.mp3
- Reload.wav
- SubPing02.wav
- swosh.flac
- waterdrop.wav
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace SnailQuest.Controls
{
/// <summary>
/// Interaction logic for Pearl.xaml
/// </summary>
public partial class Pearl : UserControl
{
int animationMs = 300;
const int cellWidth = 60;
private int squidX = 2;
private int squidY = 2;
const int mazeWidth = 15;
const int mazeHeight = 10;
public Pearl()
{
InitializeComponent();
}
public Point GetCellPoint()
{
var left = (double)this.GetValue(Canvas.LeftProperty);
var top = (double)this.GetValue(Canvas.TopProperty);
var squidX = (int)(left) / cellWidth;
var squidY = (int)(top) / cellWidth;
return new Point(squidX, squidY);
}
public Rect GetRect(Canvas canvas)
{
GeneralTransform transform = this.TransformToVisual(canvas);
return transform.TransformBounds(new Rect(0, 0, this.ActualWidth, this.ActualHeight));
}
public void PlaceAt(Point cellPoint)
{
this.Visibility = System.Windows.Visibility.Visible;
var leftAnimation = new DoubleAnimation()
{
From = cellPoint.X * cellWidth + 15,
To = cellPoint.X * cellWidth + 15,
Duration = TimeSpan.FromMilliseconds(0),
};
var topAnimation = new DoubleAnimation()
{
From = cellPoint.Y * cellWidth + 15,
To = cellPoint.Y * cellWidth + 15,
Duration = TimeSpan.FromMilliseconds(0),
};
Storyboard.SetTarget(leftAnimation, this);
Storyboard.SetTargetProperty(leftAnimation, new PropertyPath("(Canvas.Left)"));
Storyboard.SetTarget(topAnimation, this);
Storyboard.SetTargetProperty(topAnimation, new PropertyPath("(Canvas.Top)"));
var sb = new Storyboard();
sb.Children.Add(leftAnimation);
sb.Children.Add(topAnimation);
sb.Begin();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.