BallPusher: new Flash game prototype

Here it is another fresh Flash game prototype by FrozenHaddock, that jumps from the forum to the blog. FrozenHaddock was playing around with Flash as he says, when he come out with an interesting prototype.

Something I was fiddling about with, might work well as a puzzle game of some
sort. Some people might find it interesting :)

I found it very interesting... and probably I'll turn it into a complete one-day game.

In this prototype actionscript is not in a single frame but every object has its own code.

This is the code for the pusher (that's not a drug dealer in this case)

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     rad = 100;
  3.     r = 15;
  4. }
  5. onClipEvent (enterFrame) {
  6.     xdis = (this._x-_root._xmouse);
  7.     ydis = (this._y-_root._ymouse);
  8.     distance = Math.sqrt((xdis*xdis)+(ydis*ydis));
  9.     this._x = _root._xmouse += xdis/distance*rad;
  10.     this._y = _root._ymouse += ydis/distance*rad;
  11.     angle = Math.atan2(ydis, xdis);
  12.     this._rotation = angle*57.2957795;
  13.     for (i=0; i<5; i++) {
  14.         bi = _root["b"+i];
  15.         bi.r = (_root["b"+i]._width)/2;
  16.         xbidis = _root["b"+i]._x-this._x;
  17.         ybidis = _root["b"+i]._y-this._y;
  18.         bidis = Math.sqrt((xbidis*xbidis)+(ybidis*ybidis));
  19.         if (bidis<(this.r+bi.r)) {
  20.             force = bidis-(r+bi.r);
  21.             _root["b"+i]._x -= xbidis/bidis*force;
  22.             _root["b"+i]._y -= ybidis/bidis*force;
  23.         }
  24.     }
  25. }

While every ball has this code

ACTIONSCRIPT:
  1. onClipEvent (load) {
  2.     r = this._width/2;
  3.     this._x = random(400)+50;
  4.     this._y = random(300)+50;
  5. }
  6. onClipEvent (enterFrame) {
  7.     for (i=0; i<5; i++) {
  8.         bi = _root["b"+i];
  9.         bi.r = (_root["b"+i]._width)/2;
  10.         xbidis = _root["b"+i]._x-this._x;
  11.         ybidis = _root["b"+i]._y-this._y;
  12.         bidis = Math.sqrt((xbidis*xbidis)+(ybidis*ybidis));
  13.         if (bidis<(this.r+bi.r) && bidist != 0 && this.r>=bi.r && !_root["b"+i].hitTest(_root.pusher.inner)) {
  14.             force = bidis-(r+bi.r);
  15.             _root["b"+i]._x -= xbidis/bidis*force;
  16.             _root["b"+i]._y -= ybidis/bidis*force;
  17.         }
  18.     }
  19. }

And this is the result:

Download the source code and make it a playable game!

Special thanks to FrozenHaddock for sharing this code. He also runs a site, check it out.

If you liked this post buy me a beer (or two)

» Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.

13 Comment(s)

  1. Xavi-v | Mar 7, 2008 | Reply

    does anyone have any ideas of what kind of game to make with this prototype?
    the best i can think of is like to get the balls in a certain area in a limited amount of time…i’m not even going to bother making that cuz i know it will be boring

  2. Orava | Mar 7, 2008 | Reply

    you need to push the balls speed and get them to certain area, something curlinglike… all i can think of

  3. Ben Forbes | Mar 7, 2008 | Reply

    The direct link to the forum post is…

    http://www.triquitips.com/viewtopic.php?f=23&t=150

    … for impatient people :D

  4. FrozenHaddock | Mar 7, 2008 | Reply

    Modifying this to use x and y speeds so the balls slide and bounce would make for an interesting avoidance game.

    Perhaps you have 3 balls in the centre, and other enemy balls come in from the side and try to knock your balls out of a ring. You use the rod/ballpushery thing to defend against the enemies and to reposition your defendable balls.

    Just a thought.

  5. Kesh | Mar 8, 2008 | Reply

    Seems kinda……boring.

    lol nice little engine though.

  6. Ciaren Coleman | Mar 8, 2008 | Reply

    balls are flying around and you have to keep one safe?

  7. And Mar | Mar 8, 2008 | Reply

    2 ideas that require minor changes…

    1) You can swing the “pusher” around really fast with your mouse and wack balls into targets.

    2) #1 turned into a slingshot. You hold the mouse down and the ball sticks to the end. When you let go it flies off.

  8. Grifo | Mar 8, 2008 | Reply

    And Mar’s Idea seem cool , especially the scond part. I believe that in that case the speed of the pusher in the frame you release the mouse button should be directly proportional to the power and speed of the launched object. That can make something good.

  9. Monkios | Mar 10, 2008 | Reply

    This could also be the bases of a shepherds game.

  10. Luiz Fernando | Mar 10, 2008 | Reply

    Nice suggestions, guys :D

    I loved this prototype, it’s just fascinating!

  11. EagleVision | Mar 11, 2008 | Reply

    Yeah!
    I like it…Does anybody like this prototype?

    http://eagleproductions.wordpress.com/2008/03/05/brand-new-flash-prototypemake-a-ball-bounce-on-things/

    You can, stump on things.Just remember to make the green box alpha…fun?

  12. a question | Mar 12, 2008 | Reply

    Hey emanuele(or someone else who can help me)
    ive got a question can i make a hittest with two objects and then flash shows me cordinats where the two are hittesting?

  13. ssusnic | May 7, 2008 | Reply

    Hi, everybody!
    Here you can play my game named Polar Solar which is based on BallPusher prototype:

    http://www.askforgametask.com/games/polarsolar/

    Although the game is pretty simple, it has got an exclusive sponsorship. Of course, FrozzenHaddock and LuizZak as authors of the prototype are credited in the game.

1 Trackback(s)

  1. Apr 13, 2008: Ballpusher concept | FrozenHaddock

Post a Comment