misha_turnbull
Feb 26, 2015 - 21:43
Hello - I am still working on a chess game. It's coming along nicely, with one exception: the GUI. I've had some trouble with loading the images from files but got that to work, but now run into this problem:
As you can see, the grid is not being drawn correctly. Here is the code from the draw() method of the scene:
def draw(self):
background(0, 0, 0)
fill(1, 1, 1)
# this loop displays the pieces (works fine)
for piece in self.game.board.pieces:
tint(1, 1, 1, 0.5)
pos = piece.coord.as_screen()
img = self.img_names[piece.pythonista_gui_imgname]
image(img, pos.x, pos.y, scale_factor, scale_factor)
tint(1, 1, 1, 1)
# this loop displays the grid (doesn't work)
for tile in self.game.board.tiles:
# this returns either (0.27462, 0.26326, 0.27367) if the piece is white
# or (0.86174, 0.85795, 0.85417) if the piece is black
color = tile.color.tilecolor
color += (0.3,) # alpha value
# get the position of the tile in screen coords
# this method DOES function correctly as shown by the above `for piece in pieces` loop
pos = tile.coord.as_screen()
# draw
fill(*color)
rect(scale_factor, scale_factor, pos.x, pos.y)
fill(1, 1, 1)
I think the problem is either in the fill() or rect() function, but I'm not sure which. Any ideas?