Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
scene.rect
-
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 thedraw()
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()
orrect()
function, but I'm not sure which. Any ideas? -
It looks like you're using
pos.x
andpos.y
as width and height of the rect. I think the order of parameters should be:rect(pos.x, pos.y, scale_factor, scale_factor)
-
That was indeed the issue. Thank you!