JavaFX Games

May 23, 2009

I Wish... Henry Zhang would make a WidgetFX widget from his JavaFX Pac-Man game

WidgetFX-Pac-Man

Update 24 May, 2009: Stephen Chin raises the stakes with the following comment:

"That is a quite a challenge Jim laid on you, Henry. I will up the ante with a promise to display your widget on the big stage as part of the WidgetFX JavaOne presentation if you get it done in time.  There is a good tutorial on how to build widgets from my blog.

Update 25 May, 2009: Henry Zhang picks up the gauntlet with the following comment:

"I think it is a creative idea to put a game as a widget. I will take on the challenge and hopefully the widget can be demonstrated in JavaOne. Only a week or so to go. Will let you know the progress by blogging here:
http://www.javafxgame.com"

Update 26 May, 2009:

Henry finishes the Pac-Man widget.  Check it out at javafxgame.com.  Also, just a friendly reminder to reserve the JavaOne Pro JavaFX™ Platform: RIA Enterprise Application Development with JavaFX Technology session that Stephen Chin and I will be presenting.  As of May 29, 2009 there are only 96 seats available.


Dear Henry Zhang,

Please attend Stephen Chin and Josh Marinacci's Getting Started with WidgetFX session at JavaOne (or watch the video stream), and tweak your JavaFX Pac-Man game to run as a WidgetFX widget.  It would be cool to drag Pac-Man from the WidgetFX dock and devour dots for stress relief :-)

P.S. Congratulations on article #2 in your five part Pac-Man series being published on InsideRIA.  It was a pleasure to help (albeit in small ways) with that series.

Regards,
Jim Weaver

May 15, 2009

Answer: Blinky, Pinky, Inky and Clyde

Inside-ria-pacman-ghosts The answer is: Blinky, Pinky, Inky and Clyde.  Please phrase your response in the form of a question.

If you said "What are the ghosts' nicknames in American Pac-Man", congratulations!  See the table below (from the Wikipedia Pac-Man article) for more stats on these ghosts:

Inside-ria-pacman-chars


Announcing Henry Zhang's five-part series on creating the Pac-Man game in JavaFX

For each of the next five weeks Henry Zhang will show you in great detail how he created a Pac-Man game in JavaFX.  He has written a series of articles for InsideRIA that build on each other, with each article having a JavaFX program that you can execute.  There are also Web Start links in the articles so that you can run the programs directly from the web page.  Here's an example screenshot from the first article:

Inside-ria-pacman-1a

Henry's articles are an excellent resource for increasing your JavaFX skills in the context of building a fun video game, so check them out!

Regards,

JIm Weaver

March 26, 2009

Creating a UFP (Ultimate Fighting Pigs) Game using JavaFX Production Suite :-)

At least it looks like a fighting game, with buttons labeled Kick and Punch.  Upon closer inspection, we find that it's a JavaFX version of the classic Pigs dice game, co-created by a JavaFX developer and a graphics designer.


PigDiceGame


Graphics designer Jonathan Wei used Adobe Illustrator to create the artwork.  The JavaFX Production Suite was employed to make it very easy for developer Jim Connell to use that artwork from JavaFX.  To help you learn this process, Jim has created an excellent tutorial that shows you how this game was created, walking through the [small amount of] JavaFX code contained in the program.

Regarding the Kick and Punch buttons:  They don't seem to be operable, and I suspect that they reflect the aforementioned guys' twisted sense of humor :-)

Thanks for this excellent resource, Jonathan and Jim!

Regards,

Jim Weaver
JavaFXpert.com (Learn JavaFX blog)

March 11, 2009

Table of Contents for the Pro JavaFX Platform early access eBook

ProJavaFX-small-cover Several people have asked for a table of contents for the Pro JavaFX Platform early access eBook (by Weaver, Gao, Chin, and Iverson) to give them a better idea of what's inside.  Because the table of contents isn't on the Apress site yet, I'm posting it here.  Apress and Amazon aren't likely to post the fully expanded table of contents anyway. 

I've sprinkled in a few screenshots to give you a flavor for some of the example programs:

HelloEarthrise


