
This folder illustrates advanced usage of the libraries *ptk* (alone) and *luciole* (via Lustre).


# Rotakin

In this game, an image is divided into 3x3 pieces,
each randomly rotated (by 0, 45, 90 or 135°). 

Clicking a sub-image makes it and all its neighbors rotate by 45°. 
The goal is to restore the whole image in the right orientation. 

# Lustre + Luciole

The idea is to separate, as far as possible:

- the logics and algorithms, written in Lustre
- the display/animation, developed in *luc(iole)*

## game.lus

It implements the games with abstract values:

- outputs are:
   - the state of the puzzle: a 3x3 matrix where each cell
     contains the current rotation of this part of the image
     (0, 1, 2 or 3 times 45°),
   - a Boolean *win* true if all cells contain 0.
- inputs are:
   - a 3x3 Boolean matrix, indicating if a cell is clicked
   - a Boolean *start*, that "shuffle" the puzzle

## game-basic.luc

The command `luciole game.lus game` starts a default simulation:

- default widgets for inputs and outputs
- basic layout: two columns side-by-side (inputs and outputs)

To start developing a more user-friendly GUI, save the default *.luc* file:

- within Luciole: *File / Save basic luc / select game-basic* → *game-basic.luc*
-  at command-line:
   - `lus2ec game.lus game` to generate the expanded-code format → *game.ec*
   - `rp2luc ecexe game.ec game-basic.luc` → *game-basic.luc*
- N.B., running *game-basic.luc* is equivalent to `luciole game.lus game` 
   
## game-less-basic.luc

It is a copy of *game-basic.luc*, customized using only basic *luc* features:

- inputs and outputs are organized in a 3x3 grid
- illustrates the use of *line* and *col* commands
- still very user-unfriendly !

## game-advanced.luc

This version no longer use the Luciole main-loop (*stdgui*):
- it implement its own connection with the reactive program via the variables:
   `luc::InputVars, luc::OutputVars, luc::Prg`
- layout and main loop is made using *ptk* primitives


# Full tcl+ptk

In addition to the Lustre versions, the folder contains 
a in pure tcltk version, not really related to luciole,
that illustrates the "tree-like" style of *ptk* to describe
a graphical interface.

`ptk_game.tcl`

