Long Nguyen
Resources and online courses for Math and Computer Science.
How to Write a Platformer(e.g. Super Mario) Game in Java
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 Preview
2) Introduction to Processing
- Slides (PPT)
- Bouncing Ball Lab (Friendly Version, More Challenging Version) Given a ball PNG image, simulate a ball bouncing on the screen.
3) Creating the Sprite Class
- Slides (PPT)
- Sprite Class Lab (Friendly Version, More Challenging Version) Implement the Sprite class. This is the base class for all game objects.
4) Controlling a Sprite Using the Keyboard
- Slides (PPT)
- Controlling A Sprite Using Keyboard Lab (Friendly Version, More Challenging Version) Control a sprite with the keyboard.
5) Creating the Game Map by Using a CSV File
- Slides (PPT)
- Design CSV Game/Stage Map Lab No coding lab. Read code and modify CSV file to create a stage map.
6) Collision Detection
- Slides (PPT)
- Collect Coins Lab (Friendly Version, More Challenging Version) Tank moves around on the screen and collect coins. Coin counter is display and updated on the screen.
7) Resolving Platform Collisions Part 1
8) Resolving Platform Collisions Part 2
- Slides (PPT)
- Resolving Platform Collisions Lab Add gravity and resolve platform collisions. This is the most important algorithm in the game.
9) Add Jumping
- Slides (PPT)
- Jumping Lab Add jumping feature to our game. You'll need your solution from the previous Resolving Platform Collisions Lab.
10) Scrolling
- Slides (PPT)
- Platformer Scrolling Lab Implement scrolling for the platformer game.
- (Optional) Scrolling Lab (Friendly Version, More Challenging Version) Implement scrolling. Draw left/right/top/bottom boundaries to visualize scrolling.
11) Animating the Sprite(uses inheritance)
- Slides (PPT)
- Animated Sprites Lab (Friendly Version, More Challenging Version) Animate the coins from the previous Collect Coins lab.
12) Creating Enemies(uses inheritance)
- Slides (PPT)
- Create Enemies Lab (Friendly Version, More Challenging Version) Create an ArrayList of Enemy objects using CSV file. Each enemy has a different walk length between its left and right boundaries.
13) Animating the Player(uses inheritance)
- Slides (PPT)
- Animating the Player Lab (Friendly Version, More Challenging Version) Animate a simple version of the player to walk left and right. No jumping or platform collisions.
14) Finish Up Game
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.