gd50 lecture 3: match-3 · lecture 3: match-3 colton ogden [email protected] david j. malan...

117
GD50 Lecture 3: Match-3 Colton Ogden [email protected] David J. Malan [email protected]

Upload: others

Post on 17-Apr-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

GD50Lecture 3: Match-3

Colton [email protected]

David J. [email protected]

Page 2: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural
Page 3: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural
Page 4: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

● Anonymous Functions● Tweening● Timers● Solving Matches● Procedural Grids● Sprite Art and Palettes

Topics

Page 5: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

But first, a demo!

Page 6: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Our Goal

Page 7: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

timer0 “The Simple Way”

Page 8: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

timer1 “Also The Ugly Way”

Page 9: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

timer2 “The Clean Way”

Page 10: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Timer library: functions

● Timer.every(interval, callback)○ Calls `callback`, which is a function, every `interval`, where `interval` is

measured in seconds; this happens indefinitely.

● Timer.after(interval, callback)○ Calls `callback` after `interval`, but only does this one time.

https://github.com/airstruck/knife/blob/master/readme/timer.md

Page 11: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

tween0 “The Simple Way”

Page 12: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

tween1 “A Better Way”

Page 13: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Knife Library

https://github.com/airstruck/knife

Page 14: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

● knife.behavior (state machines)● knife.bind (bind arguments to functions)● knife.chain (flatten asynchronous code)● knife.convoke (flatten coroutine-based async code)● knife.event (dispatch and handle events)● knife.memoize (for memoization)● Knife.serialize (stores data structures as strings)● knife.system (an entity-component system)● knife.test (testing framework)● knife.timer (timers and tweens)

Knife Modules

Page 15: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

tween2 “The Timer.tween Way”

Page 16: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Timer library: functions, p.2

● Timer.tween(duration, definition)○ Interpolates values specified in the `definition` table over some length of

time `duration`, where the values in `definition` are the final values of

the transformation.

https://github.com/airstruck/knife/blob/master/readme/timer.md

Page 17: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

chain0 “The Simple (and Hard... and Ugly) Way”

Page 18: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

chain1 “The Better Way”

Page 19: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Timer library: functions, p.3

● Timer:finish(callback)○ A function we can call after any `Timer` function (`tween`, `every`,

`after`, etc.), which calls `callback` once that function has completed.

Useful for chaining any of the aforementioned function types together.

https://github.com/airstruck/knife/blob/master/readme/timer.md

Page 20: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

swap0 “Just a Board”

Page 21: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural
Page 22: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

swap1 “The Static Swap”

Page 23: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

swap2 “The Tween Swap”

Page 24: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 25: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 26: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 27: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 28: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Match Found!

Page 29: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 30: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 31: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 32: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 33: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

No Matches :(

Page 34: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 35: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 36: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 37: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 38: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

No Matches :(

Page 39: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 40: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 41: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 42: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 43: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

No Matches :(

Page 44: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 45: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 46: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 47: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Match Found!

Page 48: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches

Page 49: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 50: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 51: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 52: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 53: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

No Matches :(

Page 54: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 55: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 56: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Match Found!

Page 57: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 58: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 59: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

:(

Page 60: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

:(

Page 61: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 62: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 63: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 64: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Page 65: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Calculating Matches, p.2

Match Found!

Page 66: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 67: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 68: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 69: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 70: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 71: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 72: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

No spaces; column is stable!

Page 73: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Space Found!

Page 74: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Tile Found! Shift Down!

Page 75: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Restart loop from tile!

Page 76: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Space Found!

Page 77: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 78: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Page 79: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

No more spaces found; column stable!

Page 80: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Space Found!

Page 81: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Tile Found! Shift Down!

Page 82: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Restart loop from tile!

Page 83: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Space Found!

Page 84: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Tile Found! Shift Down!

Page 85: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Restart loop from tile!

Page 86: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Space Found!

Page 87: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Tile Found! Shift Down!

Page 88: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Restart loop from tile!

Page 89: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

Space Found!

Page 90: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

No more spaces found; column stable!

Page 91: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

And so on...

Page 92: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Removing Matches

And so forth...

Page 93: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 94: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 95: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 96: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 97: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 98: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 99: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 100: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 101: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 102: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 103: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 104: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 105: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 106: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Replacing Tiles

Page 107: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Palette

http://pixeljoint.com/forum/forum_posts.asp?TID=16247

Page 108: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural
Page 109: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

http://pixeljoint.com/forum/forum_posts.asp?TID=12795

Page 110: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

https://commons.wikimedia.org/wiki/File:Cat03.jpg

Page 111: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

https://commons.wikimedia.org/wiki/File:Cat03.jpg

Page 112: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural
Page 113: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural
Page 114: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

Palette Swap

Page 115: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

● Implement time addition on matches, such that scoring a match extends the timer by 1 second per tile in a match.

● Make it so that Level 1 starts with just simple flat blocks, with later levels generating the ones with patterns on them. These should be worth more points.

● Create random shiny variants of blocks that will destroy an entire row when matched.

● Only allow swapping when it results in a match. If there are no matches, reset the board.

● Optional: implementing matching with the mouse. (Hint: You’ll need `push:toGame(x,y)`!

Assignment 3

Page 116: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

● Tile Maps● 2D Animation● Platformer Level Generation● Platformer Physics● Hurtboxes● Powerups

Next Time...

https://opengameart.org/content/platformer-art-pixel-edition

Page 117: GD50 Lecture 3: Match-3 · Lecture 3: Match-3 Colton Ogden cogden@cs50.harvard.edu David J. Malan malan@harvard.edu Anonymous Functions Tweening Timers Solving Matches Procedural

See you next time!