CHAPTER 1: Getting a Jump Start in JavaFX

  • JavaFX Can’t Bring Rich-Client Java Back by Itself
  • A Brief History of JavaFX
  • Going to the Source – Sun’s JavaFX Websites
    • Accessing the JavaFX SDK API and Language Documentation
    • Obtaining the JavaFX SDK
    • JavaFX Production Suite
    • Other Available Tools
  • Developing Your First JavaFX Program: "Hello Earthrise"
    • Compiling and Running from the Command-Line
    • Understanding the Hello Earthrise Program
      • Comments
      • The package Declaration
      • import Statements
      • Declarative Code That Defines the User Interface
      • Using the Stage Class
      • Creating String Literals
      • Using the Scene Class
      • Displaying Images
      • Working with Graphical Nodes as a Group
      • Drawing Text
      • Clipping Graphical Areas
      • Animating the Text to Make it Scroll Up
    • Building and Running the Program with NetBeans
  • Deploying JavaFX Applications
    • Deploying JavaFX Applications with Java Web Start
    • Deploying JavaFX Applets
  • Developing Your Second JavaFX Program: "More Cowbell!"
    • Building and Running the Audio Configuration Program
    • The Behavior of the Audio Configuration Program
    • Understanding the Audio Configuration Program
      • Creating an Instance of the Model, and the Magic of Binding
      • Colors and Gradients
      • The Model Class for the Audio Configuration Example
      • Structure of a Minimal JavaFX class
      • Defining Triggers in the Model Class
  • Surveying JavaFX Features
  • Summary
  • Resources

MediaExplorer


CHAPTER 2: Taking a Closer Look at the JavaFX Script Language

  • An Overview of JavaFX Script
  • Understanding Variables, Values, and Their Types
    • Understanding Variable Names
    • Understanding Variable Types
  • Understanding the Primitive Types
    • Understanding the Boolean Type
      • Boolean Literals and Default Value
      • Boolean Operators
      • The Backing Class of Boolean Type
    • Understanding the Integer Type
      • Integer Literals and Default Value
      • Arithmetic Operators
      • The Backing Class of Integer Type
    • Understanding the Number Type
      • Number Literals and Default Value
      • Arithmetic Operations
      • The Backing Class of Number Type
    • Understanding the String Type
      • String Literals and Default Value
      • String Expressions
      • The Backing Class of String Type
    • Understanding the Duration Type
      • Duration Literals and Default Value
      • Arithmetic Operations Involving Durations
      • The Backing Class of Duration Type
  • Working with Sequences
    • Understanding Sequence Types
    • Constructing Sequences Using Explicit Sequence Expressions
    • Constructing Numeric Sequences Using Range Expressions
    • Manipulating Sequences
      • Accessing the Size of a Sequence
      • Accessing an Element in a Sequence
      • Accessing a Slice of a Sequence
      • Accessing a Subset of a Sequence through a Predicate
      • Reversing a Sequence
      • Inserting an Element into a Sequence
      • Inserting another Sequence into a Sequence
      • Deleting Elements from a Sequence
      • A Sequence Manipulation Example
    • Understanding Sequence Comprehension
    • Using Utility Functions in javafx.util.Sequences
  • JavaFX Script is an Expression Language
    • Understanding Expressions and their Types
    • Understanding the Block Expression
    • Understanding Precedence and Groupings
    • Understanding the Expression Separator
    • Understanding Variable and Constant Declarations
    • Understanding the Assignment Operator
    • Understanding the Compound Assignment Operators
    • Understanding the Relational Operators
    • Understanding the while Expression
    • Revisiting the for Expression
    • Understanding the if Expression
  • Understanding Object Literals
    • Understanding Classes and Objects
    • The Object Literal Expression
      • Initializing Instance variables
      • Declaring Constants and Variables
      • Overriding Instance functions and Instance variables
    • Manipulating Objects
      • Manipulating Object States
      • Invoking Instance functions
    • Creating Java Objects with the new Operator
    • The Making of a Declarative Syntax
  • Working With Data Bindings
    • Understanding the bind Expression
      • What Does the Data Binding Remember?
      • Binding to if Expressions
      • Binding to for Expressions
      • Binding to a Block
      • Binding to Function Invocation Expressions
      • Binding to Object Literal Expressions
    • Understanding Bidirectional Bindings
  • Summary

AudioPlayer


CHAPTER 3: Creating a User Interface in JavaFX

  • Introduction to Node-Centric UIs
  • Setting the Stage
    • Understanding the Stage Class
      • Consulting the API Docs for the Stage Class
    • Using the Stage Class: The StageCoach Example
    • Understanding the StageCoach Program
      • Obtaining Program Arguments
      • Setting the Style of the Stage
      • Controlling Whether a Stage is Resizable
      • Making a Stage Full Screen
      • Working with the Bounds of the Stage
      • Drawing Rounded Rectangles
      • Dragging the Stage on the Desktop when a Title Bar isn’t Available
      • Using UI Layout Containers
      • Ascertaining Whether the Stage is in Focus
      • Controlling Z-Order of the Stage
      • Closing the Stage and Detecting when it is Closed
      • Exiting the application
  • Making a Scene
    • Using the Scene Class: The OnTheScene Example
    • Understanding the OnTheScene Program
      • Setting the Cursor for the Scene
      • Painting the Scene's Background
      • Populating the Scene with Nodes
      • Finding a Scene Node by ID
      • Accessing the Stage from the Scene
      • Inserting a Node into the Scene's content Sequence
      • CSS Styling the Nodes in a Scene
      • Understanding the JavaFX Node Class Hierarchy
  • Handling Input Events
    • Surveying Mouse and Keyboard Events and Handlers
      • Understanding the KeyEvent Class
      • Understanding the MouseEvent Class
    • Using Mouse and Key Events: The MobileEqualizer Example
    • Understanding the MobileEqualizer Program
      • Understanding the Model used in this Program
      • Using the onMousePressed Event Handler
      • Using the onMouseDragged Event Handler
      • Giving Keyboard Input Focus to a Node
      • Using the onKeyPressed Event Handler
  • Animating Nodes in the Scene
    • Using a Timeline for Animation
      • The Metronome1 Example
      • Understanding the Metronome1 Program
        • Understanding the Timeline Class
        • Inserting Key-Frames into the Timeline
        • Controlling and Monitoring the Timeline
        • Shorthand Syntax for Key-Frames
    • Using the Transition Classes for Animation
      • The MetronomeTransition Example
      • The Behavior of the MetronomeTransition Program
      • Understanding the MetronomeTransition Program
        • Using the TranslateTransition Class
        • Controlling and Monitoring the Transition
        • The MetronomePathTransition Example
      • The Behavior of the MetronomePathTransition Program
      • Understanding the MetronomePathTransition Program
        • Using the PathTransition Class
        • Drawing an Ellipse
    • The Zen of Node Collision Detection
      • Understanding the ZenPong Program
        • Using the KeyFrame action Event Handler
        • Using the Node intersects() Function to Detect Collisions
        • Dragging a Node
    • Summary
    • Resources

ZenPong


