Click here to Skip to main content
Click here to Skip to main content

Hit Ball

By , 22 Oct 2012
 

Please note

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.

Introduction

This application is a game and for fun enjoyment through gaming for Windows 8 and coded in XAML and C# .This game is based on simple concept that there is a ball having random motion through out the screen and there is two board on opposite side of the screen and player has to save the ball from being hit by two opposite surface of the screen with help of board by moving up and down through keyboard and touch. As the time will pass the speed of the ball will increase and complexity will increase and it will be tougher to play .

Screen Shots

Here are some basic features of this app

  1. Ball-there is a ball having random motion throughout the screen.
  2. Board-there are two boards which are there to save the ball from being hit by two opposite surface of the screen.
  3. Score and Miss- The score will increase by 10 if player save the ball by board and miss will increase by one if fails to save the ball.
  4. User Input- we can move board up and down through keypad as well as touch input from player.
  5. Graphics- It has custom controls and there is no image inside the game, ball and boards all are customs controls and can be adjusted in any resolution and configuration of the device.
  6. Music -there are music clips in .wav format.
  7. Complexity-as the time will pass the complexity of game as increment in speed of the ball and it will be tougher to play and save the ball after some time.

Ultrabook

This app will take advantage of Ultra book in following way:

1-Touch Support

As in ultra book there is very nice touch support and with key input and in this game same trend has been followed because the board can be moved by key input as well as by touching the both board simultaneously to save the ball. As like in ultra book both form of input are available same thing in this game is followed and it will provide the freely use of touch support of ultra book as well as key input through this game. Ultra books are Thin, light, so can be played between two players anywhere.

 

2-Accelerometer -

In this accelerometER is used in such a way that if player doesn't want to play the game through key input and touch support there is a option that player can move the board through accelerometer in such way that if player will have to tap on left hand side once and then acclerometer property will get activate for respective board and then moving up and down the ultra book board can be moved like if player want to move right board then then player have to tap to tap on right hand side once and then moving ultra book up and down player can move the board and same for left board ,in this way there is no need to play the game through touch and key input and player can play the game through accelerometer property of ultra book.

3-Ambient light sensor -

Generally it is used to check the intensity of light and according to that the visibility and readability can be switched to dark and light mode easily.                                                                                                              

In this app there is two background theme and according dark and light and dark mode they can be switched and can be set automatically like in dark mode light theme will be placed and in light mode dark theme will be placed. 

In dark mode  the display will be switched to following screen

 

 

Using the Code

this game consist of one of the some fine Win/RT properties to configure this game for windows 8 some of them are:

Function to cause calculated delays: 

public static void introduceDelay(int ms)
{
    DateTime dt1 = DateTime.Now;
    int diff = 0;

    while (diff < ms)
    {

        DateTime dt2 = DateTime.Now;
        TimeSpan ts = dt2.Subtract(dt1);
        diff = (int)ts.TotalMilliseconds;

    }
}

C# Code to intersect the ball and board is:

if (rd >= 500) 
{ 
Rect board1Rect = new Rect(Canvas.GetLeft(rightBoard), Canvas.GetTop(rightBoard), 40, 300);
Rect ballRect = new Rect(Canvas.GetLeft(mainBall), Canvas.GetTop(mainBall), 80, 80); 
board1Rect.Intersect(ballRect);
if (board1Rect.Width > 0) 
{
Score+=10; 
}
[___em_>[___em_>[___em_>

Adding custom popup in Settings Pane: 

[___em_>void App_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
   args.Request.ApplicationCommands.Add(new SettingsCommand("settings", "Options", e =>
        
    {
        MyUserControl1 mycontrol = new MyUserControl1();
        mycontrol.Width = 346;
        p = new Popup();
        p.IsLightDismissEnabled = true;
        p.SetValue(Canvas.LeftProperty, Window.Current.Bounds.Width - 346);
     
        p.Child = mycontrol;
        p.IsOpen = true;
    }));
}[___em_>

Point of Interest

The Application which are made and based on Windows 8 and WinRT API's can give their best utility for Ultra Books and can be used for Ultra Books in very efficient manner because Ultra Books have very rich properties for touch and sensor support and these API's are quiet useful in making best use of these properties. In this app have included touch support in which user can play this game just by touching both boards and they can also use key input from key board to move the boards.

Next Versions:

  1. Instead of two board 4 board can be added in future versions and then four player can play this game at a time just by saving he ball of their side just by touching the board.
  2. Timer restriction will be made in this game like if there will be 4 miss by any player then he will be out if the game.

History

  • 18/10/2012-First Entry
  • 19/10/2012-Enabled Touch Input Properties  
  • 20/10/2012-Enable Light sensing 
  • 20/10/2012-Enable Accelerometer  

License

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

About the Author

sudhanshu sp gupta
India India
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5memberTalha Naqvi23 Oct '12 - 20:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 22 Oct 2012
Article Copyright 2012 by sudhanshu sp gupta
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid