1.1-Introductie-Programmeren

TicTacToe continued (2)

Difficulty: Filled Filled Filled

In the previous exercise you have made variables that can be filled with an X or an O. We will update the application in this exercise with a variable to be able to adjust the window size.

Let’s introduce a size variable which indicates the size of a single grid space. We can use this variable to calculate the new dimensions of our board. Initialize this variable with a size of 50 and draw the board similar to the previous exercise.

Steps:

  1. Determine the size of the window using the size variable so that the resulting window has the same size as it has now. Check if the program is still working correctly. You can use the resize(..) method for this.
  2. Now define the lines that where drawn using this same variable. And check the result.
  3. Check what happens when you change size into something rather big (e.g. 100-200). If the program works OK, the window and the board will be bigger, but the nought and crosses didn’t move with it. In the next exercise we will repair this.

Example

Example