Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
Let's tackle the final stage of Four in a Row - adding in the Game logic.
-
0:00
[MUSIC]
-
0:04
Welcome to the final stage of this course.
-
0:06
At this point, we've built out most of our classes.
-
0:09
We've created several objects that are all working together and
-
0:12
interacting with each other.
-
0:14
We've rendered our visual components and added interactivity so
-
0:17
a player can move their tokens around the board and drop them into spaces.
-
0:21
But now what?
-
0:22
A turn isn't just dropping a token.
-
0:25
In a real life game,
-
0:26
a lot of the synthesis that happens after someone drops a token is automatic.
-
0:30
We can clearly see a space is filled with a token.
-
0:33
It's obvious whose turn it is, and
-
0:35
a winning move is visible right in front of us.
-
0:37
In our game, though, we have to write the logic for the series of calculations.
-
0:42
So throughout this stage,
-
0:43
you'll be creating new methods to handle these tasks.
-
0:46
At the conclusion of this course, you will write
-
0:48
a final method called update game state, that calls them all in a specific order.
-
0:54
This update game state method is the callback function that was
-
0:58
mentioned earlier in the course.
-
0:59
This function is passed as an argument to the drop animation, and
-
1:03
is called once the animation is complete.
-
1:05
Calling the update games state callback will trigger the following events.
-
1:09
Filling the target space with the active token, checking for a winning move, and
-
1:14
switching the active player.
-
1:16
You'll tackle each of these steps one by one and then together, we'll
-
1:20
come together for a solution video for the completed update game state method.
-
1:24
That will be followed by a final demo of the game.
-
1:27
Good luck, and see you soon.
You need to sign up for Treehouse in order to download course files.
Sign up