Lecture 2: Breakout: Colton Ogden [email protected] - Edu David J. Malan Malan@harvard - Edu
Lecture 2: Breakout: Colton Ogden [email protected] - Edu David J. Malan Malan@harvard - Edu
Lecture 2: Breakout
Colton Ogden
[email protected]
David J. Malan
[email protected]
http://cdn.cs50.net/2015/x/psets/3/pset3/pset3.html
Topics
● Sprite Sheets
● Procedural Layouts
● Managing State
● Levels
● Player Health
● Particle Systems
● Collision Detection Revisited
● Persistent Save Data
But first, a demo!
Our Goal
Breakout State Flow
StartState
VictoryState
breakout0
“The Day-0 Update”
Project Organization
Bad :( Great! :D
breakout1
“The Quad Update”
Sprite Sheet
Quads
breakout1: New Functions
● Take the diff between the ball’s x and the paddle’s center, which is paddle.x + paddle.width / 2 - ball.x; use
this to scale the ball’s dx in the negative direction.
● Perform the operation on either side of the paddle based on paddle’s dx; if on the right side, the differential will be
negative, so we need to call math.abs to make it positive, then scale it by a positive amount so dx becomes positive.
centerDelta
Brick Collision (Simple)
https://github.com/noooway/love2d_arkanoid_tutorial
https://github.com/noooway/love2d_arkanoid_tutorial/wiki/Resolving-Collisions
breakout5
“The Hearts Update”
breakout6
“The Pretty Colors Update”
breakout7
“The Tier Update”
breakout8
“The Particle Update”
breakout8: New Functions
● love.graphics.newParticleSystem(texture, particles)
○ Takes in a particle texture and maximum number of particles we can emit and
creates a particle system we can emit from, update, and render.
https://love2d.org/wiki/ParticleSystem
breakout9
“The Progression Update”
breakout10
“The High Scores Update”
breakout10: New Functions
● love.filesystem.setIdentity(identity)
○ Sets the active subfolder in the default LÖVE save directory for reading and
writing files to.
● love.filesystem.exists(path)
○ Check if a file exists in our save directory.
● love.filesystem.write(path, data)
○ Writes data, as a string, to the file location at path.
● love.filesystem.lines(path)
○ Returns an iterator over the string lines in a file at path, located in our
active identity path.
breakout11
“The Entry Update”
breakout12
“The Paddle Select Update”
breakout13
“The Music Update”
Next Time...
● Basic Shaders
● Anonymous Functions
● Tweening
● Timers
● Solving Matches
● Procedural Game Grids
● Sprite Art and Palettes
Assignment 2