Free online course How to make a game Platformer 2D in Java
Duration of the online course: 17 hours and 52 minutes
New
Build your own 2D platformer in Java with this free online course—game loop, collisions, animations, enemies and menus, plus a certificate-ready project.
In this free course, learn about
Set up a Swing window & GamePanel correctly (setVisible timing) to avoid blank rendering
Capture keyboard input reliably: KeyListener setup, focus handling, and resetting input on focus loss
Implement a controllable game loop with fixed UPS/FPS, delta accumulators, and consistent timing
Load sprite atlases from the classpath and render scaled subimages in Java2D
Implement GameStates with enums/interfaces for menu, pause, gameplay, and overlays
Create UI components: menu buttons, URM buttons, audio/music/SFX toggles, and options sharing
Add scrolling camera & parallax backgrounds (cloud layers) for larger levels
Build enemy systems: enemy manager, patrol edge checks, aggro/attack triggers, and health bars
Implement objects/traps/cannons/projectiles with correct hitboxes, sequences, and tile collisions
Handle death/restart flows and bug fixes; add character selection via maintainable animation metadata
About the free online course
Create a complete 2D platformer from scratch while strengthening your Java fundamentals and building practical game development skills. This free online course guides you through the real decisions behind a playable game: how to open a reliable Swing window, capture responsive input, and draw smooth graphics without flicker. You will move beyond isolated snippets and learn how systems fit together to form a game that feels tight, readable, and expandable.
Step by step, you will shape a solid foundation around timing and performance. You will implement a controllable game loop, understand why separating updates from rendering matters, and keep motion consistent across different machines. From there, you will bring the world to life with sprite atlases, animation control, and a player that moves convincingly with gravity, jumping, and robust collision rules that prevent clipping through tiles.
As the project grows, you will learn how to organize code so it stays maintainable: using game states to switch cleanly between gameplay, menus, pause overlays, options, and game over screens. You will also tackle essential game feel features such as scrolling levels, parallax backgrounds, UI buttons with proper visual states, and audio that behaves predictably across screens.
The course rounds out the experience by adding enemies with patrol and attack behavior, interactive objects, traps, cannons, projectiles, health bars, multiple levels, and tools to build your own stages from images. Along the way, you will practice debugging and polishing edge cases such as focus loss, state resets after restart, and consistent collision checks. By the end, you will have a working platformer framework you can extend with new characters, levels, and mechanics—ideal for a portfolio piece or a starting point for your next game.
Course content
Video class: A New Beginning - Episode #01 - Java Game Development Tutorial27m
Exercise: When setting up the Swing window for a Java 2D platformer, where should you call setVisible(true) to avoid a blank screen?
Video class: INPUTS - Episode #02 - Platformer Game Tutorial Java20m
Exercise: Which step ensures your GamePanel receives keyboard events after adding a KeyListener?
Video class: GAME LOOP - Episode #03 - Platformer Tutorial Java28m
Exercise: Which game loop approach gives consistent, controllable FPS in a Java Swing 2D platformer?
Video class: HOW TO MAKE A Game Loop in Java - Platformer GameDev 202200m
Exercise: What kind of game loop should you implement for a 2D Java platformer and why?
Video class: IMAGES - Episode #04 - Platformer Tutorial Java15m
Exercise: How do you correctly load a sprite atlas from the classpath and render a 64x40 subimage at double size in a Java 2D platformer panel?
Video class: ANIMATIONS - Episode #05 - Platformer Tutorial Java29m
Exercise: What does the animation speed variable control in the 2D platformer animation loop?
Video class: GAME LOOP 2.0 - Episode #06 - Platformer Tutorial Java14m
Exercise: Why separate UPS from FPS and use delta accumulators in a 2D platformer game loop?
Video class: PLAYER CLASS - Episode #07 - Platformer Tutorial Java27m
Exercise: What is the correct way to prevent the player from continuing to move when the game window loses focus?
Exercise: In a 2D Java platformer, the player continues moving upward after restarting if the restart occurs mid jump. What is the correct state reset to prevent this?
Video class: THE FINAL EPISODE - Platformer Tutorial Java12m
Exercise: Most efficient way to parse a level image into game data in a basic Java 2D platformer
Video class: How To BUILD YOUR OWN LEVEL - Platformer Tutorial EXTRA21m
Exercise: Which pixel component decides which terrain tile sprite is drawn in the PNG based level system?
Video class: How To Add CHARACTER SELECTION - Platformer Tutorial EXTRA1h12m
Exercise: What is the most maintainable way to support multiple characters with different animation rows and frame counts in a Java 2D platformer
How do you create a smooth game loop with separate UPS and FPS in a Java Swing 2D platformer?
Use delta accumulators: update game logic at a fixed UPS and render independently at a target FPS. This keeps movement and physics consistent even when rendering speed varies.
How can a Java 2D platformer load and draw a sprite atlas from the classpath?
Load the image with getResourceAsStream, create a BufferedImage, then use getSubimage to select a sprite. Draw it with Graphics.drawImage using scaled destination dimensions.
How is horizontal camera scrolling implemented in a Java platformer?
Track an x-level offset and subtract it from world objects when drawing. Update the offset when the player passes a screen threshold, while clamping it to level bounds.
Ready to get started?Download the app and get started today.