Java Virtal Machine.net

[ News ] rss

February 01, 2011

Mark Wielaard: New GPG key. Finally created a new GPG key using gnupg. The old one was a DSA/1024 bits one and 8 years old. The new one is a RSA/2048 bits one. I will use the new one in the future to sign any release tarballs I might create. pub 2048R/57816A6A 2011-01-29 Key f...

More »

February 01, 2011

Andrew Hughes: [SECURITY] IcedTea6 1.7.8, 1.8.5, 1.9.5 Released!. We are pleased to announce a new set of security releases, IcedTea6 1.7.8, IcedTea6 1.8.5 and IcedTea6 1.9.5. This update contains the following security updates: The IcedTea project provides a harness to build the source code from OpenJDK6 u...

More »

April/2024
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
2122232425 2627
282930    

[ Archives News
for 'Java Technology' ]

home > news > java technology > javafx's game of life

JavaFX's Game of Life

There is an unwritten tradition that Hector Conway's Game of Life must be implemented in every programming language and every GUI toolkit. Well, OK I just invented this tradition, but it's a smart introduction and Life is one of the easiest games / cool animations you can program. But it's not too simple that we can't learn a few important things about JavaFX... My goal: a good-looking and feature-complete version of the Game of Life (GOL), but keeping code simple, short, "canonical". I won't resort to low-level optimizations (e.g. reaching to JavaSE APIs), but I may use high-level ones (e.g. good algorithms, careful selection of JavaFX features). How well JavaFX handles the task the way it is indented to be used? So, let's start. The complete app is short enough that it fits in this blog, in a few small pieces. class World {    var SIZE:Integer on replace { reset() }    var cells:Boolean[];    var gen:Integer;    var pop:Integer;    function reset () { gen = pop = 0; cells = for (i in [0 ..< SIZE * SIZE]) false }    bound function isLive (x:Integer, y:Integer)   { cells[y * SIZE + x] }    function flip (x:Integer, y:Integer):Void      { cells[y * SIZE + x] = not cells[y * SIZE + x] } The World class implement the game's data model and the GOL algorithm. The c...


Date: May, 21 2010
Url: http://www.java.net/blog/opinali/archive/2010/05/21/javafxs-game-life


Others News

©2002-2019Java-Virtual-Machine.net website maker | website designer | free icon fonts | easy free website builder | bootstrap dropdown menu