It is time to write the code for the main game loop. We have to show the characters, make them move and control the ship movement according to the keys pressed by the player.
1. Stay in the
SilverlightInvaders2DVector
project.2. Open the XAML code for
MainPage.xaml
and replace the existing code with the following (you will see a button with the title Start the game ):<UserControl x:Class="SilverlightInvaders2DVector.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/ presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="1366" Height="768" xmlns:SilverlightInvaders2D= "clr-namespace:SilverlightInvaders2DVector"> <Canvas x:Name="LayoutRoot" Background="White"> <!-- A button to start the game loop --> <Button x:Name="btnStartGame" Content="Start the game!" Canvas.Left="200" Canvas.Top="20" Width="200" Height="30" Click="btnStartGame_Click"> </Button> </Canvas> </UserControl>
3...