Commit 1cf84ab3 authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

Added non functionnal hanoi_real game (the real tower of hanoi).

* boards/searace.xml.in: removed " and <> that bugs our reread menu
parent ff75254f
2005-09-10 Bruno coudoin <bruno.coudoin@free.fr>
Added non functionnal hanoi_real game (the real tower of hanoi).
* boards/Makefile.am:
* boards/hanoi_real.xml.in:
* boards/searace.xml.in: removed " and <> that bugs our reread menu
* docs/screenshots/billard.jpg:
* po/Makefile.in.in:
* po/POTFILES.in:
* src/boards/Makefile.am:
* src/boards/hanoi.c: (hanoi_create_item): fixed string
* src/boards/hanoi_real.c: (pause_board), (start_board),
(end_board), (set_level), (is_our_board), (hanoi_next_level),
(hanoi_destroy_all_items), (dump_solution), (print_piece),
(hanoi_create_item), (game_won), (is_completed), (item_event):
2005-09-09 Bruno coudoin <bruno.coudoin@free.fr>
Fixed connect4 (bug #313432)
......
......@@ -51,6 +51,7 @@ xml_in_files = \
gnumchmenu.xml.in \
gletters.xml.in \
hanoi.xml.in \
hanoi_real.xml.in \
hexagon.xml.in \
imageid.xml.in \
imagename.xml.in \
......
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="hanoi_real"
type="hanoi_real"
section="/boards"
icon="boardicons/hanoi.png"
difficulty="0"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
boarddir="">
<_title>The Tower of Hanoi</_title>
<_description>Reproduce the tower on the right side</_description>
<_prerequisite>Mouse manipulation</_prerequisite>
<_goal>The object of the game is to move the entire stack to another peg, obeying the following rules:
* only one disc may be moved at a time
* no disc may be placed atop a smaller disc</_goal>
<_manual>Drag and Drop the top pieces only from one peg to another, to
reproduce the tower on the right in the empty space on the left.
</_manual>
<_credit>The puzzle was invented by the French mathematician Edouard Lucas in 1883. There is a legend about a Hindu temple whose priests were constantly engaged in moving a set of 64 discs according to the rules of the Tower of Hanoi puzzle. According to the legend, the world would end when the priests finished their work. The puzzle is therefore also known as the Tower of Brahma puzzle. It is not clear whether Lucas invented this legend or was inspired by it. (source Wikipedia http://en.wikipedia.org/wiki/Tower_of_hanoi)
</_credit>
</Board>
</GCompris>
......@@ -14,12 +14,12 @@
<_goal>In this activity, you will learn how to enter commands to a computer.
Even if the language is extremely basic, you learn here how to think ahead and enter a program.
This activity can be used to introduce the programming concept to kids.</_goal>
<_manual>In the text box, enter commands, line by line, to direct your ship. You can use any of the commands shown between the two entry areas. When you use the "left" or "right" commands, you have to tell the ship how far you want it to turn, in degrees (e.g. "left 30" degrees). Giving special measurements like this is also called 'passing a parameter': this is how we tell the computer how much to do something.
The "forward" command accepts a distance parameter, so you can tell it how far you want your ship to move. The default is 1, so if you don't add that parameter, each move will be 1 unit. (Defaults are handy values that help the computer out when we don't pass any parameters.)
<_manual>In the text box, enter commands, line by line, to direct your ship. You can use any of the commands shown between the two entry areas. When you use the 'left' or 'right' commands, you have to tell the ship how far you want it to turn, in degrees (e.g. 'left 30' degrees). Giving special measurements like this is also called 'passing a parameter': this is how we tell the computer how much to do something.
The 'forward' command accepts a distance parameter, so you can tell it how far you want your ship to move. The default is 1, so if you don't add that parameter, each move will be 1 unit. (Defaults are handy values that help the computer out when we don't pass any parameters.)
So you could say:
"left 90" : make a perpendicular turn (a whole corner) to the left.
"forward 10" : go ahead 10 units (as shown on the ruler).
'left 90' : make a perpendicular turn (a whole corner) to the left.
'forward 10' : go ahead 10 units (as shown on the ruler).
The goal is to reach the right edge of the screen (the red line). When you get there, you can try to improve your program, with the same weather conditions, and try again, using the Retry button.
You can click and drag your mouse anywhere on the map, to show a measurement of distance (how far) and angle (how much turn).
......
docs/screenshots/billard.jpg

11 KB | W: | H:

docs/screenshots/billard.jpg

13.8 KB | W: | H:

