Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Ultraping Paddle Game

0.00/5 (No votes)
4 Jun 2013 1  
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 

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.  

 

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:

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here