push:toGame(x,y)
; see the push
library’s documentation here for details!Download the distro code for your first game from https://cdn.cs50.net/games/2019/x/assignments/3/assignment3.zip and unzip assignment3.zip
, which should yield a directory called assignment3
.
Then, in a terminal window (located in /Applications/Utilities
on Mac or by typing
cmd
in the Windows task bar), move to the directory where you extracted assignment3
(recall that the cd
command can change your current directory), and run
cd assignment3
Welcome to your fourth assignment! There was a lot to learn with timers, tweens, and more in this lecture, but unfortunately, our game is still lacking in a few areas. By extending its functionality, we’ll have something even closer to famous titles such as Bejeweled and Candy Crush Saga!
Your goals this assignment:
PlayState:calculateMatches
, so start there!Board:initializeTiles
, but perhaps we could pass in the level
variable from the PlayState
when a Board
is created (specifically in PlayState:enter
), and then let that influence what variety
is chosen?Tile
class most likely to hold some kind of flag to let us know whether it’s shiny and then test for its presence in Board:calculateMatches
!Board:calculateMatches
after a swap and just revert back if there is no match! The harder part is ensuring that potential matches exist; for this, the simplest way is most likely to pretend swap everything left, right, up, and down, using essentially the same reverting code as just above! However, be mindful that the current implementation uses all of the blocks in the sprite sheet, which mathematically makes it highly unlikely we’ll get a board with any viable matches in the first place; in order to fix this, be sure to instead only choose a subset of tile colors to spawn in the Board
(8 seems like a good number, though tweak to taste!) before implementing this algorithm!push:toGame(x,y)
; see the push
library’s documentation here for details! This one’s fairly self-explanatory; feel free to implement click-based, drag-based, or both for your application! This one’s only if you’re feeling up for a bonus challenge :) Have fun!submit50
.Using Git, push your work to https://github.com/me50/USERNAME.git
, where USERNAME
is your GitHub username, on a branch called games50/assignments/2019/x/3
or, if you’ve installed submit50
, execute
submit50 games50/assignments/2019/x/3
instead.