day 23 - crossroads game
This commit is contained in:
27
023/player.py
Normal file
27
023/player.py
Normal file
@ -0,0 +1,27 @@
|
||||
from turtle import Turtle
|
||||
|
||||
class Player(Turtle):
|
||||
STARTING_POSITION = (0, -280)
|
||||
MOVE_DISTANCE = 10
|
||||
FINISH_LINE_Y = 280
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.shape("turtle")
|
||||
self.color("black")
|
||||
self.pu()
|
||||
self.setheading(90)
|
||||
self.goto(self.STARTING_POSITION)
|
||||
|
||||
def move_up(self):
|
||||
self.goto(x=self.xcor(), y=self.ycor() + self.MOVE_DISTANCE)
|
||||
print(self.ycor())
|
||||
|
||||
def has_won(self):
|
||||
if self.ycor() >= self.FINISH_LINE_Y:
|
||||
return True
|
||||
return False
|
||||
|
||||
def reset_position(self):
|
||||
self.clear()
|
||||
self.goto(self.STARTING_POSITION)
|
||||
Reference in New Issue
Block a user