Closed GoogleCodeExporter closed 9 years ago
Not quite sure what to call it, or if it is useful enough
generally to add it directly to the Pynguin class, but it's
easy enough to do ...
from math import sin, cos
class PP(Pynguin):
def getforward(self, distance):
deg = self.heading
rad = deg * (PI / 180)
dx = distance * cos(rad)
dy = distance * sin(rad)
x0, y0 = self.xy()
x = x0 + dx
y = y0 + dy
return x, y
Do you have a better name, or an example that makes a great
case for adding the method to the base class?
Original comment by miss...@hotmail.com
on 25 Jul 2010 at 8:47
Mostly, it's come up for when people want to constantly check if they are
within some shape or region they've made--they go forward 1, check something,
if it's true, go back, and then actually go forward.
Maybe a name like "peekforward" or something?
I'm not sure it should be in the base class either--it's really a workaround a
speed issue for a common workflow, I suppose.
Original comment by aresnick...@gmail.com
on 25 Jul 2010 at 4:39
Ok. I've done something like that before and it was pretty useful.
I've added the method as:
xyforward(distance)
but I did not pull it in to builtins yet. Give it a try and let
me know how it works out.
Original comment by miss...@hotmail.com
on 28 Jul 2010 at 1:34
Thanks! I'll check it out.
Original comment by aresnick...@gmail.com
on 28 Jul 2010 at 1:51
Nope, I can't seem to reproduce it. I'll let you know if it comes up again.
Thanks!
Original comment by aresnick...@gmail.com
on 1 Aug 2010 at 3:37
I went ahead and added xyforward() to the built-in functions
Original comment by miss...@hotmail.com
on 12 Jun 2011 at 9:30
Original issue reported on code.google.com by
aresnick...@gmail.com
on 25 Jul 2010 at 2:07