-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.py
25 lines (18 loc) · 977 Bytes
/
Player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from Item import *
'''This class defines how out player will behave. It "inherits" from its parent class Item so it can do
everything Item can do but we can also add more behavior without having to duplicate code. Pretty neat!'''
class Player(Item):
#Here we set up the player
def __init__(self, animage, xlocation, ylocation):
#We call on Player's parent constuctor to set up the basic image, location, and size information
Item.__init__(self, animage, xlocation, ylocation, animage.width, animage.height)
#This is where we tell the player how to move left using its location
def moveLeft(self):
#print("Move Left")
if(self.xlocation - 10 > 0):
self.xlocation -= 10
#This is where we tell the player how to move right using its location
def moveRight(self):
#print("Move Right")
if(self.xlocation + 10 < width):
self.xlocation += 10