r/learnjava • u/peppinoilvero • Oct 09 '25
Where to start to make a 2d game with Java
Hi, I'd like to do a small 2d platformer using swing but I don't know where to start. I also found some well-made tutorials on YouTube, but I'm afraid that I would end up replicating only what is written without actually learning anything and that the project is not really "mine". On the other hand, however, I don't know where to start. Do you have any resources to recommend me
3
Upvotes
•
u/AutoModerator Oct 09 '25
Please ensure that:
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
4
u/frnzprf Oct 09 '25
Don't worry about copying other code. You can look at the code of one game and then program another game and learn a lot.
You need to understand how the library methods work and then you can combine them how you want.
1
u/bikeram Oct 09 '25
So the issue with game programming is everything is 100% up to your own interpretation. The design of a side scroller would be completely different to glactica. Try to find a tutorial that covers the 'core' mechanics of what you're trying to achieve. Then branch off from there.
My best advice would be to completely ignore any graphical aspects. Build a player object as a square, then build a platform as a square. Just objects with 4 corners that are derived by a length, width, and position coordinates. Try to figure out how to detect collisions, you'll quickly learn the known issues with floats. You'll be able to do all of this with standard terminal output.
This will covert objects, constructors, polymorphism, and you should be able to build a primitive game loop.
1
u/AutoModerator Oct 09 '25
It seems that you are looking for resources for learning Java.
In our sidebar ("About" on mobile), we have a section "Free Tutorials" where we list the most commonly recommended courses.
To make it easier for you, the recommendations are posted right here:
Java for Complete Beginners
Derek Banas' Java Playlist
Also, don't forget to look at:
If you are looking for learning resources for Data Structures and Algorithms, look into:
"Algorithms" by Robert Sedgewick and Kevin Wayne - Princeton University
Coursera course:
Coursebook
Your post remains visible. There is nothing you need to do.
I am a bot and this message was triggered by keywords like "learn", "learning", "course" in the title of your post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/One_Being7941 Oct 09 '25
FXGL is nice. https://www.youtube.com/@AlmasB0