This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
GGS/games/tic-tac-toe/board.py

18 lines
689 B
Python

from rectangle import Rectangle
from gamerectangle import GameRectangle
from math import sqrt
#param: nr_of_squares, dimensions(could be a Rectangle)
#creates an array of gamerectangles within itself with correct
#positions from each other
class Board(object):
def __init__(self, nr_of_rectangles, dimensions):
self.game_rectangles = []
axis = sqrt(nr_of_rectangles)
width = dimensions.width
height = dimensions.height
for index in range(nr_of_rectangles):
x = width * (index % axis)
y = height * int(index / axis)
gr = GameRectangle(index, x, y, width, height)
self.game_rectangles.append(gr)