Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions examples/tic-tac-toe/tic-tac-toe.tile
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ native func DrawText(text: cptr, posX: ci32, posY: ci32, fontSize: ci32, color:
func drawGrid(grid: char[], square_colors: int[], selected: int, current_player: char): void {
cellSize: int = 80;
gap: int = 10;
offsetX: int = 30;
offsetY: int = 30;
screenWidth: int = 400;
screenHeight: int = 400;
gridWidth: int = 3 * cellSize + 2 * gap;
gridHeight: int = 3 * cellSize + 2 * gap;
offsetX: int = (screenWidth - gridWidth) / 2;
offsetY: int = (screenHeight - gridHeight) / 2 - 20;

for (i: int = 0; i < 9; i++) {
x: int = offsetX + (i % 3) * (cellSize + gap);
y: int = offsetY + (i / 3) * (cellSize + gap);

DrawRectangle(x, y, cellSize, cellSize, square_colors[i]);

// Draw selection border
if (i == selected) {
DrawRectangle(x, y, cellSize, cellSize, 0xCCCC00FF);
}
Expand Down Expand Up @@ -157,15 +160,15 @@ func main(argc: int): void {
drawGrid(grid, square_colors, selected, current_player);

if (winner == 'X') {
DrawText("Winner: ", 100, 370, 20, 0x00FF00FF);
DrawText("Green", 220, 370, 20, 0x00FF00FF);
DrawText("Winner: ", 120, 370, 20, 0x00FF00FF);
DrawText("Green", 230, 370, 20, 0x00FF00FF);
}
else if (winner == 'O') {
DrawText("Winner: ", 100, 370, 20, 0xFF0000FF);
DrawText("Red", 220, 370, 20, 0xFF0000FF);
DrawText("Winner: ", 120, 370, 20, 0xFF0000FF);
DrawText("Red", 240, 370, 20, 0xFF0000FF);
}
else if (winner == 'D') {
DrawText("Draw!", 100, 370, 20, 0x00FF00FF);
DrawText("Draw!", 170, 370, 20, 0x00FF00FF);
}
EndDrawing();
}
Expand Down