Module import: from gamegrid import *
Class GameGrid (global functions when makeGameGrid() is called)GameGrid(nbHorzCells, nbVertCells, cellSize, color) | creates a game window with given number of horizontal and vertical cells, given cell size and visible grid lines with given color and a navigation bar |
GameGrid(nbHorzCells, nbVertCells, cellSize, color, bgImagePath) | creates a game window with given number of horizontal and vertical cells, given cell size and visible grid lines with given color, and a navigation bar and a background image |
GameGrid(nbHorzCells, nbVertCells, cellSize, None, bgImagePath, False) | creates a game window with given number of horizontal and vertical cells, given cell size and visible grid lines with given color, and a background image, but no navigation bar |
act() | invoked in every simulation cycle after all Actor.act() |
addActor(actor, location) | adds an actor to the game grid and shows it in the game window at given location |
addKeyListener(listener) | registers a KeyListener |
addMouseTouchListener (onMouseEvent, mask) | registers function onMouseEvent(actor, mouse, spot) for mouse events (OR mask): GGMouse.lClick, GGMouse.lDClick, GGMouse.lDrag, GGMouse.lPress, GGMouse.lRelease, (also with r), GGMouse.enter, GGMouse.move, GGMouse.leave. onMouseEvent(actor, mouse, spot) |
addStatusBar(height) | includes a status bar at the bottom of the game window |
delay(time) | stops execution for the given time (in millisecs) |
doPause() | stops the simulation cycling |
doStep() | executes one single simulation cycle |
doReset() | stops the simulation cycling and sets all actors to start position/direction |
doRun() | starts the simulation cycling |
getActors(Actor class) | returns all actors of given class (Python list) |
getBg() | returns the background reference |
getBgColor() | returns the background color |
getKeyCode() | returns the code of the most recent key press |
getOneActorAt(location) | returns the first actor at given location (Null, if no actor present) |
getOneActor(Actor class) | returns the first actor of given class (Null, if no actor) |
getRandomEmptyLocation() | returns a random empty location |
getRandomLocation() | returns a random location |
hide() | hides the game window, but does not close it |
isAtBorder(location) | returns True, if the cell ist at the border of the game window |
isEmpty(location) | returns True, if the cell is empty |
isInGrid(location) | returns True, if the cell is inside the game window |
kbhit() | returns True, if a key was pressed |
toLocation(x, y) | returns the cell that contains the pixel coordinates (x, y) |
openSoundPlayer("wav/ping.wav") | opens a WAV formatted sound file for playing. Some sound files are distributed with TigerJython: bird.wav, boing.wav, cat.wav, click.wav, explore.wav, frog.wav, notify.wav |
play() | plays the opened sound file |
refresh() | renders the image double buffer on the screen (automatically for most operations) |
registerAct(onAct) | registers the callback onAct that is called in every simulation cycle |
registerNavigation(started = onStart, stepped = onStep, paused = onPause, resetted = onReset, periodChanged = onPeriodChange) |
registers the callbacks onStart, onStep, onPause, onReset, onPeriodChange that are called when the navigation bar is visible (not all necessary) |
removeActor (actor) | removes an actor from the game grid |
removeActorsAt(location) | removes all actors from the game grid at given location |
removeAllActors() | removes all actors from the game grid |
reset() | moves all actors to the starting position/direction |
show() | makes a hidden game window visible |
setBgColor(color) | sets the background color |
setSimulationPeriod (milisec) | sets the simulation period |
setStatusText(text) | displays the given text in the status bar (old text is erased) |
setTitle(text) | sets the game window title |
Actor(spritepath) | creates an actor with given sprite image |
Actor(True, spritepath) | creates a rotatable actor with given sprite image |
Actor(spritepath, nbSprites) | creates an actor with several sprite images (index _0, _1,... e.g..fish_0.gif , fish_1.gif,... ) |
Actor(True, spritepath, nbSprites) | creates an rotatable actor with several sprite images |
act() | invoked periodically in every simulation cycle |
addActorCollisionListener(listener) | registers a collision listener |
addCollisionActor(actor) | resgisters a collision partner |
addMouseTouchListener (listener) | registers mouse touch listener |
collide(actor1, actor2) | callback when a collision happens, returns the number of cycles in which the events are inhibited |
getCollisionActors() |
returns the list of collision actors |
getDirection() | returns the actor's direction |
getIdVisible() | returns the id of the currently visible sprite image |
getNeighbours(distance) | returns a list of all actors in given distance. The distance defines a circle around the current cell center (unit: cell width). All actors in cells that intersects with this circle are returned |
getNextMoveLocation (location) | returns the location of the next move() operation |
getX() | returns the x cell coordinate of the current location |
getY() | returns the y cell coordinate of the current location |
hide() | hides the actor, but does not remove it from the game grid |
isInGrid() | returns True, if the actor's location is inside the game grid |
isHorzMirror() | returns True, if the sprite image is mirror horizontally |
isVertMirror() | returns True, if the sprite image is mirror vertically |
isMoveValid() | returns True, if the actor remains inside the game grid by the next move() |
isNearBorder() | returns True, if the actor is in a cell near the border of the game grid |
isVisible() | returns True, if the actor is visible |
move() | moves the actor in the current direction to a neighbor location |
move(distance) | moves the actor in current direction for the given distance |
reset() |
invoked when the actor is added to the game grid or the Reset button is pressed |
setCollisionCircle (spriteId,center, radius) | defines the circle within the actor that is used for collisions |
setCollisionLine(spriteId, startPoint, endPoint) | defines the line within the actor that is used for collisions |
setCollisionRectangle(spriteId, center, width, height) | defines the rectangle within the actor that is used for collisions |
setCollisionSpot(spriteId, spot) | defines the point within the actor that is used for collisions |
setCollisionImage(spriteId) | defines collision with non-transparent pixels. Only avaible, if the partner defines spot, line or circle collision |
setHorzMirror(True) | mirrors the sprite image horizontally |
setVertMirror(True) | mirrors the sprite image vertically |
setSlowDown(factor) | slows down the call of act() by the the given factor |
setLocation(location) | sets actor in cell with given location |
setLocationOffset(point) | moves actor's center to the point relative to the current cell (location unchanged) |
setPixelLocation(location) | sets actor's image center to given point by setting it's cell location and location offset |
setX(x) | moves actor in cell with given x-coordinate (y-coordinate unchanged) |
setY(y) | moves actor in cell with given y-coordinate (x-coordinate unchanged) |
show() | shows sprite image with id 0 |
show(spriteId) | shows sprite with given id |
showNextSprite () | shows sprite with id increased by 1 (modulo number of sprites) |
showPreviousSprite() | shows sprites with id decreased by 1 (-1 set to nbSprites -1) |
removeSelf() | removes actor from game grid (the actor reference is still valid) |
reset() | invoked with GameGrid.addActor() and when the Reset button is clicked |
turn(angle) | modifies the actor's direction (in degrees clockwise) |
Location(x, y) | creates location with given coordinates |
Location(location) | creates location from given location (clone) |
clone() | returns a clone of the current location |
equals(location) | returns True if the current location is the same as the given location |
get4CompassDirectionTo(location) | returns a list of the four neighbor locations (WEST, EAST, NORTH, SOUTH) |
getCompassDirectionTo(location) | returns a list with eight neighbor locations (also in diagonal directions) |
getDirectionTo(location) | returns direction to the given location (in degrees, clockwise, zero to NORTH) |
getNeighbourLocation(direction) | returns the neighbor location that fits best the given direction |
getNeighbourLocations(distance) | returns all locations of cells with center within given distance |
getX() | returns the current horizontal coordinate |
getY() | returns the current vertical coordinate |
clear() | clears the background by painting it with the current background color |
clear(color) | clears the background by painting it with the given color |
drawCircle(center, radius) | draws a cirlce with given center and radius (pixel coordinates) |
drawLine(x1,y1, x2, y2) | draws a line from (x1, y1) to (x2, y2) (pixel coordinates) |
drawLine(pt1, pt2) | draws a line from point pt1 to point pt2 (pixel coordinates) |
drawPoint(pt) | draws a single point (pixel coordinates) |
drawRectangle(pt1, pt2) | draws a rectangle with given diagonal vertexes (pixel coordinates) |
drawText(text, pt) | displays a text starting at given point (pixel coordinates) |
fillCell(location, color) | fills the given cell with given color |
fillCircle(center,radius) | draws a filled circle with given center and radius |
getBgColor() | returns the current background color |
getColor(location) | returns the background color at center of the cell with given location (actors discounted) |
save() | saves the current background (actors are not part of it). Restore with restore() |
setBgColor(color) | sets the background color |
setFont(font) | sets the color for writing text |
setLineWidth(width) | sets the line width for all drawing operations |
setPaintColor(color) | sets the color for all drawing operations |
setPaintMode() | sets the drawing mode to overwrite |
setXORMode(color) | sets the drawing mode to XOR (drawing with same color restores old background) |
restore() | restores the previously saved background |
Documentation Java Class Library JGameGrid : JGameGridDoc