CHAPTER 4: Using Functions, Classes and Other Advanced Features

  • Working with Functions
    • Understanding Function Definitions
      • Understanding Return Types
      • Understanding Parameters and their Types
      • Understanding Function Bodies and the return Expression
      • What Can a Function Body See?
    • Understanding Overloaded Functions
      • Understanding Implicit Type Conversions
      • Rules for Overloaded Function Resolution
    • Understanding Function Types and Anonymous Functions
      • More Details on Function Type Specifiers
      • More Details on Anonymous Function Expressions
      • More Details on Closures
    • Understanding Bound Functions
    • Understanding Exceptions
      • Understanding the Call Stack
      • Throwing Exceptions
      • Handling Exceptions
  • Working with Classes
    • Understanding Class Definitions
      • Understanding Instance Variables
      • Understanding Instance Functions
      • Understanding the this Expression
      • Understanding Initialization Blocks
    • Creating Class Hierarchies
      • Extending Classes
      • Overriding Instance Variables
      • Overriding Instance Functions
      • Understanding the super Keyword
      • Understanding Abstract Classes
      • Understanding Casting and the instanceof and as Operators
  • Organizing JavaFX Script Code
    • What is a Script?
    • Understanding Modules
    • A Special Provision for Classes
    • Understanding Packages
    • Understanding Import Directives
    • Understanding Access Modifiers
      • Understanding the protected Modifier
      • Understanding the public-init and public-read Modifiers
  • Understanding Triggers
    • Accessing the Old and New Values in Trigger Blocks
    • Accessing Sequence Modification Information in Trigger Blocks
    • Debugging With Triggers
  • Understanding String Formatting and Internationalization
    • Using String Format Specifications
    • Internationalizing JavaFX Script Programs
  • Leveraging Java from JavaFX Script
    • Instantiating Java Classes
    • Accessing Java Object Fields
    • Calling Java Methods
    • Accessing Static Fields and Methods
    • Quoting JavaFX Script Keywords
    • Accessing Nested Classes
    • Accessing Java Enums
    • Extending Java Classes and Interfaces
    • Iterating Through Java Collections
  • Understanding JavaFX Script Reflection
    • Understanding Mirror-Based Reflection
    • Entering the Reflection World
    • Programming through Reflection
      • Creating a New Instance of a Class
      • Getting and Setting Values of Instance and Script variables
      • Invoking Instance and Script Functions
      • Other Reflection Capabilities
  • Summary

MobileDrawJFX  


CHAPTER 5: Creating Custom UI Components in JavaFX

  • Creating Custom UI Components
    • Creating a Custom Node
      • The ColorPickerNode Example
      • Understanding the ColorPickerNode Custom Node
        • Overriding the CustomNode create() Function
        • Using the Node hover Variable
      • The ColorPickerSnowFlakeNode Example
      • Understanding ColorPickerSnowFlakeNode
        • Making a Node Act like a Dialog
        • Defining and Invoking an Event Handler
        • Overriding Instance Variables
        • The DropShadow Effect
        • Obtaining the width and height of a Node
        • Creating a Polygon Shape
        • Using the stroke and strokeWidth Variables
        • Using the transforms Variable to Transform Nodes
        • Blocking Mouse Events from Underlying Nodes
    • Creating Skinnable UI Controls
      • The StoplightSkinning Example
      • Understanding the StoplightSkinning Program
        • Creating the Control's Model
        • Using the hover, pressed, focused and Variables in the Model
        • Associating a Skin with the Model
        • Creating a Skin for the Control
        • Binding the Skin to the Model
        • Using the hover, pressed, focused and Variables in the Skin
        • The Code for the Horizontal Stoplight Skin
        • Associating a Skin with the Model using a Stylesheet
      • Deciding Between Creating a Custom Node and a UI Control
  • Summary
  • Exercise: Putting Chapters 1 – 5 Concepts in Practice
  • Resources

HorizStoplight


CHAPTER 6: Using the Media Classes

  • The Foundation
  • Working With Media
  • Playing Audio
    • Controlling Playback
    • Repetition
    • Volume and Balance
    • Streaming Media
  • Playing Video
    • Controlling the Size of a MediaView
    • Transforming a MediaView
    • Compositing And Effects
    • One Player, Multiple Views
    • Playing Movies with SimpleMediaPlayer
  • Summary

VideoPlayer


CHAPTER 7: Dynamically Laying Out Nodes in the User Interface

  • Introducing JavaFX Reversi
    • Board Layout and Basic Rules
    • Building a JavaFX Model for Reversi
  • Dynamic Layout Basics
    • Bind For Layouts
    • Centering Nodes and Text
    • Aligning to Edges
    • Aligning Nodes to Each Other
    • Using HBox and VBox
    • When to Use Bind Versus Boxes
  • Creating Resizable Nodes
    • Building a Reversi Square
    • Building a Reversi Piece
  • Creating a Grid Layout Container
    • Understanding the Geometry API
    • Extending the Container Class
    • The Grid Layout Algorithm
    • Binding the Layout to the Model
  • A New Perspective on Reversi
    • The Perspective Layout Algorithm
    • Creating the Perspective Layout Class
    • Integrating the Perspective Layout
  • Bringing Reversi to Life
    • Highlighting Legal Moves
    • Perspective Mouse Interaction
    • Highlighting the Active Cell
    • Taking Turns
    • Additional Game Enhancements
  • Summary
  • Resources

