0% found this document useful (0 votes)
47 views32 pages

Lecture 2: Breakout: Colton Ogden [email protected] - Edu David J. Malan Malan@harvard - Edu

The document summarizes 13 lecture updates for a Breakout game project in CS50. It discusses topics like sprite sheets, procedural layouts, collision detection, particle systems, saving high scores, and more. New functions introduced include creating quads from sprite sheets, drawing textures to quads, checking for collisions, creating particle systems, reading and writing save files, and more. The next lecture topics and assignment 2 are outlined which involves adding powerups, resizing the paddle, and locked blocks with keys.

Uploaded by

YSR Sports
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views32 pages

Lecture 2: Breakout: Colton Ogden [email protected] - Edu David J. Malan Malan@harvard - Edu

The document summarizes 13 lecture updates for a Breakout game project in CS50. It discusses topics like sprite sheets, procedural layouts, collision detection, particle systems, saving high scores, and more. New functions introduced include creating quads from sprite sheets, drawing textures to quads, checking for collisions, creating particle systems, reading and writing save files, and more. The next lecture topics and assignment 2 are outlined which involves adding powerups, resizing the paddle, and locked blocks with keys.

Uploaded by

YSR Sports
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

GD50

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

HighScoreState EnterHighScoreState GameOverState

PaddleSelectState ServeState PlayState

VictoryState
breakout0
“The Day-0 Update”
Project Organization
Bad :( Great! :D
breakout1
“The Quad Update”
Sprite Sheet
Quads
breakout1: New Functions

● love.graphics.newQuad(x, y, width, height, dimensions)


○ Specify rectangle boundaries of our Quad and pass in the dimensions
(returned via image:getDimensions on whichever texture we want to make a
Quad for.
● love.graphics.draw(texture, quad, x, y)
○ Variant of love.graphics.draw, which we’ve seen, but this time we can pass
in a Quad to draw just the specific part of the texture we want, not the
entire thing!
breakout2
“The Bounce Update”
breakout3
“The Brick Update”
breakout4
“The Collision Update”
Paddle Collision

● 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)

if left edge of ball is outside brick and dx is positive:


trigger left-side collision
elseif right edge of ball is outside brick and dx is negative:
trigger right-side collision
else if top edge of ball is outside brick:
trigger top-side collision
else
trigger bottom-side collision
Alternative Way (Better)

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.

More LÖVE particle system functions and info here:

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

● Create a Powerup the Player can grab that spawns two


additional Balls for the current level.
● Add growing and shrinking to the Paddle when they gain
enough points or lose lives (included in the sprite sheet!).
● Add locked blocks and key drops (in the sprite sheet as
well) to spice up the level generation.
See you next time!

You might also like