How to Write a Platformer Game in Java
Build a side-scrolling game in Java across 14 video lectures, with slides and labs.
In this short video series course, we will learn how to write a platformer (or side-scrolling) game like Super Mario. We will write this game from scratch with very basic algebra without relying on any physics engine!
Below are all of the resources including video lectures, code, and labs. I created this curriculum for my AP Computer Science A course during the current school closures due to the coronavirus. Subscribe to my channel.
If you teach AP Computer Science A and would like solutions, feel free to contact me directly.
1) Game PreviewYoutube — 1) Game Preview
A preview of the platformer game that we will write.
2) Introduction to ProcessingYoutube — 2) Introduction to Processing
A quick introduction to Processing, a software sketchbook that allows us to easily create animations/games with simple Java code.
3) Creating the Sprite ClassYoutube — 3) Creating the Sprite Class
Making our game object-oriented by creating the Sprite class, which is the superclass of all of our game objects.
4) Controlling a Sprite Using the KeyboardYoutube — 4) Controlling a Sprite Using the Keyboard
Controlling our player using the keyboard.
5) Creating the Game Map by Using a CSV FileYoutube — 5) Creating the Game Map by Using a CSV File
Create a game map or level stage using a comma-separated values (CSV) file.
6) Collision DetectionYoutube — 6) Collision Detection
Detecting collision between sprites. We'll implement the checkCollision method which returns true if two sprites collide and the checkCollisionList method which returns the collision list between a sprite and a list of sprites.
7) Resolving Platform Collisions Part 1Youtube — 7) Resolving Platform Collisions Part 1
Understanding the math behind resolving platform collisions. This is the most important algorithm in writing this game.
8) Resolving Platform Collisions Part 2Youtube — 8) Resolving Platform Collisions Part 2
Implement the code to resolve platform collisions.
9) Add JumpingYoutube — 9) Add Jumping
Add in jumping ability to the player.
10) ScrollingYoutube — 10) Scrolling
Add scrolling to the game.
11) Animating the Sprite(uses inheritance)Youtube — 11) Animating the Sprite(uses inheritance)
Create AnimatedSprite class for simple animated Sprites. AnimatedSprite inherits from the Sprite class.
12) Creating Enemies(uses inheritance)Youtube — 12) Creating Enemies(uses inheritance)
Creating animated enemies by inheriting from the AnimatedSprite class.
13) Animating the Player(uses inheritance)Youtube — 13) Animating the Player(uses inheritance)
Create Player class which inherits from the AnimatedSprite class to animate the player.
14) Finish Up GameYoutube — 14) Finish Up Game
Finish up the game by adding game over screen and restart feature.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.