Reversi


Chapter 8: Extending JavaFX with Third-Party Libraries

  • Creating Desktop Widgets with WidgetFX
    • Creating a Movie Widget
    • Widget Configuration
    • Deploying Widgets to the Web
    • Third-Party Widgets
      • Disk Space Widget
      • World Clock Widget
      • World Smiley Widget
    • The Future of WidgetFX
  • Building a Media Explorer with JFXtras
    • Laying out a Resizable Directory Navigator
    • Building a User Interface with Constraints
    • Displaying Media in a Dynamic Grid
    • Wrapping Media with Borders in a Deck
    • Creating an Asynchronous Search Form with MigLayout
      • Laying out the Search Form with MigLayout
      • Adding Asynchronous Search with the JFXWorker
      • Refining the Search With Filters
  • The Rest of JFXtras
    • JFXtras Test
      • Nesting Test Cases
      • Fluent Expectations
      • Parameterized Testing
        • Using Assume to Calculator Output
      • Unit Testing the Media Search with Custom Expectations
    • Extended Shapes
    • The Future of JFXtras
  • Other Libraries
    • Atomic Tile - 2D Tile-based Game Authoring
    • FXUtil - Inverse Kinetics Library
    • FEST-JavaFX - Automated UI Testing of JavaFX
  • Predicting what will be in future versions of JavaFX
  • Summary
  • References

DrawJFXtras


CHAPTER 9: Building a Professional JavaFX Application

  • Writing RESTful Web Service Clients
    • Rise of the RESTful Web
    • Using The HttpRequest Class
    • Writing JSON Clients
      • Parsing JSON in JavaFX
      • Who is My Representative?
    • Writing XML Clients
      • Parsing XML in JavaFX
      • Who is My Representative in XML
  • Developing a Rich Internet Application
    • Making Use of Assets with the Production Suite
    • Using the Amazon Web Service API
    • User Interface Considerations
      • Inside the NodeFactory
    • The Home Page
      • A Java-Based Image Cache
      • Getting the Top Sellers from Amazon
    • The Search Page
      • Adding Item Search to the Application Model
    • The Cart Page
  • Summary
  • Resources

BookStore


 Chapter 10: Developing JavaFX Mobile Applications

  • The Vision of JavaFX Mobile
  • Mobile Hello Earthrise
    • Running in the Mobile Emulator
    • Fitting Applications on the Mobile Screen
  • Developing for the Common Profile
  • Mobile DrawJFX
    • Creating a Mobile Color Picker
    • Refactoring DrawJavaFX for Mobile Devices
  • Advanced Mobile Features
    • Performance Tuning JavaFX Mobile Applications
  • Summary
  • References


HelloEarthriseMobile

We end where we began, with the Hello Earthrise program, this time running in JavaFX Mobile.

Regards,
Jim Weaver

December 12, 2008

Facebook User? Check out the JavaFX Picture Puzzle

A JavaFX "Picture Puzzle" app that is integrated with Facebook is featured In a blog post by Sharon Zakhour.  Not only is it graphically pleasing and smooth operating (wasn't that a song performed by Sade?), but it "lives" in Facebook, and makes jigsaw puzzles out of your Facebook friends' profile pictures.  It uses the Facebook API, and it was developed by Sun.

Facebook_picture_puzzle  

By the way, if anyone knows whether the source code is available, please post a comment, as it would be a great learning example.

Check this JavaFX Facebook app out and puzzle all of your friends! :-)  That was lame, but it's Friday.

Regards,
Jim Weaver
JavaFXpert.com

December 10, 2008

Henry Zhang Just Raised the Bar for JavaFX Games

While checking my email today (jim.weaver [at] javafxpert.com), I received a request for feedback from Henry Zhang on a game that he had written in JavaFX.  My feedback, Henry, is that your Pac-Man game ROCKS!

Pacman

According to Henry's blog post where you can play the game, this Pac-Man game is developed with JavaFX SDK 1.0, and demonstrates the following features:

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

Check it out, and please give Henry some feedback!

Regards,
Jim Weaver
JavaFXpert.com


December 08, 2008

JavaFX Whack-a-Janssen Game for Devoxx :-)

This year I had to miss Devoxx 2008, but really wanted to go. Not only is it a great conference, but this year it is the first major conference since the JavaFX SDK 1.0 was released, so there are some great JavaFX sessions and speakers on the agenda.

 

Whack-a-janssen

So, in honor of the Devoxx conference and the excellent leadership that Stephan Janssen provides to it, I've created a game in JavaFX.  I'm not a game programmer nor am I a graphic designer, and I didn't enlist the help of either for this quick effort.  With those disclaimers, and the hope that Stephan Janssen will take this in good-natured fun, I give you: "Whack-A-Janssen", styled loosely after the old "Whac-a-Mole" game.

Click on the Launch icon to run it as a Java Web Start application.  To play the game, simply click the Start Game button and then click on Stephan's faces when they pop up.  While the game is in progress the Start Game button changes to Stop Game.  If all three faces appear, the game is over and the Start Game button reappears.

Webstart.small2

The Code Behind the Game

This game makes use of the transition convenience classes in the javafx.animation.transition package to achieve animated movement, scaling and fading.  It also uses the Timeline and KeyFrame classes in the javafx.animation package to popup the many faces of Stephen:

/*
* WhackAJanssen.fx
*
* Developed 2008 by James L. Weaver (jim.weaver at javafxpert.com)
* to demonstrate creating applications using JavaFX SDK 1.0, and for
* having some good-natured fun with Stephan Janssen of Devoxx.
*/

package javafxpert;

import javafx.animation.*;
import javafx.animation.transition.*;
import javafx.ext.swing.*;
import javafx.scene.*;
import javafx.scene.effect.*;
import javafx.scene.image.*;
import javafx.scene.input.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.scene.text.*;
import javafx.scene.transform.*;
import javafx.stage.Stage;
import java.lang.Math;

Stage {
  // Transitions for popups
  var popupRefs:Transition[] = [
    ScaleTransition {
      node: bind stephen1Ref
      duration: 1s
      fromX: 0.1
      fromY: 0.1
      toX: 1.0
      toY: 1.0
    },
    TranslateTransition {
      node: bind stephen2Ref
      duration: 1s
      fromY: 0
      byY: -70
      //autoReverse: true
    },
    FadeTransition {
      node: bind stephen3Ref
      duration: 1s
      fromValue: 0.0
      toValue: 1.0
      //autoReverse: true
   }
  ];
  // Transitions for knock-downs
  var knockdownRefs:Transition[] = [
    ScaleTransition {
      node: bind stephen1Ref
      duration: 500ms
      fromX: 1.0
      fromY: 1.0
      toX: 0.1
      toY: 0.1
    },
    TranslateTransition {
      node: bind stephen2Ref
      duration: 500ms
      fromY: -70
      byY: 70
      //autoReverse: true
    },
    FadeTransition {
      node: bind stephen3Ref
      duration: 500ms
      fromValue: 1.0
      toValue: 0.0
      //autoReverse: true
   }
  ];
  var stephen1Ref:ImageView;
  var stephen2Ref:ImageView;
  var stephen3Ref:ImageView;
  // Timeline that causes random Stephens to popup
  var gameTimeline = Timeline {
    keyFrames: [
      KeyFrame {
        time: 2s
        action: function():Void {
          var stephenNum:Integer =
            (Math.random() * sizeof stephensDown) as Integer;
          if (stephensDown[stephenNum]) {
            stephensDown[stephenNum] = false;
            popupRefs[stephenNum].playFromStart();
          }
        }
      }
    ]
    repeatCount: Timeline.INDEFINITE
  }
  // Position that the stephens are in. The trigger evaluates whether
  // the game is over and stops the game Timeline
  var stephensDown:Boolean[] = [true, true, true] on replace {
    var downs = for (stephen in stephensDown where stephen == true) stephen;
    if (sizeof downs == 0) {
      gameTimeline.stop();
    }
  };
  title: "Whack-A-Janssen"
  scene: Scene {
    var btn:SwingButton;
    width: 300
    height: 350
    fill: Color.#010101
    content: [
      ImageView {
        transforms: Translate.translate(24, 56)
        image: Image {
          url: "{__DIR__}images/devoxx250.jpg"
        }
      },
      // Left-most face
      stephen1Ref = ImageView {
        transforms: [
          Translate.translate(63, 99),
        ]
        opacity: 1.0
        image: Image {
          url: "{__DIR__}images/sj_face_small.gif"
        }
        cursor: Cursor.HAND
        onMouseClicked: function(me:MouseEvent):Void {
          stephensDown[0] = true;
          knockdownRefs[0].playFromStart();
        }
      },
      // Middle face
      Group {
        transforms: Translate.translate(120, 20)
        content: [
          Group {
            content: [
              stephen2Ref = ImageView {
                transforms: Translate.translate(0, 90)
                image: Image {
                  url: "{__DIR__}images/sj_head_small.gif"
                }
              },
            ]
            clip: Group {
              content: [
                Polygon {
                  points: [
                   0, 0,
                   0, 46
                   15, 80
                   51, 80,
                   66, 46,
                   66, 0
                  ]
                },
                Arc {
                  centerX: 33
                  centerY: 80
                  startAngle: 180
                  length: 180
                  radiusX: 18
                  radiusY: 10
                }
              ]
            }
          },
          Rectangle {
            width: 66
            height: 98
            fill: Color.TRANSPARENT
            cursor: Cursor.HAND
            onMouseClicked: function(me:MouseEvent):Void {
              stephensDown[1] = true;
              knockdownRefs[1].playFromStart();
            }
          }
        ]
      },
      // Right-most face
      stephen3Ref = ImageView {
        transforms: Translate.translate(190, 95)
        image: Image {
          url: "{__DIR__}images/sj_left_facing.gif"
        }
        opacity: 0.0
        effect: Glow {}
        cursor: Cursor.HAND
        onMouseClicked: function(me:MouseEvent):Void {
          stephensDown[2] = true;
          knockdownRefs[2].playFromStart();
        }
      },
      // Start Game button
      btn = SwingButton {
        transforms: [
          Translate.translate(200, 207),
          Scale.scale(0.7, 0.7),
          Rotate { angle: -4}
        ]
        text: bind if (gameTimeline.running) "Stop Game" else "Start Game"
        foreground: bind if (gameTimeline.running) Color.BLACK else Color.RED
        font: Font {
          name: "Arial Bold"
        }
        action: function():Void {
          if (not gameTimeline.running) {
            stephensDown[0] = true;
            stephensDown[1] = true;
            stephensDown[2] = true;
            knockdownRefs[0].playFromStart();
            knockdownRefs[1].playFromStart();
            knockdownRefs[2].playFromStart();
            gameTimeline.playFromStart();
          }
          else {
            gameTimeline.stop();
          }
        }
      }
    ]
  }
}

Enjoy the conference if you're attending, and this very simple and lame Whack-A-Janssen game!

Regards,

Jim Weaver
JavaFXpert.com

August 26, 2008

Creating Games with JavaFX: Silveira is Having Too Much Fun :-)

I've featured Silveira Neto's JavaFX work (play?) in a couple of recent posts, and it appears that he's had gaming on his mind lately.  Silveira is a CS student, CEJUG member and Sun Campus Ambassador at Federal University of Ceará.

Netoblackdotgame

His latest creation, shown above, is a game in which the player tries to vacuum up the dirty clouds with a sphere-shaped cleaner.  It demonstrates several techniques in JavaFX, such as creating a side-scrolling game, capturing keyboard input, and ascertaining when a graphical object intersects with a pixel in another graphical object.  You can see more information, including the source code and a YouTube video of the game being played, from Silveira's blog post.

In a prior post, Silveira discusses how to create a side-scrolling game in JavaFX, showing the classes that he's building to support it.

Have fun!

Jim Weaver
JavaFXpert.com blog

May 15, 2008

Video of Cool JavaFX Demos at JavaOne 2008

