I'm making a Connect 4 game for my Performance Task for AP CSP and I cannot get the grid to print in the right orientation. It seems like the board is being rotated right and then mirrored/flipped. Note: This is written in Brython on CodeHS.
def game():
matrix2 = [[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[1, 0, 2, 0, 0, 0, 0],
[0, 0, 0, 1, 2, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 1, 0, 0]]
#column 1 is (0,0)(1,0)(2,0)etc
print("(2,0) (row,column) : " + str(matrix2[2][0]))
#Outline of the board
#rectangle(get_width()-30, get_height()-30,(get_width()/2-rect.get_width()/2), (get_height()/2-rect.get_height()/2), '#274ecf' )
rect = Rectangle(get_width()-30, get_height()-30)
rect.set_position((get_width()/2-rect.get_width()/2), (get_height()/2-rect.get_height()/2))
rect.set_color('#274ecf')
add(rect)
#Board
rect = Rectangle(get_width()-50, get_height()-50)
rect.set_position((get_width()/2-rect.get_width()/2), (get_height()/2-rect.get_height()/2))
rect.set_color('#2b56e3')
add(rect)
#matrix x/90-70 y/90-70
#Slots
def slot(x,y):
circle = Circle(40)
circle.set_position(x,y)
if matrix2[x//90][y//90]==0:
print(matrix2[x//90][y//90])
circle.set_color(Color.white)
add(circle)
elif matrix2[x//90][y//90]%2==0:
circle.set_color(Color.yellow)
add(circle)
else:
circle.set_color(Color.red)
add(circle)
def row():
x=70
for i in range(6):
x+=90
a=70
for i in range(7):
slot(x,a)
a+=90
row()
This is what it looks like it looks like when ran:picture of console
I tried switching x and y and I also try rearanging the nested for loops under the function "row". Any advice helps! Thank you!