Skip to main content
3 votes

JavaFX - How do I create a health bar?

I couldn't find your approach of a health bar, but I would suggest a simple approach for the start, something like this: 1) Add a Rectangle to your scene for each ...
kalidali's user avatar
  • 333
3 votes
Accepted

How to structure tic tac toe game loop (or equivalent simple turn based game)?

First of all: M-VC Separate Game from GUI - a suitable approach might be M-VC (Model-View/Controller). If you do it right, there should be NO REFERENCE on the game towards the controller, but the ...
Martin Frank's user avatar
2 votes
Accepted

2d zooming function using transformation matrix

I don't know javafx, but I can tell you the math. An affine transformation is a linear transformation combined with a translation. e.g. ...
Lærne's user avatar
  • 1,095
2 votes

Adding JavaFX GUI to an MVC based terminal card game

if you want to implement a minimal M-VC you have to structure your application kind a like this: (This is only an example Diagramm) Model The Game is your Model. It stores information about who's ...
Martin Frank's user avatar
2 votes

How to reset snake in javafx game?

You are adding the Snake body to your canvas but you never remove it. That's why reset() won't clear your Snake. You're adding the Snake body within your ...
Martin Frank's user avatar
1 vote

How to add lighting to a 2D Tile-based game in JavaFX?

first of all, if you want to apply effects like lighting to your scene/canvas then PixelWriter is a terrible idea, because of the unevitable O(n^2) created by the ...
kalidali's user avatar
  • 333
1 vote
Accepted

How to control JavaFX's animations execution order when animations "queue" is being altered in run-time?

I have no experience with JavaFX, but for what you described, I guess the most natural solution is to have a command queue which is completely independent from the specific animation technology. Let ...
Doc Brown's user avatar
  • 126
1 vote

Snake game steering with Java FX

What you need is to store a path. Keep a collection of positions the head has been. On each tick you will add a new position to the collection. You may also remove positions that are too far back. ...
Theraot's user avatar
  • 28.2k
1 vote
Accepted

JavaFX AnimationTimer VS Swing Game Loop

Application is part of JavaFX and therefore can't be used without it and since a JavaFX app relies on the lifecycle of this class and JavaFX requires a class that ...
Bálint's user avatar
  • 15.1k
1 vote

JavaFX - How do I create a health bar?

To create a health bar, you want to have a value representing the percentage of health you have. This value can be calculated as such: ...
Darin Beaudreau's user avatar
1 vote

Breakout paddle bouncing

In your code you have if (dot.getCenterY() <= brick.getY() || dot.getCenterY() >= brick.getY()+brick.getHeight()) dotVelY *= -1; ...
Eddie K's user avatar
  • 11
1 vote
Accepted

Breakout paddle bouncing

The ball bounces "off" the paddle but because it's still inside the paddle it bounces again back into, and again, and again. This is what causes the jittering. The solution is to check the direction ...
Stephane Hockenhull's user avatar
1 vote

How to render a large tile-based 2D world efficiently (using JavaFX/ScalaFX or more generally)

You can draw your tiles with the Canvas node. You can still use your tile set for this method. You just have to call the ...
kalidali's user avatar
  • 333
1 vote
Accepted

How can I `draw` something on a JavaFX WritableImage?

You can use getGraphics in BufferedImage and do all the drawing job in the BufferedImage, ...
snow1w's user avatar
  • 26
1 vote

Applying animations to 2x2 Rubik's cube

I just realize this. You can not repeat elements in a group. Once you put them in a group they stop belonging to the other group. In this case because left and right are defined last they work. If you ...
René Mac Kinney's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible