Skip to content

Instantly share code, notes, and snippets.

@laserbat
Created July 2, 2011 18:22
Show Gist options
  • Save laserbat/1061497 to your computer and use it in GitHub Desktop.
Save laserbat/1061497 to your computer and use it in GitHub Desktop.
hasSpaceAround(x,y)
def hasSpaceAround(x,y):
"""Checks if there is free cells
around x,y"""
global gamemap
c = 0
for x2 in xrange(-2,2):
for y2 in xrange(-2,2):
if near(x, y,x + x2,y + y2):
if not gamemap[x + x2][y + y2].type[0]:
c += 1
if c >= 8:
return False
else:
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment