Commit 598f3220 authored by Bruno Coudoin's avatar Bruno Coudoin

Yves added a new board called bargame. The manual is:

	Put balls in the holes. You win if the computer play the last one.
	If you want Tux to begin, just click on him.
	Bruno Created the background image, Yves did the rest of the game.

	Serveral changes in the computer menu. Now there is a submenu for the
	mouse activity. I redid the erase activity icons to be more precse.
	The mouse comes from openclipart.

	I redid the tux teacher image as found in bargame and connect4

	Some minor fixes for win32 compilation

	log format is now generic and does not need to be localised.
parent c2a56593
2005-04-18 Bruno coudoin <bruno.coudoin@free.fr>
Yves added a new board called bargame. The manual is:
Put balls in the holes. You win if the computer play the last one.
If you want Tux to begin, just click on him.
Bruno Created the background image, Yves did the rest of the game.
Serveral changes in the computer menu. Now there is a submenu for the
mouse activity. I redid the erase activity icons to be more precse.
The mouse comes from openclipart.
I redid the tux teacher image as found in bargame and connect4
Some minor fixes for win32 compilation
log format is now generic and does not need to be localised.
* Makefile.am:
* boards/Makefile.am:
* boards/bargame.xml.in:
* boards/bargame/blue_ball.png:
* boards/bargame/board.png:
* boards/bargame/case.png:
* boards/bargame/case_last.png:
* boards/bargame/green_ball.png:
* boards/bargame/mask.png:
* boards/bargame/mask_last.png:
* boards/bargame/ombre.png:
* boards/boardicons/bargame.png:
* boards/boardicons/connect4.png:
* boards/boardicons/erase.png:
* boards/boardicons/erase_clic.png:
* boards/boardicons/erase_double_clic.png:
* boards/boardicons/mouse.png:
* boards/boardicons/mouse_move.png:
* boards/clickgame.xml.in:
* boards/connect4/prof.png:
* boards/followline.xml.in:
* boards/images/scenery6_background.png:
* boards/images/superbrain_background.jpg:
* boards/images/tux-teacher.png:
* boards/mouse.xml.in:
* configure.in:
* po/POTFILES.in:
* src/boards/chess.c:
* src/boards/erase.c:
* src/boards/py-mod-anim.c: (AnimCanvas_free),
(py_gcompris_animcanvas_setstate),
(py_gcompris_animcanvas_swapanim),
(py_gcompris_animcanvas_destroy):
* src/boards/python/Makefile.am:
* src/boards/python/bargame.py:
* src/boards/python/connect4.py:
* src/boards/python/gcompris/score/.cvsignore:
* src/gcompris/anim.c: (gcompris_load_animation),
(gcompris_activate_animation), (gcompris_swap_animation):
* src/gcompris/file_selector.c: (create_rootdir):
* src/gcompris/log.c: (gcompris_log_end):
* src/gcompris/properties.c: (create_rootdir):
2005-04-15 Bruno coudoin <bruno.coudoin@free.fr>
* src/boards/erase.c: (start_board), (end_board), (set_level),
......
## Process this file with automake to produce Makefile.in
SUBDIRS = po src docs boards
if TEXINFO
DOCS_SUBDIR=docs
else
DOCS_SUBDIR=
endif
SUBDIRS = po src boards $(DOCS_SUBDIR)
icondir=$(datadir)/pixmaps
icon_DATA = gcompris.png gcompris-edit.png
......
......@@ -14,6 +14,7 @@ xml_in_files = \
anim.xml.in \
babymatch.xml.in \
babyshapes.xml.in \
bargame.xml.in \
billard.xml.in \
ballcatch.xml.in \
boards.xml.in \
......
<?xml version="1.0" encoding="UTF-8"?>
<GCompris>
<Board
name="bargame"
type="python:bargame"
section="/boards/."
difficulty="2"
icon="boardicons/bargame.png"
author="Yves Combe"
boarddir="bargame">
<_title>bar game</_title>
<_description>Do not put the last ball</_description>
<_prerequisite>Brain</_prerequisite>
<_goal>Logic training activity</_goal>
<_manual>Put balls in the holes. You win if the computer play the last one.
If you want Tux to begin, just click on him.
</_manual>
</Board>
</GCompris>
boards/boardicons/connect4.png

12 KB | W: | H:

boards/boardicons/connect4.png

11.8 KB | W: | H:

boards/boardicons/connect4.png
boards/boardicons/connect4.png
boards/boardicons/connect4.png
boards/boardicons/connect4.png
  • 2-up
  • Swipe
  • Onion skin
boards/boardicons/erase.png

7.57 KB | W: | H:

boards/boardicons/erase.png

9.04 KB | W: | H:

boards/boardicons/erase.png
boards/boardicons/erase.png
boards/boardicons/erase.png
boards/boardicons/erase.png
  • 2-up
  • Swipe
  • Onion skin
boards/boardicons/erase_clic.png

9.4 KB | W: | H:

boards/boardicons/erase_clic.png

7.25 KB | W: | H:

boards/boardicons/erase_clic.png
boards/boardicons/erase_clic.png
boards/boardicons/erase_clic.png
boards/boardicons/erase_clic.png
  • 2-up
  • Swipe
  • Onion skin
boards/boardicons/erase_double_clic.png

7.58 KB | W: | H:

boards/boardicons/erase_double_clic.png

8.18 KB | W: | H:

boards/boardicons/erase_double_clic.png
boards/boardicons/erase_double_clic.png
boards/boardicons/erase_double_clic.png
boards/boardicons/erase_double_clic.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -3,7 +3,7 @@
<Board
name="clickgame"
type="clickgame"
section="/computer/."
section="/computer/mouse/."
icon="boardicons/clickgame.png"
difficulty="1"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
......
......@@ -3,7 +3,7 @@
<Board
name="followline"
type="python:followline"
section="/computer/."
section="/computer/mouse/."
icon="boardicons/followline.png"
difficulty="1"
author="Bruno Coudoin (bruno.coudoin@free.fr)"
......
boards/images/superbrain_background.jpg

52.3 KB | W: | H:

boards/images/superbrain_background.jpg

62.3 KB | W: | H:

