So it will come back again in this lesson and I'm going to show you how to begin writing the Tiley great.
So let me go to school and explain that once in Interface Builder once our game runs we should be able
to see toilets in here that they each represent some number.
So essentially I'm going to have a label and this is not something you have to do this is just for the
sake of demonstration but they even have a label for instance like this and that one will be showing
us a number maybe one and it can have a not an hour for a different background color and then I even
have another one next to it and another one next to it and then either one.
And if you're playing a four by four you have to have four of them into it and the four of them on the
right.
And then we have to find the size of each of them so that the properly fit inside the game you're obviously
the one I just did a try to eyeball it and I missed some of it but that's why we are doing things programmatically
to make sure that things happen properly.
So few things we learn from this experiment is one of them is we need to know what is our current game
mode.
And Cygan thing we need to know what is the size of each title which is very important.
And then of course we need to know where to place each child tile number one is placed in this particular
Rock Center tile.
I'm going to call this one for instance who is placed in this particular location.
So on and so forth.
So let's go ahead and do all of these things programmatically delete all of these.
I'm going to go to my view controller and I want to mention this early on because it will happen more
and more as we go through this development a lot of the code that you're right now.
I will end up changing them later on simply because I don't want to tell you what is coming up.
I have obviously done this code before and I know why am I doing something but that is not how a programmer
thinks is not that you know you will know exactly what is coming up in let's say after two hours of
development.
So it stands to reason that I develop it for you as if I was doing it for the first time.
I would put the code in here and then as I go along I realized I have to change things.
We come back and we change it whenever a channel or whenever I remember.
I will tell you in advance that this is something that might have to change down the.
But you won't always be the case.
So with that in mind and based on what we just learned and then go ahead and get it a little bit better
you know formatting in here and I'm going to say I have a valuable Let's call this one game maudit which
is an integer and it has a default value of 4 because by default our game is being played in a four
by four situation then and then go ahead and say have another variable that is a high level size.
And that's going to be a float value and this float value.
I don't know what is its size simply because its size depends on the vet of the game view divided by
the game.
So let's go ahead and put that into an actual practice.
And when we hear an I'm way to add a new function and we call this function let's say M.H. tiles function
which is going to build us all of our tiles.
Now in the make tiles the first thing I need to know is the size of a tile.
And we just say tile size becomes game view dart frame size that it's divided by game mode.
And because the player is facing now and we get an error and this is actually a bit of a confusing error
it says cjra is ambiguous even though that is not the error or the areas that you are trying to divide.
C.G. floored by an integer.
So to remedy that I'm going to say seach fruit values e.g. float value of game mode and that's going
to fix the error.
So the tile size is now being the calculation of the size of the width of the game.
You divide that by the size of the game more.
Which at the moment is for now that they have now they can go ahead and the tiles.
So to do that I'm going to go ahead and say we need two times both horizontally and vertically essentially
both under and under height.
For now I'm going to add only one tile to my game to you.
I'm going to say let's say let Tyler is going to be a U I'll label and this UI labored.
I'm going to make it five frame.
So they have to decide where you want to place this one.
So the frame of it I'm actually going to make it based on a CGA record of the different formats.
Obviously I'm going to use a an origin and a size simply because the origin doesn't matter.
We're going to move the trial to somewhere else.
What does matter is the size of it.
So I'm going to say let's try.
I'm going to call this one a C G size simply because I don't want to confuse it.
The other size and that's going to be a C.G. size of it and the values of it are going to be twice the
size and type size because the width and height of it are exactly identical.
So every new tile that I'm going to make I'm going to place it at CGU point zero with the size.
Tyler C.G. size and that's going to be a tile that is going to have the same size as a quarter of the
of the game view because the game for this country for now.
Once I have the time I'm going to actually add some stuff to it so we can basically see it.
So I'm going to say tiles are background color make with maybe your eye color that dark gray color so
I can actually see this one.
And I'm going to see a game view that I had this.
Time now I'm going to have to call this matter inside my view that lot so it does happen at some point
eventually so many times it happens there.
And if I run the application we should be able to see one label with no text with like a background
on the top left corner of C.G. point to zero which is exactly what's happening.
And then I'm going to have to repeat this process in this case 16 times.
But for now I'm only going to do it for four times.
I want to have one in here one next to it one next to it.
Essentially going on the vet and add them are the columns of of different times.
So just go ahead and say How are you going to do that.
The first thing I want to say is I want to set the tile in your center.
So go ahead and say let's just call this one.
Maybe a new center or tieless center.
I want to say C-g point and I want to put us a center for it that is going to be the location here the
location for the next one.
The next one and the last one so I want to calculate all the centers.
So to do that I'm going to break it down into the X envoy of the center.
So we go up here and say maybe after the tiles size I'm going to say very let's call it X Center and
the X Center at the very beginning is half the vote.
So essentially it becomes tile size divided by two and that's as simple as that simply because at the
very beginning the vet here is whatever it is.
Half of it will make the accent.
I'm going to copy this.
Going to call this one.
Why.
And that's going to be half the time as well.
And these two values essentially make a new center for us.
So now they have that and I have the x and y of the tile center I'm going up right center to my tyed
went to say the tile dot center becomes tile center and that's going to not change anything right now
because you still only have one tile but soon enough and we'll have more tiles is going to change things.
So in order to have more times I'm going to go ahead and say four.
Let's call it h.
For now in 0 0 until we reach game mode.
And that's important because we need four of them 0 1 2 3.
Let's repeat this process.
Now let me quickly explain something that might not be very clear at the beginning why do I call it
h.
It's simply because these are the horizontal ones.
Why yet another one in here.
Another one here another one at the end.
So that's why we call it h.
You could obviously call it or I could call it horizontal whatever that makes sense to you but for me
this makes a lot more sense to call it h because I know down the track I'm going to quote another one
every four for Varitek.
Now what is happening is this foretop is happening four rounds and every time he's making a tile is
placing the exact same place and is doing it the same by Goncalo so on and so forth.
But that's not what I want.
What they want to happen is this every time that we run the for loop I want to push the accent a little
bit further to the right.
So if the first sign is here the next one should be there.
The next one should be there.
The last one should be somewhere about here.
So what is the difference between each of these two.
What's the difference between center of the first one and the next one and that is going to be the vet
of one of the titles.
So every time I make a I'll and I apply it to my center I'm going to say Exxon plus equine tieless size.
So push yourself as much as one tile to the right.
And let's run app now and in here once it knows we should be able to see four of these are two or three
times sitting next to each other and I know there are four of them but we can see the gaps between them.
That's why they show up like this.
It feels like your whole essentially like a band up there.
And to fix that I'm going to try to see CGI size and subtract a little bit from it maybe five points
just a number just a static number that's going to help us see a little bit of a little bit of a gap
between them which is going to make things a little clearer for me.
So now we see that little gap between them and they're all perfectly placed one two three four essentially
zero of one to three.
And every time the accent is helping us pushing it to the next location.
So let's keep it up to here and in the next lesson I will help you.
We show you essentially how to duplicate this process across the vertical side of the game view as.