My JavaFX Demo Game: PAC-MAN

Posted: November 30th, 2008 under JavaFX, Javafx Games.
Tags: , , ,

UPDATE: June 30, 2009
If you are interested in how to write the Pac-Man game in JavaFX, the source code of this game, please check out this article:

How to Write the Pac-Man Game with JavaFX
or Articles on Writing the JavaFX Pac-Man Game

I spent some time to implement the classic game “PAC MAN”. It demos many features of the JavaFX language. Right now, it is a “simplified” PACMAN Game. I am working on the code and hopefully to complete the PACMAN game soon. Source code is not released yet because I plan to do so when I finish the whole game. A blog of writing this game will be available soon. Stay tuned.

Arrow keys to move and control to pac-man to eat all dots inside the maze. The big dots are magic dots which allow the pac-man to eat ghosts.

JavaFX Features Demostrated:

  • Bindings
  • Animations
  • Effects
  • Transforms
  • Multiple inheritant
  • Java classes integration
  • Declarative statements
  • Sequences, how to map 2D arrays into a 1D Sequence
  • Handling keyboard events

JRE 1.5+ required, JRE1.6 U10 is better, it will take some time for first time launching the game …


My JavaFX code is compatible with the newly released JavaFX 1.0. JavaFX is for Windows and Mac for now. The unofficial JavaFX SDK of Linux can be found here:

If you cannot play now, you can watch the video:

Unrelated links:

JavaFX Articles

Collection: NASCAR Diecast Model Cars

Canadian Citizenship Practice Test

NASCAR Car Diecast

NASCAR Drivers

British Citizenship Test for United Kingdom


  • Comment by Silveira Neto — December 6, 2008 @ 1:44 am


    Cool! I played it here.

  • Comment by Andrew McVeigh — December 9, 2008 @ 2:36 am


    great demo. finally a javafx demo that isn’t horrible!

  • Comment by shaman666 — December 10, 2008 @ 1:01 pm


    Congratulations! Great game!

  • Comment by Steve Muench — December 10, 2008 @ 1:13 pm


    Is there any way to play it right in the page like the Flash games I see my kids play? Having the end-user see *.jnlp extensions in Firefox download dialogs is a cold shower for non-technical users.

  • Comment by Roger Padilla — December 10, 2008 @ 1:27 pm


    Simply wonderful. Thanks by share your great work.

    Greetings from Cartagena/Colombia

  • Comment by Chad Stever — December 10, 2008 @ 1:55 pm



  • Comment by HighScore — December 10, 2008 @ 2:38 pm


    Are planning to include a high score server?

  • Comment by bein — December 10, 2008 @ 3:34 pm


    hi, great work, will be cool if share your code, i’m start with javafx, and i think is great. Good day.

  • Comment by Stephan — December 10, 2008 @ 3:41 pm


    Very cool. I love it 🙂

  • Comment by mewondering — December 10, 2008 @ 9:40 pm


    do you dubble buffer or is that part of fx?

  • Comment by Henry — December 11, 2008 @ 1:20 am


    Dear mewondering,

    I did not use any double buffering in the code, the JavaFX takes care of the animation.

  • Comment by Henry — December 11, 2008 @ 1:23 am


    Dear Steve Muench,

    It seems that IE doesn’t show up the .jnlp URL. Anyway, you can see a html version here:

  • Comment by Jim — December 11, 2008 @ 1:53 am


    Great work – one of the best JavaFX apps so far.

  • Comment by Sravan — December 11, 2008 @ 4:55 am


    Thanks for the game. Pacman is always welcome. 🙂

  • Comment by wildboar — December 11, 2008 @ 6:25 am


    Nice one Henry. Can’t wait to gobble up the code.

  • Comment by Prashant Saraf — December 11, 2008 @ 6:56 am


    Coolll.. JavaFX rocks..

  • Pingback by Sun JavaFX 1.0 Released — December 11, 2008 @ 7:01 am


    […] a penalty for missing the news, I share with you Henry Zhang’s JavaFX implementation of the Pacman game. […]

  • Comment by David — December 11, 2008 @ 9:59 am


    Great game! Is there source code that we can look at, to see how you did your animations, sequences, etc?

  • Comment by Deniz Oguz — December 11, 2008 @ 1:43 pm


    one of the best javafx games so far.

  • Comment by Christine Dorffi — December 12, 2008 @ 11:05 am


    We are covering this blog on the JavaFX Developer Home page this week: . Looking forward to the next phase.

  • Pingback by » My JavaFX Demo Game: PACMAN »Free Games — December 12, 2008 @ 12:04 pm


    […] games by unknown « Armada The Final Assault download from Action category Snow Man Online Coloring […]

  • Comment by Licsan — December 13, 2008 @ 6:14 pm


    waw, nice game! Good work, I’m really looking forward to see the source of this. Just one question : I think there is no sound in the game, right?
    Is there any possibility to do this with JavaFX, or isn’t it the subject at all?
    Sorry, I’m just trying to figure out what exactly brings JFX, so I apologize if my question is stupid…
    Except that, it’s brillant! 😉

  • Comment by Henry Zhang — December 14, 2008 @ 12:49 am


    hi Licsan,

    Thanks for your comment. JavaFX does support sound. I just need some time to put it into the game. Have fun!

  • Comment by Geert Schuring — December 16, 2008 @ 7:07 am


    Where are the cherries?

  • Comment by Amer Sohail — December 17, 2008 @ 10:29 pm


    Cool Demo. Waiting for source code

  • Comment by Eric Groleau — December 19, 2008 @ 9:54 pm


    Very good result! I am anxious to look at the code.

    Do you have an idea of how long it is going to take you to publish your code?

    Thank you.

  • Comment by Raj — December 20, 2008 @ 12:46 pm


    Hey i’m relatively new to programming. I am in a java computer programming 1 class right now. Being able to view this code would be greatly useful. Any chance this could be possible?

  • Comment by mogulwraith — December 27, 2008 @ 6:57 pm


    nice. Can’t go wrong with Pac-Man. I did miss the familiar Wocka-Wocka-Wocka sounds though.

    Hi mogulwraith,

    I am planning to add in audio of this game. Just that need to spare some time in coding and find a suitable sound track of the Wocka-Wocka …. 🙂


  • Comment by lestasi_delloro — December 27, 2008 @ 7:28 pm


    Great work…

    And i was wondering if it is possible to use JavaFX Script code integrated with pure Java code. Can i provide these new design issues to my Java code? Is there any technical articles on this subject you may recommend?

    Hi lestasi_delloro,

    JavaFX can call Java without any problem. If you want to call JavaFX from Java, there may be some work. Please refer to my other post for details:


  • Comment by Lobochief — December 29, 2008 @ 12:49 pm


    That’s remarkably well done, similar to the original. Do you plan to release the source code, or at least allow redistribution?

    Dear lobochief,

    Thanks for your comment. I am working on some articles about this game. The source code will be released as well. Please check back some time later. Thanks.


  • Comment by Jeet Kaul — January 1, 2009 @ 7:40 pm


    Very nice work. I had fun. Hope you will be doing more of these.

  • Pingback by Articles on Writing the JavaFX Pac-Man Game — May 16, 2009 @ 7:51 am


    […] My JavaFX Demo Game: PACMAN […]

RSS feed for comments on this post.