Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from graphics import *
- import time
- class MC:
- def __init__(self, x, y, radius, window):
- self.window = window
- self.goingLeft = True
- self.goingRight = True
- self.goingUp = True
- self.goingDown = True
- self.circleColor = color_rgb(0, 255, 0)
- self.circle = Circle(Point(x, y), radius)
- self.circle.setFill(self.circleColor)
- self.circle.draw(window)
- def step(self):
- windowHeight = self.window.getHeight()
- windowWidth = self.window.getWidth()
- x = self.circle.getCenter().getX()
- y = self.circle.getCenter().getY()
- if self.goingLeft:
- dx = -10
- if self.goingRight:
- dx = 10
- if x + dx >= windowWidth - self.circle.getRadius():
- self.goingLeft = False
- elif x + dx <= self.circle.getRadius():
- self.goingLeft = True
- if self.goingUp:
- dy = -10
- if self.goingDown:
- dy = 10
- if y + dy >= windowHeight - self.circle.getRadius():
- self.goingUp = False
- elif y + dy <= self.circle.getRadius():
- self.goingUp = True
- # self.circle.setFill(color_rgb(int(255 * (windowWidth - x) / windowWidth),0,int(255 * (x / windowWidth))))
- #self.circle.setFill(self.downColor *((windowHeight - y) / windowHeight) + self.UpColor * (y / windowHeight))
- self.circle.move(dx, 0)
- def routeLR(self):
- direction = input('Where do you want to go? Your choices are left or right. ')
- if direction.rstrip() == "":
- print("Type something!")
- self.routeLR()
- elif direction.rstrip() == "^[[C":
- print("Type something!")
- self.routeLR()
- elif direction.rstrip() == "^[[D":
- print("Type something!")
- self.routeLR()
- elif direction.rstrip().lower().startswith("l"):
- self.goingLeft = True
- self.goingRight = False
- for i in range(7):
- self.step()
- elif direction.rstrip() == "right":
- self.goingLeft = False
- self.goingRight = True
- for i in range(7):
- self.step()
- else:
- print('Rude. Try again')
- self.routeLR()
- def routeUD(self):
- direction = input('Good! How about trying up or down? ')
- if direction == "up":
- self.goingUp = True
- self.goingDown = False
- for i in range(7):
- self.step()
- elif direction == "down":
- self.goingUp = False
- self.goingDown = True
- for i in range(7):
- self.step()
- else:
- print('Stop that! Try again')
- self.routeUD()
- def sayMaize(window, x, y):
- textColor = color_rgb(255, 255, 255)
- text = Text(Point(x, y), 'The Maize')
- text.setTextColor(textColor)
- text.setSize(24)
- text.draw(window)
- def main():
- windowHeight = 500
- windowWidth = 500
- windowTitle = 'worldworld'
- radius = 70
- center = Point(windowWidth / 2, windowHeight / 2)
- circle = Circle(center, radius)
- backgroundColor = color_rgb(40, 40, 40)
- window = GraphWin(windowTitle, windowWidth, windowHeight)
- window.setBackground(backgroundColor)
- ball = MC(windowWidth / 2, 250, 50, window)
- sayMaize(window, (windowWidth/2), (windowHeight/1.2))
- print('Welcome to the maize! Press enter if you want to talk.')
- input("")
- print("The rules are simple. You're trapped and I know the way out. ")
- input("")
- print("I'll help you if you want, but we'll have to be fast.")
- input("")
- print("Don't worry, they don't know you're here yet. They know I still have to teach you how the game works. ")
- input("")
- print("Let's start simple. Do you know how to move?")
- input("")
- ball.routeLR()
- ball.routeUD()
- time.sleep(1.00)
- #sayTextMaize(window, (windowWidth/2), (windowHeight/1.2))
- response = input('Hit Enter to quit')
- window.close()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement