NAME
Game::Object::Worm - Worm
SYNOPSIS
Nah...
STUFF
- ExceptionCouldNotMoveForward
-
Thrown when the Worm could not moveForward().
oObject - $self
PROPERTIES
isRealPlayer
Whether this is a real life player or not.
Default: 1
oDirection($direction)
Game::Direction object.
$self->oEventMove
Timed event for movement.
Default: interval 0.2
$self->score( ... args ... );
The accumulated score, accumulated by e.g. getting Prizes.
Default: 0
lengthIdeal
The ideal length for the Worm. It will prolong itself to this size when moving. It will not shrink.
lengthActual
The actual length of the Worm.
Readonly.
METHODS
new([$left = 11], [$top = 12], [$direction = "left"], [$length = 3)
Create new Worm, facing in $direction ("left", "right", "up", "down" (only left supported right now)), with a body a total size of $length.
moveForward()
Move forward one step in the oDirection.
Return 1 on success, else 0.
oValidLocationAfterMove()
Check that a movement in the $oDirection from $oLocation is a valid one.
Return new Game::Location (with the new location) object on success, else undef if the move wasn't valid.
OTHER METHODS
- turn($direction)
-
Turn in $direction. left right
Return new direction on success, else undef.
- grow([$sizeIncrease = 1])
-
Grow with $sizeIncrease body parts over time, i.e. increase the lengthIdeal.
Return the new lengthIdeal() on success, or undef on errors.
Other other methods
- crash()
-
Crash the Worm. This doesn't mean anything in particular.
Notify the Lawn.
Return 1 on success, else 0.
- checkTick($timeWorld)
-
Check if a tick is due. If it is, move forward.
Return 1 if a tick was due, else 0. Die if the worm can't move.
- awardScorePoints($points)
-
Add $points to the score().
Return 1 on success, else 0.