Can it be use for a Surface game ?

Jan 16, 2012 at 5:09 PM

Dear all,

I am building Surface application for my customers and one of them ask me to build a small game for his customers.
First I was thinking of a famous multiplayer hair Hockey or  small brik wall.

Trickiy part is the collision of element of course.
For instance for Air hokey, player pas can be nothing else than custom scatterViewItems and then the Puck is the central point where coision should be handle between player pad.

Do this library can be easily implemented for such small game ?

An other exemple project I have in mind a multiplyer brick wall, where when the brick is hit with the ball then it should desapears.

Does all this can be done with this library ?

Any sample for that case ?

regards

serge

Coordinator
Jan 18, 2012 at 7:22 PM

Xaml Physics will work in s surface application. Just be sure to use TouchDrag instead of MouseDrag to enable dragging elements.

There is a sample that shows you have to handle collision events. You can view it here http://xamlphysics.codeplex.com/SourceControl/changeset/view/11278#121124

Also there was a discussion on how to add and remove bodies at run time a while ago here http://xamlphysics.codeplex.com/discussions/266634

Jan 19, 2012 at 5:49 AM
Edited Jan 19, 2012 at 5:51 AM

SergeCalderara , Liserdarts doo and awesome job!
Make a game like the 2 players classic pong is possible in extreme easy way.
Can be developed with this lib in just few minutes is extreme easy !!
I plan use the lib for specific thing i need, but i plan soon try create dual layer  pong game just for fun : )


Jan 19, 2012 at 6:56 AM

GrobotoX, If it really takes few minutes can you show be a small sample of those basic pong ? either I am stupid or blind but could not find the right way

Jan 19, 2012 at 7:43 AM
Edited Jan 19, 2012 at 7:50 AM

I cant do right now due I  stay ultra bussy, but if you can wait one week or less, yes, i can do very basic and you can see how easy can be.
I can do this over the weekend, very ultra basic but working example.

I code in C#  is ok for you?

If not I can create the basic on xaml and you can complete the code in visualbasic or any .net you use.

Jan 19, 2012 at 8:05 AM

I send something in few minutes  :  )

Jan 19, 2012 at 8:24 AM

Yes I am using C#

Thnaks for your help anyway

serge

Jan 19, 2012 at 8:45 AM
Edited Jan 19, 2012 at 9:01 AM

I know this no is a complete game but is the basic of how the lib work. I don't know why some times the ball when go to border not bounce and only roll from the border. Liserdarts can explain why when he have some free time.
Solving that problem you can start from here.

You can start from here :)
I plan build a complete 2 players game very soon, right now not have free time.

<Window
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:physics="clr-namespace:XamlPhysics.WPF;assembly=XamlPhysics.WPF"

      
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  x:Class="test.MainWindow"
        WindowStyle="None" WindowStartupLocation="CenterScreen"
        Title="MainWindow" Height="600" Width="1024" Loaded="Window_Loaded">





    <Grid Margin="-7.962,-8.005,-8.038,-7.995" Background="Black">
        <Rectangle Fill="#FFF4F4F5" Margin="497.208,0,0,0" Stroke="Black" HorizontalAlignment="Left" Width="10.855" Opacity="0.425"/>
        <physics:PhysicalBox x:Name="UxBox" Width="1024" Margin="0,0,0,8" >
            <physics:PhysicalBox.Clock>
                <physics:GameLoop />
            </physics:PhysicalBox.Clock>
            
            <physics:TouchDrag Width="1024" Height="600" OpacityMask="White">
                    <Ellipse Canvas.Left="209.117" Canvas.Top="169.302" Fill="#FF71FF00" Height="47" x:Name="ellipse1" Stroke="Black" Width="47" SourceUpdated="ellipse1_SourceUpdated" >
                        <physics:PhysicalBox.Body>
                            <physics:CircleBody IgnoreGravity="True" />
                        </physics:PhysicalBox.Body>
                    </Ellipse>
                    <Rectangle Canvas.Top="-0.018" Width="1016" Height="8.748" Fill="White" OpacityMask="White">
                    	<physics:PhysicalBox.Body>
                        <physics:RectangleBody IgnoreGravity="True" IsStatic="True"  />
                    	</physics:PhysicalBox.Body>
                    </Rectangle>
                    <Rectangle Canvas.Top="590.906" Width="1016" Height="8.748" Fill="White" OpacityMask="White">
                    	<physics:PhysicalBox.Body>
                    		<physics:RectangleBody IgnoreGravity="True" IsStatic="True"  />
                    	</physics:PhysicalBox.Body>
                    </Rectangle>
                    <Ellipse Canvas.Left="18.892" Canvas.Top="239.386" Fill="Black" Height="122.088" x:Name="stick1" Stroke="White" Width="122.088" SourceUpdated="ellipse1_SourceUpdated" StrokeThickness="7" >
                    	<physics:PhysicalBox.Body>
                    		<physics:CircleBody IgnoreGravity="True" />
                    	</physics:PhysicalBox.Body>
                    </Ellipse>
                    <Ellipse Canvas.Left="859.876" Canvas.Top="239.386" Fill="Black" Height="122.088" x:Name="stick2" Stroke="White" Width="122.088" SourceUpdated="ellipse1_SourceUpdated" StrokeThickness="7" >
                    	<physics:PhysicalBox.Body>
                    		<physics:CircleBody IgnoreGravity="True" />
                    	</physics:PhysicalBox.Body>
                    </Ellipse>
            </physics:TouchDrag>
        </physics:PhysicalBox>
    </Grid>




</Window>


Jan 19, 2012 at 9:03 AM

All what you need is fire collision event when the ball touch some black hidden rectangle in the back of CIRCULAR STICKS, just locate 2 rectangles and turn static, and fire collision event form that objects.


You can use that for create punctuation, make ball disappear, and create a new ball.

Thats if im not wrong........you have your game : )

Jan 19, 2012 at 11:46 AM
Edited Jan 25, 2012 at 9:44 PM

Thanks,

I have give a try to what you mention but I am not able to move any element, anything wrong ?

An other thing is that TouchDrag is not define in the assembly !!!!

regards

serge

Feb 9, 2012 at 3:36 PM

A new TouchDrag class is coming. Also a TagDrag Class specifically for Surface. I already made an airhockey game for Surface here: http://pinpoint.microsoft.com/en-GB/applications/lizards-airhockey-surface-2-windows-7-touch-12884926177

I think the old TouchDrag is in this discussion group somewhere...

Coordinator
Feb 10, 2012 at 11:00 PM

TouchDrag has not been part of a release yet but it is in the source.

http://xamlphysics.codeplex.com/SourceControl/changeset/view/11278#112255

It will be part of 0.7 when it comes out.