Adding a puzzle activity
Explanation on the use of script in python shapegame.py
In GCompris there are several activities running on the same principle, it is a puzzle with pieces represented as icons in a selector to the left of the screen. We called these activities as type shapegame because they use the motor activity shapegame of GCompris.
A python script for the drawing software Gimp was written by Miguel De Izarra. It allows to create such activities. The challenge then is put layers of images on a background image.
- The script in python
- The Gimp
- A map in 800x520 format with well defined states
The latest version of this script is in the tools directory of GCompris. Warning, it is not distributed in the source tarball of GCompris.
You can download this version.
To install the script, just copy it in Gimp script directory. For GNU/Linux, you must copy it in~/. gimp-2.2/plug-ins /( "~" represents your home directory as /home/bruno).
cp gcompris_shapegame.py ~/.gimp-2.6/plug-ins/ chmod +x ~/.gimp-2.6/plug-ins/gcompris_shapegame.py
Now, when you start GIMP, a new menu appears in the menu of a file (Python-fu-> GCompris).
It is easy to make a map to GCompris. The best explanation is by example, here is how to build the map of Brazil.
The script only works with the .xcf file format of Gimp. This is the standard file format for Gimp (a very good free software for editing and bitmap drawing). Having too lazy to make my own map of Brazil, I downloaded SVG (vector format allowing resizing without loss of image quality) from Wikipedia. This site provides maps GPL or public domain (absolutely necessary to respect the copyrights).
The card must have the right size 800x520px. The SVG format can be exported in bitmap that size. Once converted the svg to bitmap, the map can be opened with Gimp.
The card contains Brazil found in light gray and dark gray borders and the borders of his regions. Each state is well defined visually. With the magic of GIMP which is actually a tool of contiguous pixel selection, click on a state. The state in question is selected (it is surrounded by small animated features). Please right-click the mouse to display a popup menu, choose: Select> Save channel. Change the channel name (by default it is called Copy selection mask) by naming the state name (eg Rio Grande do Norte). And repeat for each state. To get an idea download the result.
Run the script
When you run the script, you'll pass a number of parameter:
- Activity_name: Activity name (default = geography)
- File: subdirectory (eg Brazil)
- Title: title of the puzzle GCompris
- Bordersize: The size of the border between the countries (3 works)
- KeepLimit: Keep the limits between countries (Preferred if complex map)
- Level: The level of activity
- Sublevel: Sub level of activity
The script will take care of each color region, create a border around the country and linking the canal to its location.
The result is saved in the same directory as your source image. You must then manually move the result to the right place in the GCompris directory. In our example we will put the data in /usr/share/gcompris/boards/geography_country Once done, run GCompris, go in the geography country activity, move to the level you created and play test your creation.
Do a puzzle
To make a puzzle, it's easier, just take any picture 800x520, save it in gimp and run the scriptPython-Fu-> gcompris-> Puzzle. You can then choose how many pieces to create. Other details are similar to the creation script map.