In this lab, you'll code a general draw gameboard for Tic Tac Toe and other games, and build a simple Tic Tac Toe game.
The game rules vary, but the game boards are alike except for the number of tiles. So, it makes sense to write one program for all three boards. For example, it would be nice if and
would draw these boards, fitting neatly on the stage:
clear
the stage and create a new sprite that will draw the gameboard.draw gameboard
block yet. The task is complex, so start by building blocks that specialize in each part of the task. One approach is described below. Be sure to test each block by itself before building a block that uses it.
draw square
block.
draw tile
when you could use draw square
or just the script inside it? Making a specific block to hide the details does two useful things:
stamp
), it makes sense to edit draw tile
(changing draw square
would change all the squares).draw tile
block to draw one row of tiles, like this:draw row
to draw as many rows as needed, with the same number of tiles in each row.go to x y
) to make it easy to move the sprite to that starting place.go to starting place
to your draw square board
block definition.
You will improve this project on the next page. In Unit 3, you will teach the computer to check for wins and illegal moves; and, still later, you will teach the computer how to be an intelligent player!
draw square board
block to create a "1-by-1 array" (just one large square) of the right size to "erase" the outside border of the 3-by-3 board to make something that looks more like a Tic-Tac-Toe board. (To "erase," use a white pencolor and a thicker pensize.)