Intro to Programming (a.k.a. CS Intro) focuses on getting you hooked into programming through game development. We'll use the Gamemaker environment to write code, telling each object in a game how to act based on a set of events (triggers) and commands (actions). We'll process collisions, keep track of scores, keep track of an object's states, and hopefully create some cool games.
Course Info Slides ( Also posted to the left)
Gamemaker download (2023.8.1.102) - Lab version
You're welcome/encouraged to install this version at home, but do not update when prompted or your version of Gamemaker will not match the lab version.
Gamemaker Concept Review (Cheat Sheet!)
Gamemaker manual (programming page)
Gamemaker Youtube Channels to check out:
Game Development Playlists
By the end of this course students know:
How to create sprites
What Events are
What a create event is
What a step event is
What a keyboard/mouse event is
Differences between down, pressed, and released
global mouse events vs normal mouse events
What the Draw event is
What the collision event is
What an alarm is
What the game/room start/end events are
What Actions are and how they differ from Events
What built-in variables are
What programmer-defined variables are.
What temporary variables are.
What built-in functions are and how they differ from variables.
Random Functions
Movement Functions
Collision Functions
instance functions
Room functions
game functions
alarm functions
draw functions
keyboard/mouse functions
Object Inheritance
Conditionals
Loops (optional)
By the end of this course students will understand that:
Sprites, Objects, and Rooms are the primary assets we'll use.
Sprites, Objects, and Rooms must all have unique names to differentiate them from one another.
Sprites are visual representations of:
Objects (costumes)
Backgrounds
Tilesets
Sprites contain collision & positioning (origin) info
Objects contain Sprites & Events
Events contain linear sequences of action.
By the end of this course students will be able to:
Create Sprites to be the visual representation of an object
Create Objects to be the conceptual representation of an object
Create Rooms to act as levels within a game
Add Events and Actions to Objects, programming them to act in their environment
Program actions that
store data (variables)
Choose options (conditionals)
Add variability (randomization)
Use pre-built commands (functions)
Put all of these items together (Sprites, Objects, Rooms, Events, & Actions) to build a game.
Programming Basics: AnimoGames
Watch the video "How Computers Work: Hardware & Software"
Take notes on how computers work.
Video - TEDx Talks - "Learning to Code is Not Just for Coders" -Â
Article - "9 Benefits of Learning & Teaching Video Game Design"
Website - Gamemaker Website - Tutorials, Tips/Tricks, Marketplace, Showcase
Website - Gamemaker Manual - One-Stop resource on how everything works.
Video - A Beginner's Guide to Gamemaker's Core Building Blocks (stop @ 4:21 - After sprites)
Slides - Gamemaker Intro
Ted Talk - Everyone Can Draw
Article - "How to Make Pixel Art For 2D Games"
Youtube Playlist - AdamCYounis - Pixel Art Class
Video Series - Riot Game Art Education
Slideshow - Sprites Tutorial - Sprite & Image Editor
Slideshow - Making a Background
Slideshow - The Wall Sprite (Simple)
Slideshow - The Bubble Sprite (Intermediate)
Slideshow - Pixel Art (Advanced)
Video on PixelArt with Mega Man Template
Complete the Sprites Assignement
Open Game Art - Find free game sprites/backgrounds
Kenny.nl - Design your own creature, avatar, or airplane
Youtube: Gamemaker - How to Use Events in Gamemaker
Recurring events (Step, Draw)
Triggered Events (Create, Alarms, Collisions, Room Start, etc.)
Gamemaker Manual - Object Events
Youtube: Let's Learn This Together - GMS - All of the GameMaker Events Explained
Walkthrough:
Create a Sprite
Create an object and assign the sprite to the object
Add Object to the room
Add the following events + actions
Key Down - Right (or Key Down - D) - Increase x by 4
Figure out left, up, and down
Mouse Left Down - Jump to random spot on the screen.
Mouse Global Right Down - Jump to mouse's location
Key Concepts
Objects contain events
Events are triggers that occur throughout the game
When the object is created
Every step of the game
When this object collides with a wall
Events contain actions (what to do when the trigger is activated)
Actions are programming commands
x & y represent this object's location in the room
+= means "increase by"
-= means "decrease by"
mouse_x & mouse_y represent the mouse's location
random_range(low, high) & irandom_range(low, high) allow you to generate a random # within a range.
Gamemaker's top-left corner of the room is (0, 0)
x is + as it moves to the right
y is + as it moves down (opposite of what you learned in math)
Watch the 4 minute Bluey video "Robo Bingo" (full clip must be accessed on Disney Plus)
Variables
Instance
Local/Temporary
Game variables
Depricated
Conditionals/Booleans
Loops
You do not have to go with a Zombie Apocalypse theme, but here's the requirements for this project: Top-Down Shooter Game
(a better write up for this will be created later)
This is a program based off the Monte Carlo method for estimating Pi which basically says if you take a circle and square that have the same radius/width and randomly generate a bunch of dots in it, then:
4*(# of dots in circle/total # of dots)
should roughly equal pi. (see https://www.101computing.net/estimating-pi-using-the-monte-carlo-method/#:~:text=The%20area%20of%20the%20circle,of%20points%20within%20the%20circle.)
We can simulate this by:
1. Creating a square room.
2. generating a large # of dots randomly located
within the room. Increase a total dot
counter.
3. If the dots have a distance from the center
of the room that is less than or equal to
the radius of the circle, color them red
and increase a counter. (this will start to
form a circle of red dots)
4. Draw
* the # of dots in the circle
* the # of total dots
* the solution to the Monte Carlo equation
4*(#dotsInCircle/total#dots)
Increasing the spawn rate of the dots will
improve accuracy over time... kind of.
For this project we'll need a:
900x900 room
No background (either remove it or make it invisible)
Spawner object (no sprite)
Dot object (w/ 1x1 sprite)
The spawner needs
Create Event:
2 variables
totalCount (representing the # of total dots created)
circleCount (representing the # of total dots within the circle)
set the depth to -1 to draw on top of all the dots.
Every step
generate a random x value (between 0 & the room's width)
generate a random y value (between 0 and the room's height)
Create a dot at this random x & y location.
Draw
the # of dots within the circle
the total # of dots
the estimated pi value based on the equation give earlier.
The dot needs
Create Event
"if the distance from this x & y to the center x & y is < 1/2 the width of the room, change the image blend to red and increase the spawner's circleCount"
Increase the spawner's total count
Post Draw Event
After the dot has been drawn on the page, we can delete it (because there's no background, the sprite will still show, but the Object will be gone, making it so the program won't slow down over time).
The goal here is to follow the Beginner Gamemaker Tutorial on making "Space Rocks".
Your task:
Follow the instructions step-by-step (Actually READ the document, don't skim it and look for the code because some of the code is example code, not actually stuff you need to write).
You'll be shown 2 versions of code - GML Code (written code), and GML Visual (Drag-and-drop code). Only follow the GML code parts, not the visual parts.
You could also follow the Space Rocks Slides, but make sure you're reading the slides and following only what needs to be followed.
When done, consider exploring additional features you can add to your game. Check out the "How to Mod Space Rocks" webpage.
This section is designed to provide you with a series of short tasks that we often do in games. Hopefully these will help provide you with resources you can come back to as you attempt to create your own games.
Chaser - Follows the mouse, but could be adapted to follow other objects as well.
Youtube - TechPrep - What is Computer Science?
Youtube - How do you Code in Gamemaker?
Youtube - Naming Conventions in Gamemaker - What I Use & Why
Slides - Programming
Slides/Tutorial - Bubble Pop (Part 1) - The Bubble
Slides/Tutorial - Bubble Pop (Part 2) - The Ref
Catch the Clown is a classic beginners game in Gamemaker:
Draw the sprites for the walls and the clown (doesn't have to be a clown, feel free to have Catch the Fruit, Catch the Theif, Catch the Cold, etc.)
Create an object for the wall, then create an object for the clown.
Place walls around the room, ensuring that there's an opening that would allow the clown to wrap the screen. Place additional walls inside the room to bounce off of.
Code the clown to:
Move in a random direction when created.
Bounce off of walls and wrap the screen every step of the game.
When clicked, teleport to a random location, head in a random direction, and increase speed. Gain points.
Display the points.
This project helps students solidify the basics of:
Controlled movement w/ keyboard buttons & the move_and_collide function
Autonomous movement w/ speed & direction
Spawner that brings objects into the room.
Simple autonomous movement is simple. Move in a direction. When you hit a solid object, bounce off of it. When you reach the edge, wrap the screen.
In the Create event:
Set a Speed
Set a Direction
In the Step event:
Bounce off of solid objects
Wrap the screen
*** If you don't have solid objects, you don't need the bounce code.
*** If you don't need to wrap the screen, don't include the wrap code.
*** If you don't need random numbers, use static numbers instead (like 3, or 5.7)
Here's the process for adding keyboard movement to an object
In the Create event:
Set a potential speed (don't use the "speed" as that will make your player move right away. Use "spd" instead)
In the Step event:
Get keyboard inputs and save them into variables
Calculate horizontal and vertical movement amounts
Move using the move_and_collide function
2 objects are needed:
Spawner Object:
Create Event:
Set an alarm to go off in x frames.
When the alarm goes off:
Reset the alarm to go off in x frames.
Add the Spawned Object to the room.
Spawned Object
Does whatever it's supposed to do (if it needs to do something)
*** The initial alarm_set only needs to be put in a create event if you want the alarm to be started right away. You might want your alarm to get set in other locations such as when a mouse is clicked
example to create a "gun cooldown" to limit the speed that the player can shoot their gun: When the mouse is clicked, create a bullet and set canShoot to false. When the alarm goes off, reset canShoot to true.
Article - "6 Valuable Resources When Learning to Code with Gamemaker"
Youtube - TechPrep - Michael
In this project, students will create a program with the following:
Main player that can move left/right/up/down with keypresses
An enemy character that
Moves straight down
Gets destroyed when it passes the bottom of the screen
Restarts the game when it hits the main player (or does some other acceptable option)
A spawner that spawns enemies from the top of the screen, randomly across the width of the screen.
Keep some form of score, such as adding points every time the enemies leave the bottom of the screen and get destroyed.
This example is J. Gosnell's version of Reign of Enemies.
20 Points
Player Movement using the move_and_collide function
Spawner that spawns in enemies
Enemies that move down the screen
Game restarts when the player is hit by the enemy
Enemies get destroyed when they pass the bottom of the screen
Score is displayed - score increases by 1 every time an enemy is destroyed by reaching the bottom of the screen, or by 1 every second (or 10th of a second) they survive in the game.
Extra Credit
Anything above and beyond the points above requirements
Utilizing both - a timer (tracking amount of time you're alive) & a score (tracking how many enemies you avoided getting hit by).
Having 3 lives
Adding some sort of power-up that makes you invincible for 5 seconds
Not immediately starting, but instead stopping all enemy movement and leaving the score in place for 5 seconds before restarting.
Birkel's TODO:Â
Update Pong Slides to use solid bouncing, not all bouncing - currently the ball gets stuck if it hits a wall & paddle @ the same time.
Update Pong Slides for player movement to use the move_and_collide function instead.
Recap on different movement types
Autonomous (speed/direction)
Manual (x/y)
New Concepts
randomize()
Choose()
if statements
while loops
game_restart()
place_meeting()
The following is only the basics on getting a car to start driving around. You'd need to add additional code/objects to make it more interesting.
Youtube: Easy Racing Game
Different movement (jump to mouse)
Coin collecting
Score keeping
Multiple Levels
Classic Dungeon Crawler games are top-down viewing games in which a player moves up/down/left/right+diagonals with controls (in our case, a keyboard) and navigates through a large area (often as a dungeon, labyrinth, or open fields with buildings) to find doors that take you to a new environment (deeper into the cave/dungeon, or to a new area of the world). The Legends of Zelda - Link's Awakening is a good example of this. In these environments you have to navigate a series of puzzles (levels) to get to the exit. In most cases you get to fight the enemies, but in ours we're simply going to try avoiding all the obstacles.
* Note: There are versions of dungeon crawling games that are in the 1st person, but I'm focusing on more traditional 2D versions of Dungeon Crawlers in my example.
In this project, students will create a program with the following:
Enemies that march back and forth (sentinels/sentry/marchingEnemy)
4 Labyrinth style rooms (maze-like, but with space enough to make movement easy)
Coins to collect
Ref to track & display your score and take it to the next room (persistent)
A door
A trap this could be something that doesn't move, it could be spikes that come in and out of walls, etc.
A chasing enemy that follows you throughout the game
Main playerÂ
Moves left/right/up/down with keypresses (use the move_and_collide function)
When collides w/ coins, destroy the coins and give the ref points
When collides w/ enemy/chaser/trap game (or room) restarts
When collides w/ door, goes to the next room
Chasing enemy doesn't move until you get within a certain distance of it, then it starts to move towards you (until you get far enough away it can no longer "see" you).
A cannon that constantly fires across a space (introducing timers)
A Camera that follows the Player (If we do this as a class, it won't count as extra credit)
Special Walls & a Switch
When the player collides w/ the switch, the special walls disappear (giving you access to coins or the door)
In the above image, the following shapes represent
Blue Square - Player
Yellow Circle - Coin/Collectible
Red Square - Simple Autonomous (Marches back and forth or up and down)
Gray Square - Walls
Brown Square - Door
Not shown:
Trap object
Chaser
Ref/Score
Extra Credit
Additional Projects
Duck Hunt
Breakout/Brick Breaker
Bomberman
Hangman
Mastermind
Wordle (Hangman meets Mastermind)
Frogger
Whack a Mole
Fruit Ninja
Tic Tac Toe
Rock Paper Scissors
Guess My Number
Picture Puzzle
Pacman (Tutorial below - not a beginner project)
In this project, students will focus on:
point-distance to point towards something
instance_create to create projectiles (bullets)
global mouse event vs. regular mouse events
simple if statement
simple alarm for bullet reload time (slow down shots per second)
***Under Construction***
Part 1: Build a device that resembles a firework sparkler.
Wand/stick
When mouse is clicked, Spawns sparks
Sparks launch into random directions (360 degrees)
Gravity pulls sparks down
Destroy sparks when pass bottom of screen
Part 2: Build a Firework
Invisible launcher at bottom of screen
Timerto launch firework
Firework moves to the top of the screen (with a random speed)
Gravity slows down firework
When firework reaches certain point/time/velocity, explode (like sparkler, but for a moment)
Additional Projects
Flappy Birds
Missile Command
Plane Dodge
1945
Birkel's Platformer Instructions
Every year someone comes up with some new Platformer Tutorial on Gamemaker.
Step 1 - Movement
Here's a really simple one recently put out specifically on platformer movement (does not cover enemies, projectiles, etc.)
Alternatively, you could follow this one on Movement (Only follow GML code, not the drag-and-drop code)
Could also use alternative platformer tutorial's such as Shaun Spalding's platformer Tutorial
Step 2 - Enemies
Step 3 - Projectiles
Step 4 - Collisions
Step 5 - Camera
Step 6 - Fun
Here's some things you should do to make sure you understand what you need to know about the final:
Make an object that moves autonomously using speed & direction, wrapping the screen & bouncing off solid objects.
Make an object that moves by chasing something (like the mouse, or another object).
Make an object that moves with key presses (WASD or arrow keys). It should calculate horizontal & vertical movements then move using the move_and_collide function.
Make an object that when clicked on will teleport (change in x & y) to a random location within the room's size (room_width, room_height).
You should be able to collect items and track points in a game (points can be earned by more than just collecting coins) .
When tracking points, there are 2 primary ways to do it and you need to know how to do both:
Objects track their own points (great when you have multiple players, each with their own score)
A Ref or Game object tracks points (great when you want your points to carry over from room to room).
Basic steps
Create event (player or ref object) - set points to 0.
Draw event (player or ref object) - draw text to the screen
If the player is tracking his own points, draw_self().
When collectible is touched by the player
The coin/collectible should disappear
Points should be awarded to whoever is tracking the points.
Other ways to score points include (but are not limited to):
destroying an enemy
clicking on an object
colliding with an object
surviving for a certain amount of time
Many times you can get away with simply using collision events, but you should know how to use collision functions(functions that check for collisions) and the differences between them.
The primary collision functions are:
place_empty - specified location is empty (no objects there)
place_free - specified location is free (no solid objects there)
place_meeting - specified location contains a specific object/instance.
Each of these return true or false
They also each have an opposite using the ! operator:
!place_empty - specified location is NOT empty (there is an objects there)
!place_free - specified location is NOT free (there is a solid objects there)
!place_meeting - specified location DOES NOT contains a specific object/instance.
These functions are usually used with if statements:
if(place_empty(x, y))
if(!place_free(x, y))
if(place_meeting(x, y, oEnemy))
This unit focuses on quick tutorials to connect to a specific topic.
Worksheet - Push of a Button & Room Jump
Score
Alarms
Collisions
More Project Ideas
Snake
Space Invaders
Rock Paper Scissors
Fish (Nim)
Google Pony Express
Centipede
Smarter AI - Learn how to make an enemy that makes priority based decisions.
Building a Beat 'Em Up in Game Maker (Old version of Gamemaker, need to modify some code to match new functions).
Videos
Youtube - Let's Learn GameMaker Studio (older resource)
Design Process
Curriculum
Sprite Resources
Open Game Art - Find free game sprites/backgrounds
Creature Mixer (Kenny.nl) - Design a creature
Articles
12/22 - Gamemaker is Free for Education (No Export Options)
Article - "9 Benefits of Learning & Teaching Video Game Design"