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 SplashScreen.xaml
/// </summary>
public partial class SplashScreen : UserControl
{
List<Ellipse> bubbles = new List<Ellipse>();
List<Storyboard> storyBoards = new List<Storyboard>();
TimeSpan ts = TimeSpan.FromMilliseconds(3000);
public SplashScreen()
{
InitializeComponent();
CreateBubbles();
}
private void CreateBubbles()
{
Storyboard sbPressSpace = this.FindResource("sbPressSpace") as Storyboard;
sbPressSpace.Begin();
var linearBubbleBrush = new LinearGradientBrush() { StartPoint = new Point(1, 0), EndPoint = new Point(0, 1) };
linearBubbleBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0x00, 0x20, 0x40), 0.0));
linearBubbleBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0xFF, 0xFF, 0xFF), 1.0));
var radialBubbleBrush = new RadialGradientBrush() { Center = new Point(0.25, 0.75), RadiusX = .3, RadiusY = .2, GradientOrigin = new Point(0.35, 0.75) };
radialBubbleBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF), 0.0));
radialBubbleBrush.GradientStops.Add(new GradientStop(Color.FromArgb(0x00, 0xFF, 0xFF, 0xFF), 1.0));
for (var i = 0; i < 10; i++)
{
var diameter = 10 + (i % 4) * 10;
var ms = 1000 + i % 7 * 500;
var ellBubble = new Ellipse()
{
Width = diameter,
Height = diameter,
Stroke = linearBubbleBrush,
Fill = radialBubbleBrush,
StrokeThickness = 3
};
ellBubble.SetValue(Canvas.LeftProperty, i * (40.0 + 40.0 - diameter / 2));
ellBubble.SetValue(Canvas.TopProperty, 0.0 + 40.0 - diameter / 2);
cnvBubbles.Children.Add(ellBubble);
var leftAnimation = new DoubleAnimation()
{
From = 40.0 * i,
To = 40.0 * i,
Duration = TimeSpan.FromMilliseconds(ms)
};
var topAnimation = new DoubleAnimation()
{
From = 200,
To = 0,
Duration = TimeSpan.FromMilliseconds(ms)
};
var opacityAnimation = new DoubleAnimation()
{
From = 1.0,
To = 0.0,
Duration = TimeSpan.FromMilliseconds(ms)
};
Storyboard.SetTarget(leftAnimation, ellBubble);
Storyboard.SetTargetProperty(leftAnimation, new PropertyPath("(Canvas.Left)"));
Storyboard.SetTarget(topAnimation, ellBubble);
Storyboard.SetTargetProperty(topAnimation, new PropertyPath("(Canvas.Top)"));
Storyboard.SetTarget(opacityAnimation, ellBubble);
Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity"));
leftAnimation.EasingFunction = new BackEase() { Amplitude = 0.5, EasingMode = EasingMode.EaseOut };
topAnimation.EasingFunction = new BackEase() { Amplitude = 0.5, EasingMode = EasingMode.EaseOut };
var sb = new Storyboard();
sb.Children.Add(leftAnimation);
sb.Children.Add(topAnimation);
sb.Children.Add(opacityAnimation);
sb.RepeatBehavior = RepeatBehavior.Forever;
bubbles.Add(ellBubble);
storyBoards.Add(sb);
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.