MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / __init__

Method __init__

src/gamesbyexample/ducklings.py:73–86  ·  view source on GitHub ↗

Create a new duckling with random body features.

(self)

Source from the content-addressed store, hash-verified

71
72class Duckling:
73 def __init__(self):
74 """Create a new duckling with random body features."""
75 self.direction = random.choice([LEFT, RIGHT])
76 self.body = random.choice([CHUBBY, VERY_CHUBBY])
77 self.mouth = random.choice([OPEN, CLOSED])
78 self.wing = random.choice([OUT, UP, DOWN])
79
80 if self.body == CHUBBY:
81 # Chubby ducklings can only have beady eyes.
82 self.eyes = BEADY
83 else:
84 self.eyes = random.choice([BEADY, WIDE, HAPPY, ALOOF])
85
86 self.partToDisplayNext = HEAD
87
88 def getHeadStr(self):
89 """Returns the string of the duckling's head."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected