def __init__(self,
shape,
color,
x = 0,
y = 0,
width = 20,
height = 20):
turtle.Turtle.__init__(self)
self.speed(0) # Animation Speed
# Register shape if it is a .gif file
if shape.endswith(".gif"):
try:
turtle.register_shape(shape)
except:
Game.logs.append("Warning: {} file missing from disk.".format(shape))
# Set placeholder shape
shape = "square"
width = 20 # This is the default for turtle module primitives
height = 20 # This is the default for turtle module primitives
self.shape(shape)
self.color(color)
self.penup()
self.goto(x, y)
# Attributes
self.width = width
self.height = width
self.speed = 0.0 # Speed of motion
self.dx = 0.0
self.dy = 0.0
self.acceleration = 0.0
self.friction = 0.0
self.state = "active"
self.solid = True
#Set click binding
self.onclick(self.click)
# Append to master sprite list
Game.sprites.append(self)
评论列表
文章目录