Post Reply 
Memory game
10-12-2014, 09:01 AM (This post was last modified: 10-12-2014 09:03 AM by Tyann.)
Post: #1
Memory game
Hello, sorry for my English (google traduction)
Here's a little memory game.
The numbers 1 to 9 appear on the screen and are hidden by rectangles .
Can you point them in the order remembering their position on the screen.
If you take option 1 : free observation, the numbers will be hidden when you point 1 .
Other options let you preset viewing figures and mask time.
Why this program name : " test monkey " because chimpanzees performs this test with an observation time of a second without ever making a mistake .
( seen in a TV show ) .
Good fun.
Code:

Filmat()
BEGIN
 LOCAL i,x,y,f;
 FOR i FROM 1 TO 9 DO
  f:=0;
REPEAT 
   x:=RANDINT(1,8);
   y:=RANDINT(1,6);
   IF M1(y,x)==0 THEN
    M1(y,x):=i;f:=1;
   END;
  UNTIL f;
 END;
END;
Afmat(m)
BEGIN
 LOCAL i,j,x,y;
 RECT_P();
 FOR i FROM 1 TO 6 DO
  FOR j FROM 1 TO 8 DO
   IF M1(i,j) >0 THEN
    x:=j*40-32;y:=i*40-32;
    IF m THEN
     TEXTOUT_P(STRING(M1(i,j)),G0,x,y,7,C_noir);
    ELSE
     RECT_P(x-7,y-7,x+31,y+31,C_gris);
    END;
   END;
  END;
 END;
END;
EXPORT Test_du_singe()
BEGIN
 LOCAL x,y,i,j,n,r,t;
 LOCAL m,o;
 M1:=MAKEMAT(0,6,8);
 Filmat();
 CHOOSE(m,"Observation","Libre","4 sec.","6 sec.","8 sec.");
 Afmat(1);
 n:=1;t:=TICKS;
 IF m>1 THEN
  t:=m*2;o:=1;
  WAIT(t);
  Afmat(0);
 END;
 REPEAT 
  WHILE MOUSE(4)<0  DO
  END;
  IF n==1  AND  NOT o THEN
   t:=ROUND((TICKS-t)/1000,1); 
  END;
  x:=MOUSE(2);y:=MOUSE(3);
  WHILE MOUSE(4)≥0 DO
  END;
  j:=IP(y/40)+1;i:=IP(x/40)+1;
  r:=M1(j,i);
  IF r==n THEN
   IF n==1  AND  NOT o THEN
    Afmat(0);
   END;
   n:=n+1;r:=n;
   RECT_P(i*40-40,j*40-40,i*40,j*40);
  END
 UNTIL n==10  OR r≠n  AND r≠0;
 Afmat(1);
 FILLPOLY_P({i*40-40,j*40-40,i*40,j*40-40,i*40,j*40,i*40-40,j*40},C_vert1,128); 
 WHILE GETKEY<0 DO
 END;
 IF n==10 THEN
  MSGBOX("BRAVO "+CHAR(10)+"Temps d'observation : "+STRING(t)+" sec.");
 END;
END;
This program uses a small library of colors I also give you .
Code:
EXPORT C_noir:=#0h;
EXPORT C_noir1:=#130E0A:32h;
EXPORT C_blanc:=#FFFFFF:32h;
EXPORT C_blanc1:=#F4FEFE:32h;
EXPORT C_gris:=#7D7D7D:32h;
EXPORT C_vert:=#78C832:32h;
EXPORT C_vert1:=#096A09:32h;
EXPORT C_vert2:=#3A9D23:32h;
EXPORT C_vert3:=#9EFD38:32h;
EXPORT C_bleu:=#1919EB:32h;
EXPORT C_bleu1:=#3A8EBA:32h;
EXPORT C_bleu2:=#77B5FE:32h;
EXPORT C_rouge:=#FF0000:32h;
EXPORT C_rouge1:=#B82010:32h;
EXPORT C_rouge2:=#850606:32h;
EXPORT C_saumon:=#F88E55:32h;
EXPORT C_amety:=#884DA7:32h;
EXPORT C_argent:=#CECECE:32h;
EXPORT C_azur:=#007FFF:32h;
EXPORT C_beige:=#C8AD7F:32h;
EXPORT C_beurre:=#F0E36B:32h;
EXPORT C_bordo:=#6D071A:32h;
EXPORT C_boutor:=#FCDC12:32h;
EXPORT C_cafe:=#462E01:32h;
EXPORT C_carmin:=#960018:32h;
EXPORT C_emerod:=#01D758:32h;
EXPORT C_fer:=#848484:32h;
EXPORT C_feu:=#FF4901:32h;
EXPORT C_fushia:=#FD3F92:32h;
EXPORT C_jade:=#87E990:32h;
EXPORT C_jaune:=#FFFF00:32h;
EXPORT C_lilas:=#B066D2:32h;
EXPORT C_marrine:=#03224C:32h;
EXPORT C_marron:=#582900:32h;
EXPORT C_menthe:=#16B84E:32h;
EXPORT C_noiset:=#955628:32h;
EXPORT C_or:=#FFD700:32h;
EXPORT C_orange:=#FF7F00:32h;
EXPORT C_rose:=#FD6C9E:32h;
EXPORT C_rose1:=#FD3F92:32h;
EXPORT C_violet:=#7F30FF:32h;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)