Pexeso Documentation

Pexeso game

About: before game starts, game pieces are picked and shuffled. Game pieces are pairs of same pieces (every piece has its completely identical twin). Game starts with all pieces turned off, so players do not know which pieces are identical. Game goal is to find these identical pairs. Player on turn can turn on two pieces, if these pieces are the identical twins, he gets one point and continue (this can be set), these twin pieces get out of the game. If the selected two pieces are not the twins, they are turned off again and next player gets on turn. Game finishes when all the pairs were found, player with most of the points wins. When piece is turned off/on it stays on its position, no one moves it. When piece it turned on all players can see what piece was turned.

Requirements:

Stylesheets:

Settings

pieces

players

Number of players

options: integer
default: 1

startPlayer

Number of starting player - first player has number 1 (not 0)!

options: integer
default: 1

pictures

Array of picture sources
For this you can use function from file get_images.php - like this: "pictures = <?php echo get_images_for_pexeso('images/pexeso/browsers'); ?>;" - creates array from all files (make sure you have there only images) in selected folder.

options: array of strings
default: []

switchOnPoint

True for switching player always after 1 step, false for switching player only if his step was wrong (if his step was correct he will continue).

options: boolean (true/false)
default: false

waitForLoad

True - game will start after all pictures are loaded (I recommend to add some loader, that will cover the game area and check onGameLoaded callback).
False - game starts immediately - you risk problems when player turns empty (not loaded) picture.

options: boolean (true/false)
default: true

waitTime

Time to wait before the quares are turned off. In milliseconds. This is important when css transitions are not used, because there will be no delay and the square will be turned off immediately, so the player will not notice what picture was there.

options: integer
default: 1500

squareDone

When standard game is played the pictures that are solved stay in the game area, they are just covered so the players know they are solved (this is when the default 'cover' option is used). But when we want to play game where we reveal big background-picture in the back, then the pictures cannot be just covered, they have to disappear, that means different animation than 'cover' must be used, I call it 'square' animation. So 'cover' option for animating cover over the square, 'square' option for animating directly the square.

In case no animations used (turned off or not supported) this setting has no effect.

options: string ("cover" | "square")
default: "cover"

useCss

If used web browser do not support 3D transforms, no transforms or animations will be used. If 3D transforms are supported they are used, but they can be turned off by setting this option to false.

options: boolean (true/false)
default: true

Callbacks

onPlayerChange

Fired when player on turn changes.

default: function(){}
options: function(playerOnTurn, playerPoints) { /*your code*/ }
arguments:
playerOnTurn: number of player that gets on turn
playerPoints: number of points of that player

onGameInit

Fired when game is created.

default: function(){}
options: function(startPlayer) { /*your code*/ }
arguments:
startPlayer: number of player that starts the game

onGameLoaded

Fired when game (all the images) is loaded - invoked only when setting waitForLoad is true.

default: function(){}
options: function() { /*your code*/ }

onStep

Fired when player turned two pieces.

default: function(){}
options: function(correctStep, totalSteps, playerPoints) { /*your code*/ }
arguments:
correctStep: boolean value that indicates if the step was correct
totalSteps: number of steps in the game
playerPoints: number of points of active player

onSolved

Fired when game is finished.

default: function(){}
options: function(points) { /*your code*/ }
arguments:
points: array of points of all players, note that the first player is on index 1 (not 0)

onTimerChange

Fired when timer value changes - every second, smaller value is not considered.

Methods

destroy

Removes game timer and all game structure.

example:
pexeso = $('#pexeso-game').pexeso();
pexeso.destroy();

pause

Pauses the game - timer stopped, player interface inactive. Game can be paused only when game status is "running", in other cases game cannot be paused (testing return value of this function will determine if game was/wasn't paused). It was made this way because pausing followed by resuming the game while it's still processing player action made game unstable.
Viz "resume" to reactivate the game.

resume

Resumes the game - timer and player interface reactivated. Game can be resumed only when game status is "paused", in other cases game cannot be resumed (testing return value of this function will determine if game was/wasn't resumed).
Viz "pause" to pause the game.

example:
pexeso = $('#pexeso-game').pexeso();
pexeso.resume();

getPoints

Returns points of all players as an array, note that the first player is on index 1 (not 0).