Share Your Code

Air Hockey 2 Player Game

Posted by carlos m. icaza, Posted on April 20, 2011, Last updated October 18, 2011

GitHub URL: 
https://github.com/ansca/Air-Hockey

Air Hockey is a two player game designed to show off some of the physics engine properties of Corona SDK and how with a few lines of code you can write a very addictive game. First one to score five points wins. Works seamlessly across iOS and Android devices.

Open sourced MIT Licensed. Feel free to use the code as you wish. If you decide you want to make changes or additions, feel free to do so and let us know to share with our community.


Replies

iWalter
User offline. Last seen 4 hours 48 min ago. Offline
Joined: 11 Oct 2010

How is it that the puck can pass through the center line and the paddles can't? Is is due to the collision filter?

krazyowl
User offline. Last seen 2 years 37 weeks ago. Offline
Joined: 14 Dec 2010

how do you set play against Computer mode? im not a programmer... only language I know is HTML and Somewhat PHP

naveen_pcs
User offline. Last seen 5 days 1 hour ago. Offline
Joined: 9 Apr 2011

It's supposed to be like that. Play any air hockey game and those are the rules. You can't cross the centre line with your paddle :)

iPanda Lab
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 19 Sep 2011

Hi,
I tried this sample source. It works very well when i drag first time.
But it show some of error when i touch again to drag.

-- error message.
gameUI.lua:81: attempt to call method 'removeSelf' (a nil value)
stack traceback:

i didn't' change any code. Can anyone help me!

iPanda Lab
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 19 Sep 2011

It is version problem. It works on Version 2011.632 very well.

^^

idea-factory
User offline. Last seen 8 weeks 23 hours ago. Offline
Joined: 16 Sep 2011

Hello,

Congratulations for the game. It is very nice.

One suggestion: how about AI for a new Player vs Computer version!?

Thanks,

Leonardo Opitz

sushant23.bitspilani
User offline. Last seen 2 years 9 weeks ago. Offline
Joined: 29 Jan 2012

Hey, I was working on the modified version of the game as suggested by Leonardo,, can someone please help me with the AI part?
How to get the computer to compute the best path to get to the ball?
Thanks
Sush
PS- Plz try to answer ASAP

mkelly
User offline. Last seen 5 weeks 20 hours ago. Offline
Joined: 4 Feb 2012

suh-weeeet!

FortyFourDigital
User offline. Last seen 40 weeks 2 days ago. Offline
Joined: 7 Apr 2012

The computer AI would be quite fun to code. In theory, you would need the computer to follow the y position of the puck, but with a randomness factor otherwise you would never win! The computer could return the puck and then remain stationary until the player returns in. That could trigger the computer to move its paddle.

I'd start off just making it follow the puck exactly (y pos) and then try and add "intelligence" (or lack of) to make it miss a few times. May have a go myself if other people want to share some code / ideas?

davidfioccola
User offline. Last seen 1 year 48 weeks ago. Offline
Joined: 18 May 2012

I'm new to programming and have a very basic question. Nod I just coy the entire code file into the text editor? I'm using text wrangler? Or do I need to store the images and sound son where else? Any help would be greatly appreciated.

ymucos46
User offline. Last seen 1 year 40 weeks ago. Offline
Joined: 12 Jul 2012

i love this game, so simple but can keep you busy for hours!
it's even more fun than to play checkers
i wish i had it om my knew cell

zeevwolf
User offline. Last seen 1 year 30 weeks ago. Offline
Joined: 22 Sep 2012

Hi,
I possibly could try this sample source. It's effective once i drag it the first time.
Nevertheless it show numerous error once i touch again to drag.
my blog