docs/screenshots/billard.jpg
docs/screenshots/billard.jpg
docs/screenshots/billard.jpg
docs/screenshots/billard.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -11,11 +11,6 @@
#
# - Modified by jacob berkman <jacob@ximian.com> to install
# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
#
# - Modified by Rodney Dawes <dobey@novell.com> for use with intltool
#
# We have the following line for use by intltoolize:
# INTLTOOL_MAKEFILE
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
PACKAGE = @PACKAGE@
......@@ -26,33 +21,27 @@ SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = @datadir@
datarootdir = @datarootdir@
libdir = @libdir@
localedir = $(libdir)/locale
gnulocaledir = $(datadir)/locale
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
subdir = po
install_sh = @install_sh@
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
CC = @CC@
GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
INTLTOOL_UPDATE = @INTLTOOL_UPDATE@
INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@
MSGMERGE = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist
GENPOT = INTLTOOL_EXTRACT=$(INTLTOOL_EXTRACT) srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot
MSGMERGE = msgmerge
DEFS = @DEFS@
CFLAGS = @CFLAGS@
......@@ -65,9 +54,8 @@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
SOURCES =
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = ChangeLog Makefile.in.in POTFILES.in \
$(POFILES) $(SOURCES)
EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
$(POFILES) $(GMOFILES) $(SOURCES)
POTFILES = \
......@@ -83,13 +71,13 @@ INSTOBJEXT = @INSTOBJEXT@
.po.pox:
$(MAKE) $(GETTEXT_PACKAGE).pot
$(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox
$(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox
.po.mo:
$(MSGFMT) -o $@ $<
.po.gmo:
file=`echo $* | sed 's,.*/,,'`.gmo \
file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
&& rm -f $$file && $(GMSGFMT) -o $$file $<
.po.cat:
......@@ -102,15 +90,20 @@ all: all-@USE_NLS@
all-yes: $(CATALOGS)
all-no:
$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(GENPOT)
$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
--add-comments --keyword=_ --keyword=N_ \
--files-from=$(srcdir)/POTFILES.in \
&& test ! -f $(GETTEXT_PACKAGE).po \
|| ( rm -f $(srcdir)/$(GETTEXT_PACKAGE).pot \
&& mv $(GETTEXT_PACKAGE).po $(srcdir)/$(GETTEXT_PACKAGE).pot )
install: install-exec install-data
install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
if test -n "$(MKINSTALLDIRS)"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
......@@ -124,7 +117,7 @@ install-data-yes: all
esac; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
if test -n "$(MKINSTALLDIRS)"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $$dir; \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
......@@ -152,7 +145,7 @@ install-data-yes: all
fi; \
done
if test "$(PACKAGE)" = "glib"; then \
if test -n "$(MKINSTALLDIRS)"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
......@@ -176,37 +169,29 @@ uninstall:
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
done
if test "$(PACKAGE)" = "glib"; then \
rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
fi
rm -f $(DESTDIR)$(gettextsrcdir)/po-Makefile.in.in
check: all $(GETTEXT_PACKAGE).pot
check: all
dvi info tags TAGS ID:
mostlyclean:
rm -f core core.* *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp
rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp
rm -fr *.o
rm -f .intltool-merge-cache
clean: mostlyclean
distclean: clean
rm -f Makefile Makefile.in POTFILES
rm -f *.mo *.msg *.cat *.cat.m $(GMOFILES)
rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f Makefile.in.in
rm -f $(GMOFILES)
distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
dist distdir: $(DISTFILES)
dist distdir: update-po $(DISTFILES)
dists="$(DISTFILES)"; \
extra_dists="$(EXTRA_DISTFILES)"; \
for file in $$extra_dists; do \
test -f $$file && dists="$$dists $$file"; \
done; \
for file in $$dists; do \
ln $(srcdir)/$$file $(distdir) 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir); \
......@@ -214,28 +199,19 @@ dist distdir: $(DISTFILES)
update-po: Makefile
$(MAKE) $(GETTEXT_PACKAGE).pot
tmpdir=`pwd`; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
mv $$lang.po $$lang.old.po; \
echo "$$lang:"; \
result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \
if $$result; then \
if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
rm -f $$tmpdir/$$lang.new.po; \
else \
if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
:; \
else \
echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
rm -f $$tmpdir/$$lang.new.po; \
exit 1; \
fi; \
fi; \
if $(MSGMERGE) $$lang.old.po $(GETTEXT_PACKAGE).pot -o $$lang.po; then \
rm -f $$lang.old.po; \
else \
echo "msgmerge for $$cat failed!"; \
rm -f $$tmpdir/$$lang.new.po; \
rm -f $$lang.po; \
mv $$lang.old.po $$lang.po; \
fi; \
done
......@@ -243,13 +219,17 @@ update-po: Makefile
# and Intltool tags (enclosed in square brackets), and appending a full
# relative path to them
POTFILES: POTFILES.in
( posrcprefix='$(top_srcdir)/'; \
( if test 'x$(srcdir)' != 'x.'; then \
posrcprefix='$(top_srcdir)/'; \
else \
posrcprefix="../"; \
fi; \
rm -f $@-t $@ \
&& (sed -e '/^#/d' \
-e 's/^[[].*] *//' \
-e '/^[ ]*$$/d' \
-e "s@^@ $$posrcprefix@" $(srcdir)/$@.in \
| sed -e '$$!s/$$/ \\/') > $@-t \
&& (sed -e '/^#/d' \
-e "s/^\[.*\] +//" \
-e '/^[ ]*$$/d' \
-e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
| sed -e '$$s/\\$$//') > $@-t \
&& chmod a-w $@-t \
&& mv $@-t $@ )
......
......@@ -99,6 +99,7 @@ boards/gnumch-multiples.xml.in
boards/gnumch-primes.xml.in
boards/gnumchmenu.xml.in
boards/hanoi.xml.in
boards/hanoi_real.xml.in
boards/hexagon.xml.in
boards/imageid.xml.in
boards/imageid/board1.xml.in
......@@ -192,6 +193,7 @@ src/boards/erase.c
src/boards/fifteen.c
src/boards/gletters.c
src/boards/hanoi.c
src/boards/hanoi_real.c
src/boards/imageid.c
src/boards/leftright.c
src/boards/machpuzzle.c
......
......@@ -40,6 +40,7 @@ lib_LTLIBRARIES = \
libfifteen.la \
libgletters.la \
libhanoi.la \
libhanoi_real.la \
libimageid.la \
libleftright.la \
libsuperbrain.la \
......@@ -224,6 +225,10 @@ libhanoi_la_LDFLAGS = -module -avoid-version
libhanoi_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la
libhanoi_la_SOURCES = hanoi.c
libhanoi_real_la_LDFLAGS = -module -avoid-version
libhanoi_real_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la
libhanoi_real_la_SOURCES = hanoi_real.c
libfifteen_la_LDFLAGS = -module -avoid-version
libfifteen_la_LIBADD = $(top_builddir)/src/gcompris/libgcompris-1.la
libfifteen_la_SOURCES = fifteen.c
......
......@@ -345,7 +345,7 @@ static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent)
gnome_canvas_item_new (boardRootItem,
gnome_canvas_text_get_type (),
"text", _("Reproduce in the empty area the same tower as the one on the right"),
"text", _("Re-create in the empty area the same tower as the one on the right"),
"font", gcompris_skin_font_board_medium,
"x", (double) BOARDWIDTH/2,
"y", (double) BOARDHEIGHT - 50,
......
/* gcompris - hanoi_real.c
*
* Copyright (C) 2005 Bruno Coudoin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ctype.h>
#include <math.h>
#include <assert.h>
#include "gcompris/gcompris.h"
#define SOUNDLISTFILE PACKAGE
static GcomprisBoard *gcomprisBoard = NULL;
static gboolean board_paused = TRUE;
static void start_board (GcomprisBoard *agcomprisBoard);
static void pause_board (gboolean pause);
static void end_board (void);
static gboolean is_our_board (GcomprisBoard *gcomprisBoard);
static void set_level (guint level);
static int gamewon;
static void game_won(void);
static GnomeCanvasGroup *boardRootItem = NULL;
static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent);
static void hanoi_destroy_all_items(void);
static void hanoi_next_level(void);
/*
* Contains the piece information
*/
typedef struct {
GnomeCanvasItem *item;
gint i;
gint j;
double x;
double y;
double xt;
double yt;
gboolean on_top;
gint width;
} PieceItem;
static gint item_event(GnomeCanvasItem *item, GdkEvent *event, PieceItem *data);
/* This contains the layout of the pieces */
#define MAX_NUMBER_X 3
#define MAX_NUMBER_Y 10
static PieceItem *position[MAX_NUMBER_X][MAX_NUMBER_Y];
static int number_of_item = 0;
static int number_of_item_x = MAX_NUMBER_X;
static int number_of_item_y = 0;
static int item_width;
static int item_height;
/* Keep here the limit of the column */
static gint limit_column_x1[MAX_NUMBER_X];
static gint limit_column_x2[MAX_NUMBER_X];
static gint peg_disc_count[MAX_NUMBER_X];
static gint peg_top_disc[MAX_NUMBER_X];
static guint colorlist [] =
{
0x00FFFFFF,
0xA00000FF,
0xF00000FF,
0x00A000FF,
0x00F000FF,
0x0000AAFF,
0x0000FFFF,
0x505000FF,
0xA0A000FF,
0xF0F000FF,
0x005050FF,
0x00A0A0FF,
0x500050FF,
0xA000A0FF,
0xF000F0FF
};
#define NUMBER_OF_COLOR 14
/* Description of this plugin */
static BoardPlugin menu_bp =
{
NULL,
NULL,
N_("Tower of Hanoi"),
N_(""),
"Bruno Coudoin <bruno.coudoin@free.fr>",
NULL,
NULL,
NULL,
NULL,
start_board,
pause_board,
end_board,
is_our_board,
NULL,
NULL,
set_level,
NULL,
NULL,
NULL,
NULL
};
/*
* Main entry point mandatory for each Gcompris's game
* ---------------------------------------------------
*
*/
GET_BPLUGIN_INFO(hanoi)
/*
* in : boolean TRUE = PAUSE : FALSE = CONTINUE
*
*/
static void pause_board (gboolean pause)
{
if(gcomprisBoard==NULL)
return;
if(gamewon == TRUE && pause == FALSE) /* the game is won */
{
game_won();
}
board_paused = pause;
}
/*
*/
static void start_board (GcomprisBoard *agcomprisBoard)
{
if(agcomprisBoard!=NULL)
{
gcomprisBoard=agcomprisBoard;
gcomprisBoard->level=1;
gcomprisBoard->maxlevel=6;
gcomprisBoard->sublevel=1;
gcomprisBoard->number_of_sublevel=1; /* Go to next level after this number of 'play' */
gcompris_bar_set(GCOMPRIS_BAR_LEVEL);
gcompris_set_background(gnome_canvas_root(gcomprisBoard->canvas),
gcompris_image_to_skin("gcompris-bg.jpg"));
boardRootItem = NULL;
hanoi_next_level();
gamewon = FALSE;
pause_board(FALSE);
}
}
/* ======================================= */
static void end_board ()
{
if(gcomprisBoard!=NULL)
{
pause_board(TRUE);
hanoi_destroy_all_items();
}
gcomprisBoard = NULL;
}
/* ======================================= */
static void set_level (guint level)
{
if(gcomprisBoard!=NULL)
{
gcomprisBoard->level=level;
gcomprisBoard->sublevel=1;
hanoi_next_level();
}
}
/* ======================================= */
static gboolean is_our_board (GcomprisBoard *gcomprisBoard)
{
if (gcomprisBoard)
{
if(g_strcasecmp(gcomprisBoard->type, "hanoi_real")==0)
{
/* Set the plugin entry */
gcomprisBoard->plugin=&menu_bp;
return TRUE;
}
}
return FALSE;
}
/*-------------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------------*/
/* set initial values for the next level */
static void hanoi_next_level()
{
gcompris_bar_set_level(gcomprisBoard);
hanoi_destroy_all_items();
gamewon = FALSE;
/* Select level difficulty */
number_of_item_y = gcomprisBoard->level + 2;
/* Try the next level */
hanoi_create_item(gnome_canvas_root(gcomprisBoard->canvas));
}
/* ==================================== */
/* Destroy all the items */
static void hanoi_destroy_all_items()
{
guint i,j;
if(boardRootItem!=NULL)
{
gtk_object_destroy (GTK_OBJECT(boardRootItem));
/* Cleanup our memory structure */
for(i=0; i<number_of_item_x; i++)
{
for(j=0; j<number_of_item_y; j++)
{
g_free(position[i][j]);
}
}
}
boardRootItem = NULL;
}
#if 0
static void dump_solution()
{
guint i, j;
printf("Dumping solution\n");
for(i=0; i<number_of_item_x; i++)
{
for(j=0; j<number_of_item_y; j++)
{
printf("(%d,%d= width=%d top=%d) ", position[i][j]->i, position[i][j]->j,
position[i][j]->width,
position[i][j]->on_top);
}
printf("\n");
}
}
#endif
/* ==================================== */
static GnomeCanvasItem *hanoi_create_item(GnomeCanvasGroup *parent)
{
int i,j;
double gap_x, gap_y;
double baseline;
GnomeCanvasItem *item = NULL;
guint color_to_place;
GnomeCanvasPathDef *path;
guint w;
GdkPixbuf *pixmap = NULL;
boardRootItem = GNOME_CANVAS_GROUP(
gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
gnome_canvas_group_get_type (),
"x", (double) 0,
"y", (double) 0,
NULL));
pixmap = gcompris_load_skin_pixmap("gcompris-shapelabel.png");
if(pixmap) {
gnome_canvas_item_new (boardRootItem,
gnome_canvas_pixbuf_get_type (),
"pixbuf", pixmap,
"x", (double)BOARDWIDTH/2,