Click here to Skip to main content
15,886,518 members
Articles / Desktop Programming / WPF

Brick Ball Game : WPF C# Game

Rate me:
Please Sign up or sign in to vote.
4.98/5 (13 votes)
16 May 2014CPOL8 min read 99.7K   5.1K   30  
This is not a simple brick ball game but we need to concentrate on two balls at a time.

This article is an entry in our AppInnovation Contest. Articles in this sub-section are not required to be full articles so care should be taken when voting.

<Window x:Class="WPFGame1.Gammer" Name="myWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        WindowStyle="None"
        AllowsTransparency="True"
        ResizeMode="CanMinimize"
        Title="Duo Brick Breaker" Height="650" Width="700" KeyDown="Window_KeyDown" WindowStartupLocation="CenterScreen" Icon="/DuoBrickBreaker;component/Images/icon.ico">
    <Border BorderBrush="Black" BorderThickness="10" >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="529"></RowDefinition>
                <RowDefinition Height="40"></RowDefinition>
                <RowDefinition Height="40"></RowDefinition>
            </Grid.RowDefinitions>
            <Canvas Name="MyGameCanvas" Width="650" Height="500" Background="LightPink" Opacity="0.6">
                <Rectangle Name="rectangleRed" Width="100" Height="15" RadiusX="3" RadiusY="3" Fill="Red" Canvas.Left="0" Canvas.Top="500" Opacity="1"></Rectangle>
                <Rectangle Name="rectangleBlue" Width="100" Height="15" Fill="Blue" RadiusX="3" RadiusY="3" Canvas.Left="550" Canvas.Top="500" Opacity="1" ></Rectangle>
                <Ellipse Name="GameBallRed" Fill="{DynamicResource MyRadialGradientRed}" Width="30" Height="30" Canvas.Left="30" Canvas.Top="470" Opacity="1" />
                <Ellipse Name="GameBallBlue" Fill="{DynamicResource MyRadialGradientBlue}" Width="30" Height="30" Canvas.Left="589" Canvas.Top="470" Opacity="1"></Ellipse>
            </Canvas>
            <Canvas Grid.Row="1" Height="40" Background="Gold" Margin="10" Name="canvas1">
            </Canvas>
            <TextBlock Grid.Row="2" Text="F1:Help      F5:Play     Space:Pause" FontSize="24" Margin="5" HorizontalAlignment="Center" />
        </Grid>
    </Border>
    <Window.Resources>
        <RadialGradientBrush x:Key="MyRadialGradientRed" GradientOrigin="0.5,0.5">
            <GradientStop Color="Transparent" Offset="1"></GradientStop>
            <GradientStop Color="Red" Offset="0.8"></GradientStop>
            <GradientStop Color="Red" Offset="0.5"></GradientStop>
        </RadialGradientBrush>
        <RadialGradientBrush x:Key="MyRadialGradientBlue" GradientOrigin="0.5,0.5">
            <GradientStop Color="Transparent" Offset="1"></GradientStop>
            <GradientStop Color="Blue" Offset="0.8"></GradientStop>
            <GradientStop Color="Blue" Offset="0.5"></GradientStop>
        </RadialGradientBrush>
    </Window.Resources>
    
</Window>

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
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions