1 00:00:00,920 --> 00:00:07,980 So come back again resetting the game means doing a lot of different things means resetting the randomization 2 00:00:07,980 --> 00:00:14,520 of the time it means resetting the time means making sure if game estate is in the vorn estate resetting 3 00:00:14,520 --> 00:00:16,500 that and so many other things. 4 00:00:16,500 --> 00:00:22,080 In fact this recent action is perhaps the only function that's going to stay with us until the end of 5 00:00:22,110 --> 00:00:26,490 his development and every step of the development as we add new features to the code. 6 00:00:26,490 --> 00:00:30,120 We end up adding some stuff for it in the Reset action as well. 7 00:00:30,300 --> 00:00:32,460 But for now let's go ahead to X school. 8 00:00:32,520 --> 00:00:37,370 And in the recent action I'm actually going to list the things we currently have to do. 9 00:00:37,380 --> 00:00:46,050 First of all we have to set the game time to zero and then we have to read randomize everyone randomize 10 00:00:46,140 --> 00:00:47,530 every time. 11 00:00:47,760 --> 00:00:50,400 So let's see how we're going to do all of these things. 12 00:00:50,400 --> 00:00:53,770 The first thing I'm going to do is I'm going to say game time. 13 00:00:54,190 --> 00:00:55,670 That has to be Cong's zero. 14 00:00:55,680 --> 00:00:58,410 That's something that we said right off the beginning. 15 00:00:58,410 --> 00:01:03,130 The next thing is randomizing the tiles means several different things. 16 00:01:03,150 --> 00:01:07,390 Above all means that we have to remake the tiles. 17 00:01:07,390 --> 00:01:13,140 Now here is the problem we'll be facing if we remake the tiles and we add them to our game view. 18 00:01:13,140 --> 00:01:17,000 It simply means that we have two sets of tires in there. 19 00:01:17,130 --> 00:01:22,450 So because of that I have to first remove every one that is currently there. 20 00:01:22,620 --> 00:01:24,830 So let me show you how I'm going to do that. 21 00:01:24,870 --> 00:01:30,730 I'm going to go ahead and save for any and I'm going to see any in the tiles array. 22 00:01:30,870 --> 00:01:34,560 Remember this is the array that holds on to all four tiles. 23 00:01:34,710 --> 00:01:42,120 I'm going to say in the Remove from superb view so I'm going to remove every one that is currently in 24 00:01:42,120 --> 00:01:46,310 the toilet from the view that is called The Game view. 25 00:01:46,450 --> 00:01:53,210 So the one sided that I'm going to go ahead and say well now make on the tiles once again. 26 00:01:53,210 --> 00:01:56,720 And if you made the tiles then randomize them. 27 00:01:56,760 --> 00:02:01,770 Now that's a part of what we have to do in the reset and something that is going to come to my mind 28 00:02:01,770 --> 00:02:08,100 right now is it seems like at the very beginning of the app when the app loads for the first time we 29 00:02:08,100 --> 00:02:10,340 are also resetting everything. 30 00:02:10,470 --> 00:02:13,160 And that's something that's happening in the view that lot. 31 00:02:13,200 --> 00:02:18,420 So a lot of this is actually repetitious code and I could actually get three of them so to do that I'm 32 00:02:18,420 --> 00:02:21,630 going to go ahead and say gets me all of these. 33 00:02:21,810 --> 00:02:27,050 I'm going to cut all of them out go to reset and place them all in here. 34 00:02:27,300 --> 00:02:34,010 So right now in my reset action gets rid of all of that so I can show you all the code in one go. 35 00:02:34,080 --> 00:02:38,890 So that is getting rid of everyone that is currently in the game view. 36 00:02:39,090 --> 00:02:40,630 Then I'm going to make the toys. 37 00:02:40,650 --> 00:02:46,490 Randomize them then if they use a game timer running on when it invalidate them. 38 00:02:46,490 --> 00:02:54,120 Sure the correct time which is 0 0 and rerun the game timer and that's all perfect except that right 39 00:02:54,180 --> 00:02:58,260 at the beginning of the app nobody is calling the reset action. 40 00:02:58,350 --> 00:03:03,900 So to fix that I'm going to go back to my view of that lot which crankily has nothing left in it. 41 00:03:04,080 --> 00:03:07,820 I'm going to say of the reset action. 42 00:03:07,830 --> 00:03:13,740 And he says you have to give me some bonus and I'm going to say self because it doesn't really matter 43 00:03:13,740 --> 00:03:16,160 what we give it's of any value. 44 00:03:16,200 --> 00:03:22,510 Essentially here in the reset it says it's any it is not an optional any. 45 00:03:22,530 --> 00:03:27,590 So I have to feed it something you can say nil but you can't give it anything. 46 00:03:27,630 --> 00:03:33,010 I'm going to say stuff because we are not doing anything with descender It's not like are checking for 47 00:03:33,010 --> 00:03:35,390 ascender value and do things with it. 48 00:03:35,400 --> 00:03:38,740 So with that just go ahead and see what we get in here. 49 00:03:38,880 --> 00:03:41,680 If it all works the way we are hoping it's going to work. 50 00:03:41,850 --> 00:03:47,810 We should see a reset game in a randomized game at the very beginning and a timer that is counting. 51 00:03:47,940 --> 00:03:52,690 And every time I hit the reset I should get a brand new set and a brand new timer. 52 00:03:53,260 --> 00:03:55,630 Again one two. 53 00:03:55,660 --> 00:04:01,500 The timer is working and we got a brand new group of tiles on our reset is now working the way we're 54 00:04:01,500 --> 00:04:02,650 hoping is going to do. 55 00:04:02,880 --> 00:04:06,180 So let's keep it up to here on this one to our next lesson.