Getting To An End
Our game is starting to shape up we are really only missing a few key elements to make our game complete. The first is a way for us to know when the game ends so we can show the user a score and enable the user to restart the game. To get there there are a few more steps we need to take. lets jump in and see what that means...
Video Transcript
00:00The really only last element that's missing here is to actually know when is the game over, right?
00:06Well we don't really have any clue when the game is over because we don't have any reference to
00:11how many elements are on the stage. So to have a reference to how many elements are on the stage
00:15we're going to create a new variable and we're going to call it count. And our new variable
00:20count we will just add into our loop. So first of all we're going to create a new variable.
00:26Let's go all the way to the top and just right after our dictionary we want to create our
00:31count. So let's do that. Private var count and that would be an integer and its initial value
00:40we could set it to zero. So let's see what we're doing here. So if we go into our RSS complete
00:46again we just want to add every time a loop goes through we want to upgrade our count to be one
00:52more. And that basically will give us the count of how many elements we have in our application.
00:58And then the next step that we want to do is start subtracting a value whenever we have a match.
01:03And when do we have a match is in our drop whenever we see that we have a match. So if
01:09we go into our drop on drop we could add so whenever we have a drop whenever we have
01:15a value we want to subtract. Now the last item that we want to see is we want to see
01:21if our element if our count has no value when would it have no value when the value would be
01:27zero. Thus when the value would be zero only then our if statement now would happen because it would
01:32be not zero which is true but not one is false because one is equals to true and boolean and
01:4010 is equal to true and boolean. So not true equals false but if the value was zero only then
01:46we would get a value of true which then only then this would be called. So we could call another
01:51function and let's call it end. And now that we have our end let's see what logic we would put
01:57into it. So let's take end all the way to the bottom of our method. Private function and
