MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / getSpaceClicked

Function getSpaceClicked

src/gamesbyexample/pygame_games/flippy.py:291–301  ·  view source on GitHub ↗
(mousex, mousey)

Source from the content-addressed store, hash-verified

289
290
291def getSpaceClicked(mousex, mousey):
292 # Return a tuple of two integers of the board space coordinates where
293 # the mouse was clicked. (Or returns None not in any space.)
294 for x in range(BOARDWIDTH):
295 for y in range(BOARDHEIGHT):
296 if mousex > x * SPACESIZE + XMARGIN and \
297 mousex < (x + 1) * SPACESIZE + XMARGIN and \
298 mousey > y * SPACESIZE + YMARGIN and \
299 mousey < (y + 1) * SPACESIZE + YMARGIN:
300 return (x, y)
301 return None
302
303
304def drawInfo(board, playerTile, computerTile, turn):

Callers 1

runGameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected