Posted by editor
on June 11, 2009 at 5:57 AM PDT
The O'Reilly InsideRIA site has published an interesting series of articles by Haining Henry Zhang titled "Writing the Pac-Man Game in JavaFX"... Also:
Java Today: Writing the Pac-Man Game in JavaFX, JavaOne - my personal favorite sessions, and LINQ to XSD Released on CodePlex.
Weblogs: Top 5 Most Important Features in JavaFX 1.2, JWebPane BOF slides at JavaOne 2009, and AGFA Healthcare - Using GlassFish for Field Force Automation, Time Registration, SAP Integration.
Featured Articles: Zero and Shark: a Zero-Assembly Port of OpenJDK; Protect Your Legacy Code Investment with JNA.
Featured Podcast: Java Mobility Podcast 79: JavaOne 2009 Preview.
The O'Reilly InsideRIA site has published an interesting series of articles by Haining Henry Zhang titled "Writing the Pac-Man Game in JavaFX." This is yet another illustration of the power of JavaFX, exemplifying the richness and variety of capabilities the framework provides.
To date, four JavaFX Pac-Man articles have been published. The current version of the application can be run in Part 4 of the series. And the source code is available for download .
In "Writing the Pac-Man Game in JavaFX - Part 1 , Haining outlines the logical and data structure behind his implementation of the game.
When designing a data model, I usually consider two aspects: performance and space. Performance means that the data should be accessed via an efficient approach. For example, a hash table is usually faster than a linked list when a keyword-based search is performed. Performance is an important consideration for games that are constantly taking a player's input and updating graphical objects. Games like Pac-Man or Space Invaders fall into this category.
Haining notes that "the ability to leverage Java from within JavaFX is one of the very powerful features of JavaFX," and he puts this to use in the application. The article demonstrates the code for drawing the Pac-Man maze and concludes with a runnable JavaFX demo.
In Part 2 , Haining tackles some of the Pac-Man animation requirements, including the chomping Pac-Man himself. This is designed looking ahead to the subsequent need to create the "ghosts" later on. Haining creates a
MovingObject class with a
moveOneStep() function that is called every 200 milliseconds. The Pac-Man is inserted into the maze, and code for letting the user control the Pac-Man's motion via the keyboard is implemented, followed by code to let the Pac-Man grab the dots it passes through. At this point, the program is an interesting toy, but there isn't much challenge in playing it.
Part 3 of the article series brings in those frightening Pac-Man ghosts. The programming challenge is to create the different state representations of the ghosts (normal, hollow, and flashing), and correctly manifest the transitions between the states. This part of the article ends with the ghosts roaming the maze along with the Pac-Man, but these are nice ghosts that don't yet try to eat the Pac-Man.
Writing the Pac-Man Game in JavaFX - Part 4 provides the interactions between the Pac-Man and the ghosts (if the Pac-Man has recently gobbled a dot, he can eat the ghosts; if not, then they can eat him). First, the distance between the Pac-Man and the ghosts is calcuated. A threshold is applied, defining when the Pac-Man and a ghost are considered to be "touching" (in which case somebody is destroyed). Haining also implements the classical death throes of the Pac-Man, when he is eaten by a ghost (his circle unwraps until he disappears). To do this, he creates a
DyingPacMan class. Whenever the Pac-Man is eaten by a ghost, an instance of
DyingPacMan is inserted into the maze at the appropriate locations, it does its visual activity, and the game ends.
It looks like there will be a Part 5 article, since near the end of Part 4 Haining says:
As we mentioned in previous article, the ghosts are moving in a random fashion. This makes the game less challenging. In the next article, we will discuss a better algorithm of the ghost's moving behavior.
Haining's "Pac-Man in JavaFX" series is an interesting tutorial on JavaFX, worthy of study if you're looking for a fun way to introduce yourself to JavaFX.
In Java Today , Haining Henry Zhang has written a four-part article series on Writing the Pac-Man Game in JavaFX : "When I was young I was fascinated by arcade games. One of my favorites was the Pac-Man game. Recently, when I was learning the JavaFX language, I decided to write the game in JavaFX. Based on my experience in other programming languages, I assumed there would be some amount of work in building a game such as Pac-Man, giving me a good feel for RIA development in JavaFX..."
John Smart talks about JavaOne - my personal favorite sessions : "As usual, JavaOne was a great networking opportunity, and I caught up with old friends, made new ones, and met up with people I had only ever known virtually. This year I was giving a session myself, so I didn't get to as many sessions as I would have liked to. However, I did attend a few gems. Here are some of them..."
Jonathan Allen reports LINQ to XSD Released on CodePlex : "LINQ to XSD is the long awaited follow-up to LINQ to XML. Its primary purpose is to produce LINQ-compatible object models from XSD files, giving developers some measure of static type checking while accessing XML data..."
In today's Weblogs , Joshua Marinacci writes about Top 5 Most Important Features in JavaFX 1.2 : "Technically I'm on vacation this week so don't mention this post to my boss. I simply couldn't wait to blog about cool stuff we put into JavaFX 1.2. Shhhhh! Lots of JavaFX related things were announced at JavaOne, many of..."
Alexey Ushakov writes about JWebPane BOF slides at JavaOne 2009 : "Slides from BOF-3992 session presented at Thursday, June 4."
And Arun Gupta writes about AGFA Healthcare - Using GlassFish for Field Force Automation, Time Registration, SAP Integration : "Here are some reasons why AGFA Healthcare choose GlassFish for their Field Force Automation, Time Registration and SAP integration: 100% uptime for past 1.5 years with 8 cluster nodes GlassFish's importance in this economy Simple and elegant administrative console High availability, ease-of-use, and..."
In the Forums ,
Shai Almog responds Re: Fwd: tabbedpane left/right transition problem : "Hi Anson, the solution you suggest is relevant since you allow cyclic tabs which isn't "officially" supported by LWUIT. About the sequence of sending the selectionChanged events, I'm afraid that might be hard to change since this relates to listeners we bind to the internal List component and I can't think of a way to workaround it properly. You can open an RFE for something like that and maybe someone can come up with some idea..."
has found a v0.5 strange startup with newest trunk build
: "This is a it strange, I just received the latest trunk version as of an hour ago. I did 'ant' an 'ant run-server. I used the firefox client. It logged me in then I got a popup message "Unable to launch the application. I'd hit OK and the client exited. The next time I ran it, I just minimized the error message and clicked on the client window where the avatar moved around inside the world like nothing was wrong. But,tool items like clicking on "Window" shows nothing. So, with the error message I clicked on "details" and got this..."
Shreedhar Ganap continues the discussion Re: In memory session management Problem : "No intention to hide - it took a while to decide on a next release on the v2.x train while most of us were focused on v3 and Sailfin. The build promotion notices have been going to the dev alias. Let me see if those notices could be sent to this list and add it to the DL page. firstname.lastname@example.org wrote: Why does the the nightly/promoted builds cannot be found on main download page ? Many in this forum have faced replication problems and it took so long to release a fix build. More correctly is created a fixed build and hide it from all of us !... "
The current Spotlight is View the JavaOne 2009 General Sessions : "If you weren't able to attend JavaOne 2009, you can still see all the general sessions online..."
This week's java.net Poll asks What was most significant about JavaOne 2009? . Today (Thursday) is the last full day of voting.
Our Feature Articles include today's new article by Thomas Kunneth, Hacking JavaFX Binding . In this article, Thomas describes how to apply binding within JavaFX in a manner similar to what can be accomplished using Beans Binding (JSR-295). We're also featuring Gary Benson's Zero and Shark: a Zero-Assembly Port of OpenJDK , which tells the interesting story of how the Java group at Red Hat developed a cross-platform OpenJDK port.
The latest Java Mobility Podcast is Java Mobility Podcast 80: Java at FIRST 2010 Competition , in which Eric Areseneau talks about Java now being available for the FIRST 2010 Competition.
The latest OpenJDK Podcast is
The latest JavaOne Community Corner Podcast is
Current and upcoming Java
Registered users can submit event listings for the
href="http://www.java.net/events">java.net Events Page using our
href="http://today.java.net/cs/user/create/e">events submission form.
All submissions go through an editorial review before being posted to the
Archives and Subscriptions: This blog is delivered weekdays as
Today RSS feed . Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the
The O'Reilly InsideRIA site has published an interesting series of articles by Haining Henry Zhang titled "Writing the Pac-Man Game in JavaFX"...