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 ...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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. ...
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 ...
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:
...
1
vote
Breakout paddle bouncing
In your code you have
if (dot.getCenterY() <= brick.getY() || dot.getCenterY() >= brick.getY()+brick.getHeight())
dotVelY *= -1;
...
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 ...
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 ...
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, ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
javafx × 29java × 20
3d × 4
2d × 3
animation × 3
rotation × 3
mathematics × 2
game-mechanics × 2
lighting × 2
game-loop × 2
card-game × 2
mvc × 2
snake × 2
collision-detection × 1
algorithm × 1
graphics × 1
ai × 1
tilemap × 1
path-finding × 1
gui × 1
input × 1
tiles × 1
matrix × 1
optimization × 1
assets × 1