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

Method getBodyStr

src/gamesbyexample/ducklings.py:140–180  ·  view source on GitHub ↗

Returns the string of the duckling's body.

(self)

Source from the content-addressed store, hash-verified

138 return headStr
139
140 def getBodyStr(self):
141 """Returns the string of the duckling's body."""
142 bodyStr = '(' # Get the left side of the body.
143 if self.direction == LEFT:
144 # Get the interior body space:
145 if self.body == CHUBBY:
146 bodyStr += ' '
147 elif self.body == VERY_CHUBBY:
148 bodyStr += ' '
149
150 # Get the wing:
151 if self.wing == OUT:
152 bodyStr += '>'
153 elif self.wing == UP:
154 bodyStr += '^'
155 elif self.wing == DOWN:
156 bodyStr += 'v'
157
158 if self.direction == RIGHT:
159 # Get the wing:
160 if self.wing == OUT:
161 bodyStr += '<'
162 elif self.wing == UP:
163 bodyStr += '^'
164 elif self.wing == DOWN:
165 bodyStr += 'v'
166
167 # Get the interior body space:
168 if self.body == CHUBBY:
169 bodyStr += ' '
170 elif self.body == VERY_CHUBBY:
171 bodyStr += ' '
172
173 bodyStr += ')' # Get the right side of the body.
174
175 if self.body == CHUBBY:
176 # Get an extra space so chubby ducklings are the same
177 # width as very chubby ducklings.
178 bodyStr += ' '
179
180 return bodyStr
181
182 def getFeetStr(self):
183 """Returns the string of the duckling's feet."""

Callers 1

getNextBodyPartMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected