Skip to content

Instantly share code, notes, and snippets.

@Jan200101
Created February 23, 2017 11:11
Show Gist options
  • Save Jan200101/a93ed230730c40356f3db052acf29389 to your computer and use it in GitHub Desktop.
Save Jan200101/a93ed230730c40356f3db052acf29389 to your computer and use it in GitHub Desktop.
class Coords:
def __init__(self):
self.normalposition = {'x':5, 'y':5}
self.normalsize = {'h':10, 'w':10}
self.position = self.normalposition
self.size = self.normalsize
def reset(self):
self.position = self.normalposition
self.size = self.normalsize
self.pos()
def pos(self):
print(self.position)
def move(self, y:int=0, x:int=0):
err = 'error'
if x == 0 and y == 0:
print('Neither X or Y were given')
return
if 0 < self.position['x'] + x <= self.size['w']:
self.position = {'x':self.position['x'] + x, 'y':self.position['y']}
else:
print('You cannot go past X{} and Y{}'.format(self.position['x'], self.position['y']))
return
if 0 < self.position['y'] + x <= self.size['h']:
self.position = {'x':self.position['x'],'y':self.position['y'] + y}
else:
print('You cannot go past X{} and Y{}'.format(self.position['x'], self.position['y']))
return
self.pos()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment