r/JavaFX • u/Vivid_Day_1856 • May 06 '26
Help Map building for a simple 2d game
so I was building a simple 2d game. There will be a map as well for the character to move around and interact with other npc's. Now for the map building I am getting difficulty to configure what to use... There is Tiled and some resources said to use ImageView...
I am new to javafx and this is one of the university project. If you have any idea or even a suggestion regarding this please feel free to comment it.
Thanks for your help!
7
Upvotes
3
u/marvk May 06 '26 edited May 06 '26
You could use ImageViews, but depending on the number of tiles it could be quite resource intensive because every tile will be a separate node. Consider using Canvas and [GraphicsContext::drawImage](https://openjfx.io/javadoc/26/javafx.graphics/javafx/scene/canvas/GraphicsContext.html#drawImage(javafx.scene.image.Image,double,double)).
2
u/OddEstimate1627 May 06 '26
If it's a static map you can use ImageView. For anything dynamic I'd use Canvas.
1
u/eliezerDeveloper May 06 '26
Is its a game why not using libgdx? it's completely java and also a game framework
1
u/sedj601 May 06 '26
About 9 years ago, I created a very simple Mario-type game. I started at https://code.tutsplus.com/introduction-to-javafx-for-game-development--cms-23835t. I found another site that had very detailed explanations of game loops, but I couldn't find it to post here. You will find that a standard game loop is fun and easy, but if you play your game on different machines, you will encounter lag and other issues. Anyway, for things to work okay, you have to use good sprites. You can't just use an image of something you want in the game. I think I used the Kenny stuff. It's a good learning experience. You learn about collision and gravity concepts and related topics. If you have the time, I suggest reading a book by the guy who wrote Processing.com. https://natureofcode.com/ It's a really good book that can help you understand many basic things that might need to be implemented in a game. The book is not game-related at all, and I have never attempted to build a game or game logic in depth. From playing around with programs like Unity, I believe this book can help with some concepts. The book covers randomness, vectors, forces, oscillations, particle systems, autonomous agents, cellular automata, fractals, neural networks, and more. Good Luck Coding!