

The next task is to draw a symbol-nought or cross-in a given square. Since a PICO-8 screen is 128x128 pixels, each square can be 42 pixels, leaving 1 pixel for the grid lines: function draw_grid( ) You can recreate this using four lines: two horizontal and two vertical.

Tic-tac-toe takes place on a grid of nine squares. Try removing this line to see what happens when you don’t clear the screen. It takes four arguments to draw a line between two points: the x and y coordinates of point a, and the x and y coordinates of point b. The line() function is another that’s built into PICO-8. Line(mousex - 4, mousey, mousex + 4, mousey) Line(mousex, mousey - 4, mousex, mousey + 4) For a crosshair-style pointer, you can draw a vertical line and a horizontal line at the current mouse position: function _draw( ) It gives various details about the current environment, including the mouse, keyboard, and date/time.įinally, define a _draw function to display a pointer on-screen. PICO-8 includes stat as a built-in function. Note that variables in PICO-8 are global by default, so any function in your program will have access to mousex and mousey. To support mouse input, this is the place to keep track of the pointer’s position. The _update function handles user input and updates to your game’s state. For a game that requires mouse input, you’ll need to make a special call to enable it: function _init( ) This function isn’t strictly part of the game loop since it only runs once, on start. Start by setting up any required actions in _init().
