Now it is time to put together everything we have learned so far! Over the next 4 weeks, we will be making the Doctor Who Tardis. This week we will set up the variables. The second week will be the Tardis’ functions. Next week we will make the shapes and position everything. In the last section, we will add details and text.
So in case you don’t know what the Tardis looks like, here is what we will be making:
In order to easily modify anything and write the code quicker, I have made a boat load of variables and functions. This will not only give you great practice but a good stopping point at the end of this part.
Let’s start with the variables first.
Since the Tardis is a bunch of boxes stacked on each other, I have made variables for each set of boxes. Starting with the biggest box, I have the tardisW and tardisH variables for the width and the height. I set them at 200 and 300 respectively. Next, you have the door. This need to be proportional to the big box, so I made my variable value into a math problem. For the width, doorW, I set it to tardisW – 43. For the height, doorH, I set it to tardisW – 42. The door panels are next. I set the width and height to 45 but made them separate variables just in case I want to make them different. Next is the windows in the first row. The width and height are set to pannelW/3 and pannelH/2 in that order.
To get the spacing even in both directions, I made 2 variables for each row of panels. One for the x-direction and one for the y-direction. For the left side, I have a variable called lRowX and set it to 155. For the right side, I made the variable rRowX that is set at 239. These will make sure every panel is lined up in the x-direction or horizontally.
The spacing in the y-direction requires one variable per row. This set of variables follows a pattern since they all have the same spacing. The first row has been assigned the variable row1 and is set at 124. Since there are 4 rows you will have the variables named, row1, row2, row3, and row4. Each variable adds 62 to the last one. For example, row 2’s variable is set at row1 + 62. Row 3’s variable is set at row2 + 62, and so on.