Click here to Skip to main content
15,867,330 members
Articles / Programming Languages / Javascript

Ultraping Paddle Game

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
4 Jun 2013CPOL2 min read 14.5K   2   4
Paddle-Ball multiplayer multitouch game for Ultrabooks.

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  

You know Pong and Breakout, you love those games and you have the new Ultrabook, so here is a multitouch paddle game you can play with your friends.

Windows 8 Game / Desktop App / AIR for Ultrabooks 

Image 1

Thoughts  

Thinking about using multitouch features of the Ultrabook I ask myself, what would I want to see on an Ultrabook. A game that makes more fun with touching a screen than using multiple keys on a board. Or which needs more than one mouse. 

Gameplay 

Using two fingers in the marked area on the left for the left player and using two fingers in the right area for the second player. The paddle will have a fit size (when using no items maybe later in the game). If the puck  / ball touches the barrier on the sides, the player who is not on this side will get a point. Till how many points you want to play you can chose yourself.   

Why you should use it on an Ultrabook?    

Using keyboard keys wouldn't give you the flexibility of turning your paddle around in any angle. With the high performance of the Ultrabook I also can more graphic effects like particles or other features in the future without having the anger of slowing down. 

How does it works? 

Two  fingers on each side in the marked area. So I bounded the area for the touch events.   

If now touch event is in the area or more than two, the paddle will have a default position. If there is only one touch event in the area, the paddle will have a fixed angle. And if using two fingers in the area which gives two touch events in this area, a draw a imaginary line between these two touch-points. The paddle center is placed between the two touch-points and the  angle of the paddle is the angle of the imaginary line to one side of the hole field.  

Image 2 

I am using Flash Action Script 3.0 AIR 3.4 for Desktops   

Using the code 

TouchEvent

So multitouch is like using drag and drop events.

Sample code:

C#
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

paddle_ball_1.addEventListener(TouchEvent.TOUCH_BEGIN, fl_TouchBeginHandler);
paddle_ball_1.addEventListener(TouchEvent.TOUCH_END, fl_TouchEndHandler);

var fl_DragBounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);

function fl_TouchBeginHandler(event:TouchEvent):void
{
    event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
}

function fl_TouchEndHandler(event:TouchEvent):void
{
    event.target.stopTouchDrag(event.touchPointID);    
}

Game and Physics Engine 

For the game I am using no special engine. But for the physics I choose Box2D. It's simple to use and well documented.  

History  

1.0 Initial release  

1.1 bugfixes where I lost letters in the text 

License

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


Written By
Software Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Fabse_net23-Oct-12 2:50
Fabse_net23-Oct-12 2:50 
GeneralMy vote of 5 Pin
Den205023-Oct-12 1:35
Den205023-Oct-12 1:35 
GeneralRe: My vote of 5 Pin
Folker_23-Oct-12 1:47
Folker_23-Oct-12 1:47 
GeneralRe: My vote of 5 Pin
Den205023-Oct-12 4:08
Den205023-Oct-12 4:08 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.