Broken Tetris

Here is another simple Java FX game: Broken Tetris. This game looks like Tetris, except the dropped bricks won't stay in place.

Objective is to make blocks of the same color hit each other. Once two blocks of the same color collide, they disappear. Be careful: some colors may look alike!

Controls: Left-Right to move the brick, Up to rotate.

See how many points you can get...

A few Java FX UI controls are used to set parameters for the game. You can control gravity, friction and restitution. Or increase the number of colors to make the game more challenging. You can also turn block rotation off to make them behave more like Tetris blocks.

The source code for the game is available here: Main.fx This demonstrates integration of Java code into an FX application code: physics engine is implemented using Phys2D library.

Note a couple of useful FX techniques
- Node transforms are used to rotate the blocks and move them around
- Opacity animation makes the colliding blocks melt and disappear.
- Paiting blocks with radial gradient gives them a more interesting appearance

Click on the image below to start the game.

Comments:

30 seconds startup time on a modern win 7 laptops!

Back to the early 90s...8086-6800 CPUs performance...

Posted by fx on February 06, 2010 at 02:37 AM PST #

30 seconds must be the time it takes to download the FX runtime. It only happens when the first FX application is run. The game loads in 3-4 seconds on my 5-year-old desktop machine.

Posted by Mikhail Gorshenev on February 06, 2010 at 03:10 AM PST #

then users should be aware that runtime is being downloaded, and it will not do it again. But i liked the application!

Posted by guest on February 06, 2010 at 03:56 PM PST #

Excellent!

Posted by Sergey Malenkov on February 07, 2010 at 02:03 PM PST #

Awesome! Finaly a cool JavaFX Game!

Posted by Jan Sterba on February 09, 2010 at 03:54 AM PST #

2 sec. load time on 1 year old laptop. Tetris i've never seen before. Good work.

Posted by Marcin on February 09, 2010 at 05:56 AM PST #

Less than 30s on a very old (6 years!) desktop computer. Of course, I have the runtime in cache...

This is the most original Tetris game I ever saw! :-) And well made too.

Saw some glitches: an exception from the media player (no frankieloop2.wav). The number of colors slider should display the value.
I saw some brick overlays (probably a Phys2D glitch). And after some 40+ bricks, they started to jump, then to appear directly on their resting place...
And the applet is a bit too tall, at least for Firefox with two rows of tabs...

Good work anyway!

Posted by PhiLho on February 11, 2010 at 04:07 AM PST #

I had to take the music out as the blogging site won't allow big jar files. I think block overlaps are mostly due to Phys2D bugs though sometimes these can be caused by moving or rotating a block so that it overlaps with another. The engine quickly corrects this in most cases though.

Posted by Mikhail Gorshenev on February 11, 2010 at 04:20 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

user12608660

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today