Difference between revisions of "Adding a puzzle activity"

From GCompris
Jump to: navigation, search
 
(Do a puzzle)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Warning: This is a google translated page, it needs rework'''
 
 
 
[[Image: Geography.jpg | thumb | 200 px | The activity of geography.]]
 
[[Image: Geography.jpg | thumb | 200 px | The activity of geography.]]
 
= Explanation on the use of script in python shapegame.py =
 
= Explanation on the use of script in python shapegame.py =
Line 6: Line 4:
 
== Introduction ==
 
== Introduction ==
  
GCompris is found in several activities running on the same principle, it is a puzzle with pieces by icons in a selector to the left of the screen.
+
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 of GCompris.
+
We called these activities as ''type'' shapegame because they use the motor activity ''shapegame'' of GCompris.
  
A python script for drawing software [http://www.gimp-fr.org Gimp] was written by Miguel De Izarra. It allows to create such activities. The challenge then is to link images to a location on a background image.
+
A python script for the drawing software [http://www.gimp-fr.org 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.
  
 
== Tools ==
 
== Tools ==
Line 18: Line 16:
 
== Installation script ==
 
== Installation script ==
  
The latest version of this script is in the [http://svn.gnome.org/viewcvs/gcompris/trunk/tools/gcompris_shapegame.py?view=markup source directory] GCompris (tools). Attention is not distributed in the source tarball of GCompris.
+
The latest version of this script is in the [http://git.gnome.org/cgit/gcompris/tree/tools/gcompris_shapegame.py tools directory of GCompris]. Warning, it is not distributed in the source tarball of GCompris.
  
You can [download http://gcompris.net/docs/download/gcompris_shapegame.py] this version.
+
You can [http://git.gnome.org/browse/gcompris/plain/tools/gcompris_shapegame.py download this version].
  
To install the script, it must move in the directory script gimp. For GNU / Linux, you must copy it in''~/. gimp-2.2/plug-ins /''( "~" represents your home directory as / home / bruno). Ensuitre add him run mode:
+
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).
  
 
<code> <pre>
 
<code> <pre>
gcompris_shapegame.py cp ~ / .gimp-2.2/plug-ins /
+
cp gcompris_shapegame.py ~/.gimp-2.6/plug-ins/
chmod + x ~ / .gimp-2.2/plug-ins/gcompris_shapegame.py
+
chmod +x ~/.gimp-2.6/plug-ins/gcompris_shapegame.py
</pre> </ code>
+
</pre> </code>
  
 
Now, when you start GIMP, a new menu appears in the menu of a file (Python-fu-> GCompris).
 
Now, when you start GIMP, a new menu appears in the menu of a file (Python-fu-> GCompris).
  
 
== Preparation ==
 
== Preparation ==
It is easy to make yourself a map to GCompris. The best explanation is by example, here is how the map of Brazil with his statements to place.
+
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 a file format type. Xcf. 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 [http://fr.wikipedia.org/ wiki / Home Wikipedia]. This site provides maps GPL or public domain (absolutely necessary to respect the copyrights).
+
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 [http://www.wikipedia.org/ 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 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.
  
== == Creating regions
+
== Creating regions ==
The card contains Brazil found in light gray and dark gray borders and the borders of his dominions. 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 [http://gcompris.net/docs/download/shapegame_brazil_map.xcf download] result.
+
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 [http://gcompris.net/docs/download/shapegame_brazil_map.xcf download] the result.
  
Run the script == ==
+
== Run the script ==
 
When you run the script, you'll pass a number of parameter:
 
When you run the script, you'll pass a number of parameter:
  
Line 50: Line 48:
 
* KeepLimit: Keep the limits between countries (Preferred if complex map)
 
* KeepLimit: Keep the limits between countries (Preferred if complex map)
 
* Level: The level of activity
 
* Level: The level of activity
* Sublevel: Deputy 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 for future Thurs
+
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 repertoire of GCompris.
+
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.
For our example we will put the data in / usr / share / gcompris / boards / geography_country
+
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
+
== Do a puzzle ==
 +
To make a puzzle, it's easier, just take any picture 800x520, save it in gimp and run the script''Python-Fu-> gcompris-> Puzzle''. You can then choose how many pieces to create. Other details are similar to the creation script map.
  
To make a puzzle, it's easier, just take any picture 800x520, save it in gimp and run the script''Python-Fu-> gcompris-> Puzzle''. You can then choose how many pieces to create. Other details are similar to the creation script map.
+
[[Category:English]]

Latest revision as of 12:24, 27 January 2015

The activity of geography.

Explanation on the use of script in python shapegame.py

Introduction

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.

Tools

  • The script in python
  • The Gimp
  • A map in 800x520 format with well defined states

Installation script

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).

Preparation

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.

Creating regions

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.