7.18: Deciding Where the Apple Appears
- Page ID
- 14570
def getRandomLocation(): return {'x': random.randint(0, CELLWIDTH - 1), 'y': random.randint(0, CELLHEIGHT - 1)}
The getRandomLocation()
function is called whenever new coordinates for the apple are needed. This function returns a dictionary with keys 'x'
and 'y'
, with the values set to random XY coordinates.