Most Common Penjee Methods Objects Cheat Sheet
Most Common Penjee Methods Objects Cheat Sheet
Most Common Penjee Methods Objects Cheat Sheet
not running into walls or other things that don't have a good effect on your penguin)
Contents
I)
II)
III)
IV)
V)
VI)
Penjee's World
Penguin Instantiation
Relative Directions
Compass Directions
Action Methods
Boolean Methods (with some gotchas, at least read this one over once)
I) Penjee's World
Penguins, fish, and other objects exist inside an ice world. The borders of this world are "walls"
of ice. If your Penguin tries to move outside the map, the penguin will hit the ice wall and become
disabled. So, be kind to your Penguin and don't hit the outer walls! (We'll show you all sorts of neat tricks
later on how to do this like a programmer.)
Map
B. Penguin(compass_direction)
Passing a single compass direction will instantiate a penguin at row 0, column 0, facing in
compass_direction, with 0 fish
Example Code
Map
C. Penguin(num_fish)
Passing a single integer will instantiate a penguin at row 0, column 0, facing East, with num_fish
fish
Example Code
Map
Map
Map
Map
V) Action Methods
a. waddle()
Penguin attempts to move the penguin forward one position.
b. grab()
Penguin picks up a fish-- if the penguin is on top of a fish. Note: Calling grab() on an
empty cell (ie one without a fish) has no effect.
c. drop()
Penguin drops a fish onto its current cell.
d. giveFish()
Penguin transfers a fish to a second penguin.
IV)Boolean Methods
A.
B.
C.
D.
E.
isWater(relative_direction)
isWall(relative_direction)
isRock(relative_direction)
isSafe(relative_direction)
hasFish() #coming soon..to Penjee 2.0 due out in late fall of 2016
Continued
Object
isSafe(ahead)
Reflecting Cube
True
Water
False
Penguin disabled
You may use isWater(ahead) or
isSafe(ahead) to detect water.
Fish
True
Nothing
You must use isFish(ahead) or
isFish(here) to detect a fish
NOTE: it's possible for multiple fish to be
in one cell
Penguin
True
Nothing
You must use isPenguin(ahead) to
detect a penguin
Wall
False
Penguin disabled