Flash ball vs ball game concept

This is a prototype sent me by Rory Kamminga.

It’s an unfinished game where you control a blue ball with arrow keys. Your aim is to kick a red ball out of the stage.

Obviously the red ball will try to do the same with you.

The interesting thing is that Rory took the studies of Raman Pfaff’s Physics of an Elastic Collision and its derivated tutorials such as Managing ball vs ball collision with Flash by myself and Elastic collisions by Marijn van Aerle and come out with a good prototype where the red ball is moved by AI.

That’s what Rory says:

Hi Emanuele, I’m a huge fan of your site, and I thought I’d make a contribution in the form of a concept game that’s still in its early stages.
Basically, you control the blue ball with the arrow keys and you have to knock the red ball off the edge. Clicking the mouse resets it.


I’m thinking of having several stages, including walls.
I want to have multiple AI balls, but I don’t know how.

So, if you have any clue about multiple AI balls, just give feedback.

The source code is well commented, for your understanding:

And this is the result:

Take a look, download the source code and let me know if you can turn this prototype into a blockbuster

  • David

    first post!

    interesting tutorial. are you going to make this into a game?

  • very nice idea for a game, nees some more coding however:
    when nor moving the ball after pressing the mouse butting the other ball lays on top of the other.

    ow and is it ok if i experiment with the code a little bit, maybe i can improbe it a bit =)

  • Frederik J

    Wow.. That’s addicting and nice. I’ve always wondered how the enemy, was computer controlled. Very nice, I may give it a look, when i get time, and try to understand the code. Thanks for sharing it with us.


  • Patrik TG

    Well I think that this is a better game consept then gobble, if you just would make a story and some different levels ;)

  • This will be difficult to make into a game with walls without a better way to determine a collision between a ball and a wall

  • shiv1411

    It looks like a pretty good game concept and
    still it needs some more improvements.

    Making AI for a ball….

    good concept however…!


  • @ And Mar :
    I think this is more a proof of concept. It is made to show how things can work togeter without having to make the big code things.

  • s0d4player

    This would be useful for an enemy AI.

  • oran

    why won’t it work when theres two frames?

  • sometimes if you dont hit anything the balls overlap and stop on each other with no collision.
    hopefully something you can fix.

  • David

    how would you use the existing code to allow the computer to control two balls?

  • welldone