Note from Jim Weaver: Since this was written, an updated version of JavaFX has been released.  You can get the new version of JavaFX at at JavaFX.com.

During the Tuesday afternoon general session at JavaOne 2008, there were some cool JavaFX-related announcements and demos.  Grab some popcorn and watch this video of a portion of the session, which includes:

  • An announcement that ON2 and Sun now have a relationship that will make the ON2 video codec available as part of the Java and JavaFX platforms.  This will allow video to be converted to a common format and played on any machine or device that supports Java.
  • The JavaFX version of the parleys.com website, which is the Belgium Java Users Group's (JUG) site for sharing video presentations about Java.  Stephan Janssen, who leads the JUG as well as the JavaPolis conference in Belgium, presented the site with Jo Voordeckers, the JavaFX developer of the site.  Stephan also announced that any JUG can post presentation videos to the new parleys.com site, which up to now has received most of its content from the JavaPolis conferences.
  • An early peek at a design tool for JavaFX in which graphics can be created in Photoshop and Illustrator, and exported for use by a JavaFX program.  This tool is currently named Distiller, and will support the collaboration of graphic designers and software developers.  As a side note, ReportMill is also making some great progress on their JavaFX designer tool.
  • A demo of a three-dimensional multi-player game named MoonTank developed in JavaFX.  One of the demonstrators is Chris Oliver, the founder of JavaFX.

Enjoy the video.  This JavaFX stuff is getting exciting!
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications

Immediate eBook (PDF) download available at the book's Apress site

May 01, 2008

Watch for Falling Blocks: Take TetrisJFX for a Spin!

You may know that I've been progressively building a Tetris game in JavaFX on this blog, the most recent post being Game Over: Improving upon the Compiled JavaFX Tetris Program.  In each post I've shown you the code and pointed out some highlights.  Since then I've added some finishing touches, and would be honored if you've try it out and give me (kind) feedback for improving it further.  The screenshot below shows what TetrisJFX should look like when you click this Java Web Start link.  By the way, you'll need the JRE (Java Runtime Environment) 1.5 or later.  Also, please keep in mind that the JavaFX Script JAR files will be included with the JRE at some point. Until then please understand that when you click this link those JAR files will be downloaded as well, causing a bit of a delay.

Tetrisjfx_w_image_buttons

In addition to clicking the image buttons at the bottom of the game, you can use keystrokes (hover over the images to see tooltips that tell you what the keystrokes are).  In a future version, the arrow keys will be used for game control.  I also plan to provide the ability to cause the current tetromino to fall faster.  By the way, the tetrominoes fall progressively faster as your score increases, so be warned. :-)

170x93_speaker_v4_4 If you have any questions or input for improvements, please post a comment.  Also, if you'll be at JavaOne 2008, please attend my JavaFX Script Programming Language Tutorial session and introduce yourself afterward!

 

Have fun!
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications

Immediate eBook (PDF) download available at the book's Apress site

My Photo

Upcoming Speaking Engagements:


  • Stephen Chin and Jim Weaver speaking about JavaFX Platform

  • Speaking on JavaFX and Java at Øredev in Malmö, Sweden on 2-6 November, 2009

Upcoming JavaFX Training:


  • Developing Secure, Rich Internet Applications Hosted on a Variety of Clients Using JavaFX Technology

Enter your email address:

Delivered by FeedBurner

Available now as early access eBook


  • Click book image above to obtain eBook

Twitter Updates

    follow me on Twitter

    Affiliations:

    DZone Links:


    July 2009

    Sun Mon Tue Wed Thu Fri Sat
          1 2 3 4
    5 6 7 8 9 10 11
    12 13 14 15 16 17 18
    19 20 21 22 23 24 25
    26 27 28 29 30 31  

    Disclaimer:

    • By reading this site, you are agreeing that under no circumstances will Veriana Networks, Inc. or its affiliates be responsible for (1) any information contained on or omitted from the site, (2) any person's reliance on any such information, whether or not the information is correct, current or complete, (3) the consequences of any action you or any other person takes or fails to take, whether or not based on information provided by or as a result of the use of the sites.