The game of Ayumu
Posted: Sun Jun 15, 2014 3:11 pm
More info on http://en.wikipedia.org/wiki/Ayumu_(chimpanzee)
You can try to be be as good as Ayumu but you'll probably not success!
' *** Ayumu game, © Philippe Lagarrigue, 2014 ***
number = 6
milisec = 750
GOSUB init_app
GOSUB init_vars
begin:
GOSUB define_coord
GOSUB dessine_nombres
GOSUB wait_ms
GOSUB cache_nombres
nombre = 1
DO
GOSUB no_touch
GOSUB get_touch
GOSUB check_pos
UNTIL nombre > number
IF okay = 1 THEN
DRAW TEXT "Bravo !" AT 0,0
PAUSE 1
ENDIF
GOTO begin
wait_ms:
f = TIMER() + milisec
not_yet:
IF f > TIMER() THEN GOTO not_yet
RETURN
check_pos:
IF tx >= x(nombre) - 30 AND tx <= x(nombre) + 70 THEN
IF ty >= y(nombre) - 30 AND ty <= y(nombre) + 70 THEN
DRAW TEXT nombre AT x(nombre), y(nombre)
nombre = nombre + 1
okay = 1
RETURN
ENDIF
ENDIF
nombre = number + 1
okay = 0
RETURN
check_coord:
IF f > 1 THEN
FOR e = 1 TO f - 1
IF xc(e) = xx AND yc(e) = yy THEN
again = 1
RETURN
ENDIF
NEXT e
ENDIF
again = 0
RETURN
define_coord:
FOR f = 1 TO number
hasard:
xx = RND (segment - 1) + 1
yy = RND (segment - 1) + 1
GOSUB check_coord
IF again = 1 THEN GOTO hasard
xc(f) = xx
yc(f) = yy
NEXT f
GOSUB def_coord
RETURN
def_coord:
FOR f = 1 TO number
x(f) = xoffset + xc(f) * pixels
y(f) = yoffset + yc(f) * pixels
NEXT f
RETURN
dessine_nombres:
GRAPHICS CLEAR
FOR f = 1 TO number
DRAW TEXT f AT x(f), y(f)
NEXT f
RETURN
cache_nombres:
FOR f = 1 TO number
FILL CIRCLE 15 + x(f), 20 + y(f) SIZE 50
NEXT f
RETURN
new_orientation:
GET ORIENTATION p2
IF p1 <> p2 THEN
GOSUB init_vars
GOSUB def_coord
GOSUB cache_nombres
' dessine nombres trouvés
FOR f = 1 TO nombre - 1
DRAW TEXT f AT x(f), y(f)
NEXT f
ENDIF
RETURN
no_touch:
loop1:
GOSUB new_orientation
GET TOUCH 0 AS tx, ty
IF tx <> -1 THEN GOTO loop1
RETURN
get_touch:
loop2:
GOSUB new_orientation
GET TOUCH 0 AS tx, ty
IF tx = -1 THEN GOTO loop2
RETURN
init_app:
GRAPHICS
SHADOW ON
RANDOMIZE
DIM x(number+1), y(number+1)
DIM xc(number+1), yc(number+1)
segment = 6
DRAW FONT SIZE 50
DRAW COLOR 0,0,0
RETURN
init_vars:
GRAPHICS CLEAR
GET ORIENTATION p1
sw = SCREEN_WIDTH()
sh = SCREEN_HEIGHT()
xlen = INT (sw / segment)
ylen = INT (sh / segment)
IF xlen < ylen THEN
pixels = xlen
ELSE
pixels = ylen
ENDIF
xoffset = (sw - pixels * segment) / 2
yoffset = (sh - pixels * segment) / 2
RETURN
You can try to be be as good as Ayumu but you'll probably not success!
' *** Ayumu game, © Philippe Lagarrigue, 2014 ***
number = 6
milisec = 750
GOSUB init_app
GOSUB init_vars
begin:
GOSUB define_coord
GOSUB dessine_nombres
GOSUB wait_ms
GOSUB cache_nombres
nombre = 1
DO
GOSUB no_touch
GOSUB get_touch
GOSUB check_pos
UNTIL nombre > number
IF okay = 1 THEN
DRAW TEXT "Bravo !" AT 0,0
PAUSE 1
ENDIF
GOTO begin
wait_ms:
f = TIMER() + milisec
not_yet:
IF f > TIMER() THEN GOTO not_yet
RETURN
check_pos:
IF tx >= x(nombre) - 30 AND tx <= x(nombre) + 70 THEN
IF ty >= y(nombre) - 30 AND ty <= y(nombre) + 70 THEN
DRAW TEXT nombre AT x(nombre), y(nombre)
nombre = nombre + 1
okay = 1
RETURN
ENDIF
ENDIF
nombre = number + 1
okay = 0
RETURN
check_coord:
IF f > 1 THEN
FOR e = 1 TO f - 1
IF xc(e) = xx AND yc(e) = yy THEN
again = 1
RETURN
ENDIF
NEXT e
ENDIF
again = 0
RETURN
define_coord:
FOR f = 1 TO number
hasard:
xx = RND (segment - 1) + 1
yy = RND (segment - 1) + 1
GOSUB check_coord
IF again = 1 THEN GOTO hasard
xc(f) = xx
yc(f) = yy
NEXT f
GOSUB def_coord
RETURN
def_coord:
FOR f = 1 TO number
x(f) = xoffset + xc(f) * pixels
y(f) = yoffset + yc(f) * pixels
NEXT f
RETURN
dessine_nombres:
GRAPHICS CLEAR
FOR f = 1 TO number
DRAW TEXT f AT x(f), y(f)
NEXT f
RETURN
cache_nombres:
FOR f = 1 TO number
FILL CIRCLE 15 + x(f), 20 + y(f) SIZE 50
NEXT f
RETURN
new_orientation:
GET ORIENTATION p2
IF p1 <> p2 THEN
GOSUB init_vars
GOSUB def_coord
GOSUB cache_nombres
' dessine nombres trouvés
FOR f = 1 TO nombre - 1
DRAW TEXT f AT x(f), y(f)
NEXT f
ENDIF
RETURN
no_touch:
loop1:
GOSUB new_orientation
GET TOUCH 0 AS tx, ty
IF tx <> -1 THEN GOTO loop1
RETURN
get_touch:
loop2:
GOSUB new_orientation
GET TOUCH 0 AS tx, ty
IF tx = -1 THEN GOTO loop2
RETURN
init_app:
GRAPHICS
SHADOW ON
RANDOMIZE
DIM x(number+1), y(number+1)
DIM xc(number+1), yc(number+1)
segment = 6
DRAW FONT SIZE 50
DRAW COLOR 0,0,0
RETURN
init_vars:
GRAPHICS CLEAR
GET ORIENTATION p1
sw = SCREEN_WIDTH()
sh = SCREEN_HEIGHT()
xlen = INT (sw / segment)
ylen = INT (sh / segment)
IF xlen < ylen THEN
pixels = xlen
ELSE
pixels = ylen
ENDIF
xoffset = (sw - pixels * segment) / 2
yoffset = (sh - pixels * segment) / 2
RETURN