Tk::Taxis::Critter - Perl extension for simulating critters
use Tk::Taxis::Critter; my $critter = Tk::Taxis::Critter->new( -taxis => $taxis ); $critter->randomise(); $critter->move();
Simulates critters in a taxis object
This module is used by the Tk:::Taxis class to implement the critter objects in the taxis simulation. Classes using it require the same interface as Tk::Taxis to work, namely one supporting width, height, image_width, image_height, tumble, preference, calculation and speed methods.
Tk:::Taxis
Tk::Taxis
width
height
image_width
image_height
tumble
preference
calculation
speed
new( -taxis => $taxis )
Generates a new Tk::Taxis::Critter object. Must be passed the -taxis option and object. This object should be a Tk::Taxis object or one implementing the methods width, height, image_width, image_height, tumble, preference, speed and calculation. The module will croak unless it receives this object in its constructor's arguments.
Tk::Taxis::Critter
-taxis
croak
randomise
Randomises the positions of the critters.
move
Moves each critter through one cycle of run-and-tumble.
get_pos and set_pos
get_pos
set_pos
Gets the position of the critter. Returns a two item list of x, y coordinates. set_pos sets the critters x, y coordinates, and expects a two item list.
get_orient and set_orient
get_orient
set_orient
Gets the orientation of the critter: returns a string: either 'n', 'ne', 'e', 'se', 's', 'sw', 'w', or 'nw'. The set_orient method is called with no argument: the orientation will be set automatically from internal data.
get_id and set_id
get_id
set_id
Gets or sets the canvas ID of the critter. Returns this integer.
get_boundries
Gets a hash of numbers describing the area in which the critters may move. The keys are min_x, max_x, min_y, max_y, width and height. The width and height are the physical dimensions of the taxis canvas (as specified by the object passed to the constructor), the min and max values take into account the size of the critters' images: min_x will be 5px if the critter images are 10px wide, since objects cannot be squashed any closer to the edges of the canvas than this.
min_x
max_x
min_y
max_y
Steve Cook, <steve@steve.gb.com>
Copyright 2005 by Steve Cook
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Tk::Taxis, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::Taxis
CPAN shell
perl -MCPAN -e shell install Tk::Taxis
For more information on module installation, please visit the detailed CPAN module installation guide.