Click here to Skip to main content
15,892,927 members
Articles / Desktop Programming / WPF

Snail Quest - A Maze Game Using WPF, A* Search Algorithm, C# Midi Toolkit and Irrklang Audio Engine

Rate me:
Please Sign up or sign in to vote.
4.99/5 (68 votes)
7 Apr 2011CPOL12 min read 143K   4.1K   103  
This article covers the creation of maze game all the way from its WPF animations to its music integration with two sound engines.
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.
<UserControl x:Class="SnailQuest.Controls.Starfish"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="30" d:DesignWidth="30">
    <UserControl.Resources>
        <Storyboard x:Key="sbRotate" x:Uid="sbRotate" Duration="0:0:0.250" RepeatBehavior="Forever">
            <DoubleAnimation Storyboard.TargetName="rotateTransform" Storyboard.TargetProperty="Angle" From="0" To="360"/>
        </Storyboard>
    </UserControl.Resources>
    <Grid>
        <Path StrokeEndLineCap="Round" StrokeStartLineCap="Round" StrokeLineJoin="Round" StrokeThickness="2" Fill="DarkRed"
              Data="M11,16 L4,10 L13,13 L16,2 L17,14 L27,13 L18,18 L20,28 L14,19 L4,25 L11,16">
            <Path.Stroke>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0.0" Color="Red"/>
                    <GradientStop Offset="0.3" Color="Red"/>
                    <!--<GradientStop Offset="1.0" Color="#FF000000"/>-->
                </LinearGradientBrush>
            </Path.Stroke>
        </Path>
        <Path StrokeEndLineCap="Round" StrokeStartLineCap="Round" StrokeLineJoin="Round" StrokeDashCap="Round" StrokeThickness="3" Stroke="DarkRed"
              Data="M15,15 L4,10 L15,15 L16,2 L15,15 L27,13 L15,15 L20,28 L15,15 L4,25 L15,15">
        </Path>
        <Path StrokeEndLineCap="Round" StrokeStartLineCap="Round" StrokeLineJoin="Round" StrokeDashArray="1,3" StrokeDashCap="Round" StrokeThickness="1" Fill="Red"
              Data="M15,15 L4,10 L15,15 L16,2 L15,15 L27,13 L15,15 L20,28 L15,15 L4,25 L15,15">
            <Path.Stroke>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                    <GradientStop Offset="0.0" Color="#FFFFFFFF"/>
                    <GradientStop Offset="1.0" Color="#FFFFFFFF"/>
                </LinearGradientBrush>
            </Path.Stroke>
        </Path>
        <Grid.RenderTransform>
            <TransformGroup>
                <RotateTransform x:Name="rotateTransform" Angle="0.0" CenterX="15" CenterY="15"/>
                <ScaleTransform x:Name="scaleTransform" ScaleX="1" ScaleY="1" CenterX="15" CenterY="15"/>
            </TransformGroup>
        </Grid.RenderTransform>
    </Grid>
</UserControl>

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer Alura Cursos Online
Brazil Brazil

Comments and Discussions