-
Notifications
You must be signed in to change notification settings - Fork 0
/
frog_oop.py
39 lines (29 loc) · 911 Bytes
/
frog_oop.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import turtle
from random import randint, choice
class Frog(turtle.RawTurtle):
def __init__(self, screen, x, y):
super().__init__(screen)
self.up()
self.goto(x, y)
self.down()
self.color('green')
def jump(self, dist):
self.up()
self.fd(dist)
self.down()
class MagicFrog(Frog):
def change_color(self):
self.color(choice(['black','blue','red','yellow','cyan','magenta','darkgreen']))
def jump(self,dist):
self.up()
self.fd(dist)
self.down()
self.change_color()
if __name__ == "__main__":
s = turtle.Screen()
konnad = [Frog(s, 10, 30), MagicFrog(s, 40, 80), MagicFrog(s, 70, 130)]
for konn in konnad:
for i in range(9):
konn.fd(10)
konn.jump(10)
turtle.done()