go to starting place
) to hide just one block (go to x y
) a little non-intuitive. If we are going to use that block again somewhere else in the script, we should say that, and if we aren't (and I think we aren't), I don't think it makes sense to create it.go to starting place
to my draw square board
block definition might not be the right thing; I have the pen down
block outside of draw square board
, so it's going to make drag marks. If it needs to be inside, we should specify that.point in direction
block, which is needed as much as go to x y
. Perhaps it should also be in the go to starting place
block, and maybe we could even call it initialize
(or just set up sprite to draw grid
).clear
inside their draw square board
block, which they will likely be inclined to do since we asked them to put go to starting place
inside it; if the sprite isn't already at the starting place, they'll get drag marks if they don't either have the pen up or clear after moving to the starting place. It would be better to suggest using draw tile
(and why draw a 1-1 array with a more complicated block when you can use a much simpler block?).
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 that accepts any number of tiles as input until the end of the next page. 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.)