boards/images/superbrain_background.jpg
boards/images/superbrain_background.jpg
boards/images/superbrain_background.jpg
boards/images/superbrain_background.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -4,7 +4,7 @@
name="mouse"
type="menu"
section="/computer/mouse"
icon="boardicons/erase.png"
icon="boardicons/mouse.png"
author="">
<_title>Mouse manipulation boards</_title>
<_description>Left-Click with the mouse to select an activity</_description>
......
......@@ -264,8 +264,9 @@ AC_DEFINE_UNQUOTED(GNUCHESS, "$GNUCHESS", Defines where GNU Chess resides on the
AC_PATH_PROG(TEXINFO, makeinfo,no)
if test x$TEXINFO = xno; then
AC_MSG_ERROR(Couldn't find texinfo, please install the texinfo package)
AC_MSG_WARN(Couldn't find texinfo, docs are not compiled. please install the texinfo package)
fi
AM_CONDITIONAL(TEXINFO, test x$TEXINFO = xyes)
AC_PATH_PROG(TETEX, texi2html,no)
if test x$TETEX = xno; then
......
......@@ -36,6 +36,7 @@ boards/babyshapes/board5_0.xml.in
boards/babyshapes/board6_0.xml.in
boards/babyshapes/board7_0.xml.in
boards/ballcatch.xml.in
boards/bargame.xml.in
boards/billard.xml.in
boards/boards.xml.in
boards/canal_lock.xml.in
......
......@@ -28,8 +28,6 @@
#include <unistd.h>
#include <signal.h>
#include "sys/wait.h"
#include "chess_notation.h"
#include "gcompris/gcompris.h"
......
......@@ -50,15 +50,15 @@ static int number_of_item_y = 0;
static gint timer_id = 0;
// Default Double clic distance to restore on exit.
gint DefaultDoubleClicDistance;
static gint DefaultDoubleClicDistance;
static gint DoubleClicLevel[6]= { 1000, 750, 600, 500, 400, 250};
gint DoubleClicLevel[6]= { 1000, 750, 600, 500, 400, 250};
1000, 750, 600, 500, 400, 25
#define NORMAL 0
#define CLIC 1
#define DOUBLECLIC 2
gint board_mode = NORMAL;
static gint board_mode = NORMAL;
// List of images to use in the game
static gchar *imageList[] =
......
......@@ -4,6 +4,13 @@
#include "py-gcompris-board.h"
#include "py-mod-anim.h"
#define THROW_INACTIVE_ANIMATION \
{ \
PyErr_SetString(PyExc_RuntimeError, "Tried to access an inactive " \
"AnimCanvas"); \
return NULL; \
}
static int Animation_init(py_GcomprisAnimation *self, PyObject*, PyObject*);
static void Animation_free(py_GcomprisAnimation *self);
......@@ -13,10 +20,16 @@ static PyObject *AnimCanvas_getattr(py_GcomprisAnimCanvas*, char*);
/* AnimCanvas methods */
static PyObject *py_gcompris_animcanvas_setstate(PyObject*, PyObject*);
static PyObject *py_gcompris_animcanvas_swapanim(PyObject*, PyObject*);
static PyObject *py_gcompris_animcanvas_destroy(PyObject*, PyObject*);
static PyMethodDef AnimCanvasMethods[] = {
{"setState", py_gcompris_animcanvas_setstate, METH_VARARGS,
"gcompris_animcanvas_setstate"},
{"swapAnimation", py_gcompris_animcanvas_swapanim, METH_VARARGS,
"gcompris_animcanvas_swapanim"},
{"destroy", py_gcompris_animcanvas_destroy, METH_VARARGS,
"gcompris_animcanvas_destroy"},
{NULL, NULL, 0, NULL}
};
......@@ -185,8 +198,13 @@ static void
AnimCanvas_free(py_GcomprisAnimCanvas *self)
{
printf("*** garbage collecting AnimCanvas ***\n");
gcompris_deactivate_animation(self->item);
Py_DECREF(self->anim);
if(self->item)
{
g_warning("You should really call destroy() on an AnimCanvas "
"instead of relying on the refcounter\n");
gcompris_deactivate_animation(self->item);
Py_DECREF(self->anim);
}
PyObject_DEL(self);
}
......@@ -206,6 +224,8 @@ py_gcompris_animcanvas_setstate(PyObject *self, PyObject *args)
int state;
GcomprisAnimCanvasItem *item = ( (py_GcomprisAnimCanvas*)self )->item;
if(!item) THROW_INACTIVE_ANIMATION;
if(!PyArg_ParseTuple(args, "i:gcompris_animcanvas_setstate", &state))
return NULL;
......@@ -215,6 +235,44 @@ py_gcompris_animcanvas_setstate(PyObject *self, PyObject *args)
return Py_None;
}
static PyObject*
py_gcompris_animcanvas_swapanim(PyObject *self, PyObject *args)
{
py_GcomprisAnimCanvas *s = (py_GcomprisAnimCanvas*)self;
py_GcomprisAnimation *new_anim;
py_GcomprisAnimation *old_anim = (py_GcomprisAnimation*)s->anim;
GcomprisAnimCanvasItem *item = s->item;
if(!item) THROW_INACTIVE_ANIMATION;
if(!PyArg_ParseTuple(args, "O:AnimCanvas_swapAnim", (PyObject**)&new_anim))
return NULL;
gcompris_swap_animation(item, new_anim->a);
Py_INCREF(new_anim);
s->anim = (PyObject*)new_anim;
Py_DECREF(old_anim);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject*
py_gcompris_animcanvas_destroy(PyObject *self, PyObject *args)
{
py_GcomprisAnimCanvas *s = (py_GcomprisAnimCanvas*)self;
if(!s->item) THROW_INACTIVE_ANIMATION;
gcompris_deactivate_animation(s->item);
Py_DECREF(s->anim);
s->item = NULL;
s->anim = NULL;
Py_INCREF(Py_None);
return Py_None;
}
#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */
#define PyMODINIT_FUNC void
#endif
......
......@@ -6,6 +6,7 @@ dist_python_DATA= \
algorithm.py \
anim.py \
ballcatch.py \
bargame.py \
connect4.py \
followline.py \
hexagon.py \
......
# gcompris - BarGame
#
#
#
# Copyright (C) 2004 Christof Petig and Ingo Konrad
#
# 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
#
import gnome
import gnome.canvas
import gcompris
import gcompris.utils
import gcompris.bonus
import gcompris.skin
import pygtk
import gtk
import gtk.gdk
import random
import math
class Gcompris_bargame:
"""The Bar Game"""
def __init__(self, gcomprisBoard):
random.seed()
self.gcomprisBoard = gcomprisBoard
self.rootitem = None
# To display the bonus, we need to pause the board.
self.board_paused = 0
self.number_balls = [[1,4],[2,6],[3,6]]
self.board_size = [15,19,29]
self.gcomprisBoard.level=1
self.gcomprisBoard.maxlevel=4
self.gcomprisBoard.sublevel=1
self.gcomprisBoard.number_of_sublevel=3
self.rootitem = None
def start(self):
# load pixmaps for the ui.
self.pixmap_blue_ball = gcompris.utils.load_pixmap("bargame/blue_ball.png")
self.pixmap_green_ball = gcompris.utils.load_pixmap("bargame/green_ball.png")
self.pixmap_case = gcompris.utils.load_pixmap("bargame/case.png")
self.pixmap_case_last = gcompris.utils.load_pixmap("bargame/case_last.png")
self.pixmap_ombre = gcompris.utils.load_pixmap("bargame/ombre.png")
self.pixmap_mask = gcompris.utils.load_pixmap("bargame/mask.png")
self.pixmap_mask_last = gcompris.utils.load_pixmap("bargame/mask_last.png")
self.pixmap_answer = gcompris.utils.load_pixmap("images/enumerate_answer.png")
self.pixmap_answer_focus = gcompris.utils.load_pixmap("images/enumerate_answer_focus.png")
self.pixmap_background = gcompris.utils.load_pixmap("images/scenery6_background.png")
self.ANSWER_X = gcompris.BOARD_WIDTH - 200
self.ANSWER_Y = gcompris.BOARD_HEIGHT - self.pixmap_answer.get_height() - 5
self.ANSWER_WIDTH = self.pixmap_answer.get_width()
self.ANSWER_HEIGHT = self.pixmap_answer.get_height()
self.pixmap_prof = gcompris.utils.load_pixmap("images/tux-teacher.png")
#
pixmap = gcompris.utils.load_pixmap(gcompris.skin.image_to_skin("button_reload.png"))
if(pixmap):
gcompris.bar_set_repeat_icon(pixmap)
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_OK|gcompris.BAR_REPEAT_ICON)
else:
gcompris.bar_set(gcompris.BAR_LEVEL|gcompris.BAR_OK|gcompris.BAR_REPEAT)
gcompris.bar_set_level(self.gcomprisBoard)
#
self.newGame()
def end(self):
self.rootitem.destroy()
pass
def set_level(self,level):
print 'set_level', level
self.gcomprisBoard.level = level
self.gcomprisBoard.sublevel = 1
gcompris.bar_set_level(self.gcomprisBoard)
self.newGame()
pass
def ok(self):
self.answer.has_focus()
self.play(self.answer.value,True)
pass
def key_press(self, keyval):
#print("got key %i" % keyval)
return gtk.FALSE
def repeat(self):
self.newGame()
def pause(self, pause):
self.board_paused = pause
# When the bonus is displayed, it call us first with pause(1) and then with pause(0)
# the game is won
if(pause == 0):
self.set_sublevel(self.gcomprisBoard.sublevel+1)
return 0
#-------------------------------------------------
#-------------------------------------------------
#-------------------------------------------------
def set_sublevel(self, sublevel):
print 'set_sublevel', sublevel
#sublevel change only in game_won
if sublevel > self.gcomprisBoard.number_of_sublevel:
if self.game_won:
if self.gcomprisBoard.level == self.gcomprisBoard.maxlevel:
gcompris.bonus.board_finished(gcompris.bonus.FINISHED_RANDOM)
return 0
else:
self.set_level(self.gcomprisBoard.level+1)
else:
self.gcomprisBoard.sublevel = 1
self.newGame()
else:
self.gcomprisBoard.sublevel = sublevel
self.newGame()
def scale_pixbuf(self,pixbuf, scale):
return pixbuf.scale_simple(pixbuf.get_width()*scale,
pixbuf.get_height()*scale,
gtk.gdk.INTERP_HYPER)
def calculate_win_places(self):
winners = []
min = self.number_balls[self.gcomprisBoard.sublevel-1][0]
max = self.number_balls[self.gcomprisBoard.sublevel-1][1]
period = (min + max)
winners_list = [(self.board_size[self.gcomprisBoard.sublevel-1] -1 -x)% period for x in range(min)]
for i in range(self.board_size[self.gcomprisBoard.sublevel-1]):
if ((i+1) % period) in winners_list:
winners.append(i)
level_win = (self.gcomprisBoard.level -1) * min
if level_win == 0:
winners = []
else:
winners = winners[-level_win:]
print 'winners', winners
return winners
def newGame(self):
if self.rootitem:
self.rootitem.destroy()
self.scale = gcompris.BOARD_WIDTH/(float(self.board_size[self.gcomprisBoard.sublevel-1])*self.pixmap_case.get_width())
print "scale :", self.scale
self.px_case = self.scale_pixbuf(self.pixmap_case,self.scale)
self.px_mask = self.scale_pixbuf(self.pixmap_mask,self.scale)
self.px_case_last = self.scale_pixbuf(self.pixmap_case_last,self.scale)
self.px_mask_last = self.scale_pixbuf(self.pixmap_mask_last,self.scale)
self.px_ombre = self.scale_pixbuf(self.pixmap_ombre,self.scale)
self.px_green_ball = self.scale_pixbuf(self.pixmap_green_ball,self.scale)
self.px_blue_ball = self.scale_pixbuf(self.pixmap_blue_ball,self.scale)
self.holes = []
self.last_played = -1
self.game_won = False
self.list_win = self.calculate_win_places()
# Create root item canvas for the board
self.rootitem = self.gcomprisBoard.canvas.root().add(
gnome.canvas.CanvasGroup,
x=0,
y=0
)
# background
self.background = self.rootitem.add(
gnome.canvas.CanvasPixbuf,
pixbuf = self.pixmap_background,
x=0,
y=0
)
self.prof = self.prof_button(self,
self.rootitem,
(gcompris.BOARD_WIDTH - self.pixmap_prof.get_width())/2 - 90 ,
230
)
for i in range(self.board_size[self.gcomprisBoard.sublevel-1]):
self.holes.append(self.hole(self,
self.rootitem,
i*self.px_case.get_width(),
gcompris.BOARD_HEIGHT - 120,i))
for i in range(self.number_balls[self.gcomprisBoard.sublevel-1][1]):
self.ball(self.rootitem,
i*self.px_case.get_width()+ 150,
gcompris.BOARD_HEIGHT - 160,
self.px_blue_ball)
self.ball(self.rootitem,
i*self.px_case.get_width()+150,
gcompris.BOARD_HEIGHT-70,
self.px_green_ball)
self.answer = self.answer_button(self,
self.rootitem,
self.ANSWER_X,
self.ANSWER_Y,
self.px_green_ball)
def play(self, value, human):
print 'play:', value
for i in range(1,value+1):
self.last_played += 1
if human:
self.holes[self.last_played].isGreen()
else:
self.holes[self.last_played].isBlue()
if self.last_played == self.board_size[self.gcomprisBoard.sublevel-1] - 1 :
self.gamelost(human)
return
if human:
self.machine_play()
def machine_play(self):
print 'machine_play'
def accessible(x):
if ((x + self.last_played) in self.list_win):
return True
return False
playable = filter(accessible, range(self.number_balls[self.gcomprisBoard.sublevel-1][0], self.number_balls[self.gcomprisBoard.sublevel-1][1]+1))
print 'playable', playable
if playable != []:
self.play(random.choice(playable),False)
else:
self.play(random.choice(range(self.number_balls[self.gcomprisBoard.sublevel-1][0],
self.number_balls[self.gcomprisBoard.sublevel-1][1]+1)),
False)
self.answer.new_value(self.number_balls[self.gcomprisBoard.sublevel-1][0])
def gamelost(self,human):
if human:
print 'Lost !'
gcompris.bonus.display(gcompris.bonus.LOOSE, gcompris.bonus.GNU)
else:
print 'Won !'
self.game_won = True
gcompris.bonus.display(gcompris.bonus.WIN, gcompris.bonus.GNU)
class hole:
def __init__(self, board, root, x, y, index):
self.board = board
self.itemgroup = root.add(
gnome.canvas.CanvasGroup,
x=x,
y=y
)
if (index == (self.board.board_size[self.board.gcomprisBoard.sublevel-1]-1)):
pixbuf_case = self.board.px_case_last
pixbuf_mask = self.board.px_mask_last
else:
pixbuf_case = self.board.px_case
pixbuf_mask = self.board.px_mask
self.base = self.itemgroup.add(
gnome.canvas.CanvasPixbuf,
pixbuf = pixbuf_case,
x=0,
y=0
)
self.ombre = self.itemgroup.add(
gnome.canvas.CanvasPixbuf,
pixbuf = self.board.px_ombre,
x=0,
y=0
)
self.ombre.hide()
self.blue = self.itemgroup.add(
gnome.canvas.CanvasPixbuf,
pixbuf = self.board.px_blue_ball,
x=0,
y=0
)
self.blue.hide()
self.green = self.itemgroup.add(
gnome.canvas.CanvasPixbuf,
pixbuf = self.board.px_green_ball,
x=0,
y=0
)
self.green.hide()
self.mask = self.itemgroup.add(
gnome.canvas.CanvasPixbuf,
pixbuf = pixbuf_mask,
x=0,
y=0,
)
if ((index+1)%5 == 0):
self.text= self.itemgroup.add(
gnome.canvas.CanvasText,
x=self.board.px_case.get_width()/2,
y=-10,
fill_color_rgba=0x000000ffL,
font=gcompris.skin.get_font("gcompris/board/small bold"),
anchor=gtk.ANCHOR_CENTER,
text = index + 1
)
def isBlue(self):
self.blue.show()
self.ombre.show()
def isGreen(self):
self.green.show()
self.ombre.show()
class ball:
def __init__(self, root, x, y, pixbuf):
self.ball = root.add(
gnome.canvas.CanvasPixbuf,
pixbuf = pixbuf,
x=x,
y=y
)
class answer_button:
def __init__(self, board, root, x, y, pixbuf):
self.board = board
self.focus = False
self.itemgroup = root.add(
gnome.canvas.CanvasGroup,
x=x,
y=y
)