FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC

Développement d'applications avec le langage Panoramic
 
AccueilAccueil  RechercherRechercher  Dernières imagesDernières images  S'enregistrerS'enregistrer  MembresMembres  Connexion  
Derniers sujets
» Gestion d'un système client-serveur.
Le jeu de Taquin Emptypar Klaus Ven 17 Mai 2024 - 14:02

» item_index(résolu)
Le jeu de Taquin Emptypar jjn4 Mar 14 Mai 2024 - 19:38

» Bataille terrestre
Le jeu de Taquin Emptypar jjn4 Lun 13 Mai 2024 - 15:01

» SineCube
Le jeu de Taquin Emptypar Marc Sam 11 Mai 2024 - 12:38

» Editeur EliP 6 : Le Tiny éditeur avec 25 onglets de travail
Le jeu de Taquin Emptypar Marc Sam 11 Mai 2024 - 12:22

» Philharmusique
Le jeu de Taquin Emptypar jjn4 Ven 10 Mai 2024 - 13:58

» PANORAMIC V 1
Le jeu de Taquin Emptypar papydall Jeu 9 Mai 2024 - 3:22

» select intégrés [résolu]
Le jeu de Taquin Emptypar jjn4 Mer 8 Mai 2024 - 17:00

» number_mouse_up
Le jeu de Taquin Emptypar jjn4 Mer 8 Mai 2024 - 11:59

» Aide de PANORAMIC
Le jeu de Taquin Emptypar jjn4 Mer 8 Mai 2024 - 11:16

» trop de fichiers en cours
Le jeu de Taquin Emptypar lepetitmarocain Mer 8 Mai 2024 - 10:43

» Je teste PANORAMIC V 1 beta 1
Le jeu de Taquin Emptypar papydall Mer 8 Mai 2024 - 4:17

» bouton dans autre form que 0(résolu)
Le jeu de Taquin Emptypar leclode Lun 6 Mai 2024 - 13:59

» KGF_dll - nouvelles versions
Le jeu de Taquin Emptypar Klaus Lun 6 Mai 2024 - 11:41

» @Jack
Le jeu de Taquin Emptypar Jack Mar 30 Avr 2024 - 20:40

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Mai 2024
LunMarMerJeuVenSamDim
  12345
6789101112
13141516171819
20212223242526
2728293031  
CalendrierCalendrier
-14%
Le deal à ne pas rater :
Apple MacBook Air (2020) 13,3″ Puce Apple M1 – RAM 8Go/SSD 256Go
799 € 930 €
Voir le deal

 

 Le jeu de Taquin

Aller en bas 
5 participants
AuteurMessage
Klaus

Klaus


Nombre de messages : 12301
Age : 75
Localisation : Ile de France
Date d'inscription : 29/12/2009

Le jeu de Taquin Empty
MessageSujet: Le jeu de Taquin   Le jeu de Taquin EmptySam 21 Fév 2015 - 22:56

Selon le modèle du jeu de l'Ane rouge (Papydall), j'ai fait le jeu de Taquin (ou Pousse-Pousse). Ce jeu se présente sous la forme de 16 cases, organisées en 4 lignes de 4 colonnes. Les cases sont préremplies par les chiffres de 1 à 15, dans un ordre aléatoire. La case en bas à droite est vide. Le but du jeu est de remettre les chiffres dans l'ordre, en laissant la case en bas à droite vide. Pour cela, on peut glisser un pion voisin d'une case vide dans cette case vide, etc. La touche Echap remet un nouveau jeu en abandonnant la partie en cours. Voici le code:
Code:
' le_Taquin.bas


label click, touche

dim unite% : unite% = 100
dim bord%  : bord%  = 10

dim pieces%(15,8)
  ' (n%,d%) n%=numéro de pièce (1...15)
  '          d%=1 n%
  '          d%=2 x%
  '          d%=3 y%
  '          d%=4 nombre horizontal
  '          d%=5 nombre vertical
  '          d%=6 R%
  '          d%=7 G%
  '          d%=8 B%

dim terrain%(4,4) : ' 4 lignes de 4 colonnes
dim table%(15)    : ' table des nombres de 1 à 15, en ordre aléatoire
dim table_exist%

width  0,4*unite%+2*bord% + 16
height 0,4*unite%+2*bord% + 39
left   0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu Taquin"
on_key_down 0,touche

picture 1 : width 1,4*unite%+2*bord% : height 1,4*unite%+2*bord%
            color 1,102,0,0
            2d_pen_color 102,0,0
            2d_pen_width 2
            on_click 1,click
            2d_target_is 1
            print_target_is 1
            font_color 1,255,255,255
            font_bold 1

initialiser()
end

touche:
  select scancode
    case 27: ' echap
      if message_confirmation_yes_no("Voulez-vous vraiment relancer le jeu ?")=1
        color 1,102,0,0
        initialiser()
      end_if
  end_select
  return

click:
  deplacer_piece()
  return
  
sub chercher_table(k%,i%)
  dim_local j%
  table_exist% = 0
  if i%=1 then exit_sub
  for j%=1 to i%-1
    if table%(j%)=k%
      table_exist% = 1
      exit_sub
    end_if
  next j%
end_sub
  
sub initialiser()
  dim_local i%, j%, n%, k%
  for i%=1 to 15
    table_exist% = 1
    while table_exist%=1
      k% = int(rnd(14.999))+1
      chercher_table(k%,i%)
    end_while
    table%(i%) = k%
  next i%
  for i%=1 to 4
    for j%=1 to 4
      terrain%(i%,j%) = 0
      n% = n% + 1
      if n%<16 then creer_piece(table%(n%),i%,j%,1,1,254,204,0)
    next j%
  next i%

end_sub

sub creer_piece(n%,x%,y%,nh%,nv%,R%,G%,B%)
  dim_local i%, j%, tx%, ty%
  pieces%(n%,1) = n%
  pieces%(n%,2) = x%
  pieces%(n%,3) = y%
  pieces%(n%,4) = nh%
  pieces%(n%,5) = nv%
  pieces%(n%,6) = R%
  pieces%(n%,7) = G%
  pieces%(n%,8) = B%
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%) = n%
    next j%
  next i%
  2d_fill_color R%,G%,B%
  tx% = bord%+(x%-1)*unite%
  ty% = bord%+(y%-1)*unite%
  2d_rectangle tx%,ty%,tx%+nh%*unite%,ty%+nv%*unite%
  tx% = tx% + int((nh%*unite%)/2)
  ty% = ty% + int((nv%*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  print_locate tx%-5,ty%-5
  print n%
end_sub

sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, j%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(1)

'  x1% = mouse_x_left_up(1)
'  y1% = mouse_y_left_up(1)

  x1% = mouse_x_position(1)
  y1% = mouse_y_position(1)

  cx% = int((x%-bord%+unite%-1)/unite%)
  cy% = int((y%-bord%+unite%-1)/unite%)
  cx1% = int((x1%-bord%+unite%-1)/unite%)
  cy1% = int((y1%-bord%+unite%-1)/unite%)
  if cx%<1 then cx% = 1
  if cx%>4 then cx% = 4
  if cx1%<1 then cx1% = 1
  if cx1%>4 then cx1% = 4
  if cy%<1 then cy% = 1
  if cy%>4 then cy% = 5
  if cy1%<1 then cy1% = 1
  if cy1%>4 then cy1% = 5
  p% = terrain%(cx%,cy%)
  if p%=0 then exit_sub                    : ' on a cliqué dans un espace vide ?
  if terrain%(cx1%,cy1%)<>0 then exit_sub  : ' on veut tirer vers un espace occupé ?
  ' chercher si le décalage est possible
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  if cx1%<>cx%         : ' décaler horizontalement ?
    if cx1%>cx%        : ' décaler à droite ?
      if x%<4
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%+nh%,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          deplacer_droite(p%)
        end_if
      end_if
    else               : ' décaler à gauche !
      if x%>1
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%-1,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          deplacer_gauche(p%)
        end_if
      end_if
    end_if
  else                 : ' pas de décalage horizontal !
    if cy1%<>cy%       : ' décaler verticalement ?
      if cy1%>cy%      : ' décaler en bas ?
        if y%<5
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%+nv%)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            deplacer_bas(p%)
          end_if
        end_if
      else             : ' décaler en haut !
        if y%>1
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%-1)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            deplacer_haut(p%)
          end_if
        end_if
      end_if
    end_if
  end_if
  if terrain%(4,4)=0
    cnt% = 0
    for i%=1 to 4
      for j%=1 to 4
        cnt% = cnt% + 1
        if cnt%<16
          if terrain%(i%,j%)<>cnt% then exit_sub
        end_if
      next j%
    next i%
    message "BRAVO ! C'est gagné !"
  end_if
end_sub

sub deplacer_gauche(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%-1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%+nh%-1,y%+i%) = 0
  next i%
  pieces%(p%,2) = pieces%(p%,2) - 1
  dessiner_terrain()
end_sub

sub deplacer_haut(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%-1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%+nv%-1) = 0
  next i%
  pieces%(p%,3) = pieces%(p%,3) - 1
  dessiner_terrain()
end_sub

sub deplacer_droite(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=nh%-1 to 0 step -1
    for j%=0 to nv%-1
      terrain%(x%+i%+1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%,y%+i%) = 0
  next i%
  pieces%(p%,2) = pieces%(p%,2) + 1
  dessiner_terrain()
end_sub

sub deplacer_bas(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=nv%-1 to 0 step -1
      terrain%(x%+i%,y%+j%+1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%) = 0
  next i%
  pieces%(p%,3) = pieces%(p%,3) + 1
  dessiner_terrain()
end_sub

sub dessiner_terrain()
  dim_local p%, tx%, ty%
  color 1,102,0,0
  for p%=1 to 15
    tx% = bord%+(pieces%(p%,2)-1)*unite%
    ty% = bord%+(pieces%(p%,3)-1)*unite%
    2d_fill_color pieces%(p%,6), pieces%(p%,7), pieces%(p%,8)
    2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
    tx% = tx% + int((pieces%(p%,4)*unite%)/2)
    ty% = ty% + int((pieces%(p%,5)*unite%)/2)
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print p%
  next p%
end_sub


Dernière édition par Klaus le Dim 22 Fév 2015 - 1:41, édité 2 fois
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptySam 21 Fév 2015 - 23:17

Je vais tester, mais il manque la déclaration de j% à la ligne 117 pour l'utilisation ligne 197. J'y retourne
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptySam 21 Fév 2015 - 23:26

Oui à par le j% manquant, ça marche bien.
Tu pourrais faire un petit article sur ton Taquin Klaus avec un zoom sur la technique du drag and drop utilisée qui n'est pas si évitente à trouver.
Revenir en haut Aller en bas
Yannick




Nombre de messages : 8611
Age : 53
Localisation : Bretagne
Date d'inscription : 15/02/2010

Le jeu de Taquin Empty
MessageSujet: re   Le jeu de Taquin EmptyDim 22 Fév 2015 - 1:10

C' est le même principe de jeu que celui que l' on avait fait avec des images en morceaux .
Avec le drag and drop au lieu d' un clic sur un sprite...Embarassed
Revenir en haut Aller en bas
Klaus

Klaus


Nombre de messages : 12301
Age : 75
Localisation : Ile de France
Date d'inscription : 29/12/2009

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 1:23

Merci d'avoir relevé cet oubli, Jicehel. J'ai corrigé dans le premier post.

Je peux envisager un article à ce sujet - je vais y réfléchir. J'attendrai que l'ensemble ait mûri un peu.
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


Nombre de messages : 7009
Age : 73
Localisation : Moknine (Tunisie) Entre la chaise et le clavier
Date d'inscription : 03/03/2012

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 3:18

Avec le chat noir, l’âne rouge, le taquin, Tetris, le Solitaire, le Memory Starwars, etc.. on a de quoi se faire la torture cérébrale.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


Nombre de messages : 12301
Age : 75
Localisation : Ile de France
Date d'inscription : 29/12/2009

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 8:50

Voici une nouvelle version. Fonctionnellement identique, elle élimine cependant le clignotement au déplacement d'un pion:
Code:
' le_Taquin.bas


label click, touche

dim unite% : unite% = 100
dim bord%  : bord%  = 10

dim pieces%(15,8)
  ' (n%,d%)  n%=numéro de pièce (1...15)
  '          d%=1 n%
  '          d%=2 x%
  '          d%=3 y%
  '          d%=4 nombre horizontal
  '          d%=5 nombre vertical
  '          d%=6 R%
  '          d%=7 G%
  '          d%=8 B%

dim terrain%(4,4) : ' 4 lignes de 4 colonnes
dim table%(15)    : ' table des nombres de 1 à 15, en ordre aléatoire
dim table_exist%

width  0,4*unite%+2*bord% + 16
height 0,4*unite%+2*bord% + 39
left   0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu Taquin"
on_key_down 0,touche

picture 1 : width 1,4*unite%+2*bord% : height 1,4*unite%+2*bord%
            color 1,102,0,0
            2d_target_is 1
            2d_pen_color 102,0,0
            2d_pen_width 2
            on_click 1,click
            print_target_is 1
            font_color 1,255,255,255
            font_bold 1

initialiser()
end

touche:
  select scancode
    case 27: ' echap
      if message_confirmation_yes_no("Voulez-vous vraiment relancer le jeu ?")=1
        color 1,102,0,0
        initialiser()
      end_if
  end_select
  return

click:
  deplacer_piece()
  return
  
sub chercher_table(k%,i%)
  dim_local j%
  table_exist% = 0
  if i%=1 then exit_sub
  for j%=1 to i%-1
    if table%(j%)=k%
      table_exist% = 1
      exit_sub
    end_if
  next j%
end_sub
  
sub initialiser()
  dim_local i%, j%, n%, k%
  for i%=1 to 15
    table_exist% = 1
    while table_exist%=1
      k% = int(rnd(14.999))+1
      chercher_table(k%,i%)
    end_while
    table%(i%) = k%
  next i%
  for i%=1 to 4
    for j%=1 to 4
      terrain%(i%,j%) = 0
      n% = n% + 1
      if n%<16 then creer_piece(table%(n%),i%,j%,1,1,254,204,0)
    next j%
  next i%

end_sub

sub creer_piece(n%,x%,y%,nh%,nv%,R%,G%,B%)
  dim_local i%, j%, tx%, ty%
  pieces%(n%,1) = n%
  pieces%(n%,2) = x%
  pieces%(n%,3) = y%
  pieces%(n%,4) = nh%
  pieces%(n%,5) = nv%
  pieces%(n%,6) = R%
  pieces%(n%,7) = G%
  pieces%(n%,8) = B%
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%) = n%
    next j%
  next i%
  2d_fill_color R%,G%,B%
  tx% = bord%+(x%-1)*unite%
  ty% = bord%+(y%-1)*unite%
  2d_rectangle tx%,ty%,tx%+nh%*unite%,ty%+nv%*unite%
  tx% = tx% + int((nh%*unite%)/2)
  ty% = ty% + int((nv%*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  print_locate tx%-5,ty%-5
  print n%
end_sub

sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, j%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(1)

'  x1% = mouse_x_left_up(1)
'  y1% = mouse_y_left_up(1)

  x1% = mouse_x_position(1)
  y1% = mouse_y_position(1)

  cx% = int((x%-bord%+unite%-1)/unite%)
  cy% = int((y%-bord%+unite%-1)/unite%)
  cx1% = int((x1%-bord%+unite%-1)/unite%)
  cy1% = int((y1%-bord%+unite%-1)/unite%)
  if cx%<1 then cx% = 1
  if cx%>4 then cx% = 4
  if cx1%<1 then cx1% = 1
  if cx1%>4 then cx1% = 4
  if cy%<1 then cy% = 1
  if cy%>4 then cy% = 5
  if cy1%<1 then cy1% = 1
  if cy1%>4 then cy1% = 5
  p% = terrain%(cx%,cy%)
  if p%=0 then exit_sub                    : ' on a cliqué dans un espace vide ?
  if terrain%(cx1%,cy1%)<>0 then exit_sub  : ' on veut tirer vers un espace occupé ?
  ' chercher si le décalage est possible
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  if cx1%<>cx%         : ' décaler horizontalement ?
    if cx1%>cx%        : ' décaler à droite ?
      if x%<4
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%+nh%,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          deplacer_droite(p%)
        end_if
      end_if
    else               : ' décaler à gauche !
      if x%>1
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%-1,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          deplacer_gauche(p%)
        end_if
      end_if
    end_if
  else                 : ' pas de décalage horizontal !
    if cy1%<>cy%       : ' décaler verticalement ?
      if cy1%>cy%      : ' décaler en bas ?
        if y%<5
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%+nv%)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            deplacer_bas(p%)
          end_if
        end_if
      else             : ' décaler en haut !
        if y%>1
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%-1)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            deplacer_haut(p%)
          end_if
        end_if
      end_if
    end_if
  end_if
  if terrain%(4,4)=0
    cnt% = 0
    for i%=1 to 4
      for j%=1 to 4
        cnt% = cnt% + 1
        if cnt%<16
          if terrain%(i%,j%)<>cnt% then exit_sub
        end_if
      next j%
    next i%
    message "BRAVO ! C'est gagné !"
  end_if
end_sub

sub deplacer_gauche(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%-1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%+nh%-1,y%+i%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,2) = pieces%(p%,2) - 1
  dessiner_piece(p%)
end_sub

sub deplacer_haut(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%-1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%+nv%-1) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,3) = pieces%(p%,3) - 1
  dessiner_piece(p%)
end_sub

sub deplacer_droite(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=nh%-1 to 0 step -1
    for j%=0 to nv%-1
      terrain%(x%+i%+1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%,y%+i%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,2) = pieces%(p%,2) + 1
  dessiner_piece(p%)
end_sub

sub deplacer_bas(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=nv%-1 to 0 step -1
      terrain%(x%+i%,y%+j%+1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,3) = pieces%(p%,3) + 1
  dessiner_piece(p%)
end_sub

sub effacer_piece(p%)
  dim_local tx%, ty%
  tx% = bord%+(pieces%(p%,2)-1)*unite%
  ty% = bord%+(pieces%(p%,3)-1)*unite%
  2d_fill_color 102,0,0
  2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
end_sub

sub dessiner_piece(p%)
  dim_local tx%, ty%
  tx% = bord%+(pieces%(p%,2)-1)*unite%
  ty% = bord%+(pieces%(p%,3)-1)*unite%
  2d_fill_color pieces%(p%,6), pieces%(p%,7), pieces%(p%,8)
  2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
  tx% = tx% + int((pieces%(p%,4)*unite%)/2)
  ty% = ty% + int((pieces%(p%,5)*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  print_locate tx%-5,ty%-5
  print p%
end_sub


Dernière édition par Klaus le Dim 22 Fév 2015 - 9:39, édité 1 fois
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
Jean Claude

Jean Claude


Nombre de messages : 5950
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 9:27

Celui là, on l'avais déjà, mais maintenant il fonctionne avec le déplacement par la souris.

Que je jeu ! actuellement, et ce n'est pas pour me déplaire cheers

A+
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 9:45

Oui, beaucoup mieux la derniere version, l'affichage est nickel et la détection du mouvement pour les pièces est plus fluide.
Revenir en haut Aller en bas
Klaus

Klaus


Nombre de messages : 12301
Age : 75
Localisation : Ile de France
Date d'inscription : 29/12/2009

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 13:25

Et voici la version avec annulation du dernier ou des derniers mouvements, jusqu'au retour à la position de départ. C'est la touche "Espace" qui fait cela:
Code:
' le_Taquin.bas


label click, touche

dim unite% : unite% = 100
dim bord%  : bord%  = 10

dim pieces%(15,8)
  ' (n%,d%)  n%=numéro de pièce (1...15)
  '          d%=1 n%
  '          d%=2 x%
  '          d%=3 y%
  '          d%=4 nombre horizontal
  '          d%=5 nombre vertical
  '          d%=6 R%
  '          d%=7 G%
  '          d%=8 B%

dim terrain%(4,4) : ' 4 lignes de 4 colonnes
dim table%(15)    : ' table des nombres de 1 à 15, en ordre aléatoire
dim table_exist%

width  0,4*unite%+2*bord% + 16
height 0,4*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu Taquin"
on_key_down 0,touche

picture 1 : width 1,4*unite%+2*bord% : height 1,4*unite%+2*bord%
            color 1,102,0,0
            2d_target_is 1
            2d_pen_color 102,0,0
            2d_pen_width 2
            on_click 1,click
            print_target_is 1
            font_color 1,255,255,255
            font_bold 1

dlist 2  : ' pour défaire la dernière action par la touche "espace"

initialiser()
end

touche:
  select scancode
    case 27: ' echap
      if message_confirmation_yes_no("Voulez-vous vraiment relancer le jeu ?")=1
        color 1,102,0,0
        initialiser()
      end_if
    case 32: ' "espace" = défaire le dernier mouvement
      if count(2)>0 then defaire()
  end_select
  return

click:
  deplacer_piece()
  return
 
sub chercher_table(k%,i%)
  dim_local j%
  table_exist% = 0
  if i%=1 then exit_sub
  for j%=1 to i%-1
    if table%(j%)=k%
      table_exist% = 1
      exit_sub
    end_if
  next j%
end_sub
 
sub initialiser()
  clear 2
  dim_local i%, j%, n%, k%
  for i%=1 to 15
    table_exist% = 1
    while table_exist%=1
      k% = int(rnd(14.999))+1
      chercher_table(k%,i%)
    end_while
    table%(i%) = k%
  next i%
  for i%=1 to 4
    for j%=1 to 4
      terrain%(i%,j%) = 0
      n% = n% + 1
      if n%<16 then creer_piece(table%(n%),i%,j%,1,1,254,204,0)
    next j%
  next i%

end_sub

sub creer_piece(n%,x%,y%,nh%,nv%,R%,G%,B%)
  dim_local i%, j%, tx%, ty%
  pieces%(n%,1) = n%
  pieces%(n%,2) = x%
  pieces%(n%,3) = y%
  pieces%(n%,4) = nh%
  pieces%(n%,5) = nv%
  pieces%(n%,6) = R%
  pieces%(n%,7) = G%
  pieces%(n%,8) = B%
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%) = n%
    next j%
  next i%
  2d_fill_color R%,G%,B%
  tx% = bord%+(x%-1)*unite%
  ty% = bord%+(y%-1)*unite%
  2d_rectangle tx%,ty%,tx%+nh%*unite%,ty%+nv%*unite%
  tx% = tx% + int((nh%*unite%)/2)
  ty% = ty% + int((nv%*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  print_locate tx%-5,ty%-5
  print n%
end_sub

sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, j%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(1)

'  x1% = mouse_x_left_up(1)
'  y1% = mouse_y_left_up(1)

  x1% = mouse_x_position(1)
  y1% = mouse_y_position(1)

  cx% = int((x%-bord%+unite%-1)/unite%)
  cy% = int((y%-bord%+unite%-1)/unite%)
  cx1% = int((x1%-bord%+unite%-1)/unite%)
  cy1% = int((y1%-bord%+unite%-1)/unite%)
  if cx%<1 then cx% = 1
  if cx%>4 then cx% = 4
  if cx1%<1 then cx1% = 1
  if cx1%>4 then cx1% = 4
  if cy%<1 then cy% = 1
  if cy%>4 then cy% = 5
  if cy1%<1 then cy1% = 1
  if cy1%>4 then cy1% = 5
  p% = terrain%(cx%,cy%)
  if p%=0 then exit_sub                    : ' on a cliqué dans un espace vide ?
  if terrain%(cx1%,cy1%)<>0 then exit_sub  : ' on veut tirer vers un espace occupé ?
  ' chercher si le décalage est possible
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  if cx1%<>cx%        : ' décaler horizontalement ?
    if cx1%>cx%        : ' décaler à droite ?
      if x%<4
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%+nh%,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          item_add 2,str$(p%)+"D"
          deplacer_droite(p%)
        end_if
      end_if
    else              : ' décaler à gauche !
      if x%>1
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%-1,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          item_add 2,str$(p%)+"G"
          deplacer_gauche(p%)
        end_if
      end_if
    end_if
  else                : ' pas de décalage horizontal !
    if cy1%<>cy%      : ' décaler verticalement ?
      if cy1%>cy%      : ' décaler en bas ?
        if y%<5
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%+nv%)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            item_add 2,str$(p%)+"B"
            deplacer_bas(p%)
          end_if
        end_if
      else            : ' décaler en haut !
        if y%>1
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%-1)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            item_add 2,str$(p%)+"H"
            deplacer_haut(p%)
          end_if
        end_if
      end_if
    end_if
  end_if
  if terrain%(4,4)=0
    cnt% = 0
    for i%=1 to 4
      for j%=1 to 4
        cnt% = cnt% + 1
        if cnt%<16
          if terrain%(i%,j%)<>cnt% then exit_sub
        end_if
      next j%
    next i%
    message "BRAVO ! C'est gagné !"
  end_if
end_sub

sub deplacer_gauche(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%-1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%+nh%-1,y%+i%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,2) = pieces%(p%,2) - 1
  dessiner_piece(p%)
end_sub

sub deplacer_haut(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%-1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%+nv%-1) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,3) = pieces%(p%,3) - 1
  dessiner_piece(p%)
end_sub

sub deplacer_droite(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=nh%-1 to 0 step -1
    for j%=0 to nv%-1
      terrain%(x%+i%+1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%,y%+i%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,2) = pieces%(p%,2) + 1
  dessiner_piece(p%)
end_sub

sub deplacer_bas(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=nv%-1 to 0 step -1
      terrain%(x%+i%,y%+j%+1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,3) = pieces%(p%,3) + 1
  dessiner_piece(p%)
end_sub

sub effacer_piece(p%)
  dim_local tx%, ty%
  tx% = bord%+(pieces%(p%,2)-1)*unite%
  ty% = bord%+(pieces%(p%,3)-1)*unite%
  2d_fill_color 102,0,0
  2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
end_sub

sub dessiner_piece(p%)
  dim_local tx%, ty%
  tx% = bord%+(pieces%(p%,2)-1)*unite%
  ty% = bord%+(pieces%(p%,3)-1)*unite%
  2d_fill_color pieces%(p%,6), pieces%(p%,7), pieces%(p%,8)
  2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
  tx% = tx% + int((pieces%(p%,4)*unite%)/2)
  ty% = ty% + int((pieces%(p%,5)*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  print_locate tx%-5,ty%-5
  print p%
end_sub

sub defaire()
  dim_local s$, p%, d$, d%
  s$ = item_read$(2,count(2))
  item_delete 2,count(2)
  d$ = right$(s$,1)
  p% = val(left$(s$,len(s$)-1))
  d% = instr("GHDB",d$)
  select d%
    case 1: ' gauche
      deplacer_droite(p%)
    case 2: ' haut
      deplacer_bas(p%)
    case 3: ' droite
      deplacer_gauche(p%)
    case 4: ' bas
      deplacer_haut(p%)
  end_select
end_sub
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
Jean Claude

Jean Claude


Nombre de messages : 5950
Age : 69
Localisation : 83 Var
Date d'inscription : 07/05/2009

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 13:45

Même remarque que pour l’âne rouge, la couleur des N° de case (Blanc sur fond Jaune) est illisible.

J'ai remplacé la ligne 38 par: font_color 1,0,0,255

Le retour en arrière avec "la barre d'espace", c'est génial.

A+
Revenir en haut Aller en bas
Jicehel

Jicehel


Nombre de messages : 5947
Age : 51
Localisation : 77500
Date d'inscription : 18/04/2011

Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin EmptyDim 22 Fév 2015 - 14:47

Meme chose que pour l’âne rouge, j'ai centré les pièces à 2 chiffres:
Code:
' le_Taquin.bas


label click, touche

dim unite% : unite% = 100
dim bord%  : bord%  = 10

dim pieces%(15,8)
  ' (n%,d%)  n%=numéro de pièce (1...15)
  '          d%=1 n%
  '          d%=2 x%
  '          d%=3 y%
  '          d%=4 nombre horizontal
  '          d%=5 nombre vertical
  '          d%=6 R%
  '          d%=7 G%
  '          d%=8 B%

dim terrain%(4,4) : ' 4 lignes de 4 colonnes
dim table%(15)    : ' table des nombres de 1 à 15, en ordre aléatoire
dim table_exist%

width  0,4*unite%+2*bord% + 16
height 0,4*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu Taquin"
on_key_down 0,touche

picture 1 : width 1,4*unite%+2*bord% : height 1,4*unite%+2*bord%
            color 1,102,0,0
            2d_target_is 1
            2d_pen_color 102,0,0
            2d_pen_width 2
            on_click 1,click
            print_target_is 1
            font_color 1,25,15,15
            font_bold 1

dlist 2  : ' pour défaire la dernière action par la touche "espace"

initialiser()
end

touche:
  select scancode
    case 27: ' echap
      if message_confirmation_yes_no("Voulez-vous vraiment relancer le jeu ?")=1
        color 1,102,0,0
        initialiser()
      end_if
    case 32: ' "espace" = défaire le dernier mouvement
      if count(2)>0 then defaire()
  end_select
  return

click:
  deplacer_piece()
  return

sub chercher_table(k%,i%)
  dim_local j%
  table_exist% = 0
  if i%=1 then exit_sub
  for j%=1 to i%-1
    if table%(j%)=k%
      table_exist% = 1
      exit_sub
    end_if
  next j%
end_sub

sub initialiser()
  clear 2
  dim_local i%, j%, n%, k%
  for i%=1 to 15
    table_exist% = 1
    while table_exist%=1
      k% = int(rnd(14.999))+1
      chercher_table(k%,i%)
    end_while
    table%(i%) = k%
  next i%
  for i%=1 to 4
    for j%=1 to 4
      terrain%(i%,j%) = 0
      n% = n% + 1
      if n%<16 then creer_piece(table%(n%),i%,j%,1,1,254,204,0)
    next j%
  next i%

end_sub

sub creer_piece(n%,x%,y%,nh%,nv%,R%,G%,B%)
  dim_local i%, j%, tx%, ty%
  pieces%(n%,1) = n%
  pieces%(n%,2) = x%
  pieces%(n%,3) = y%
  pieces%(n%,4) = nh%
  pieces%(n%,5) = nv%
  pieces%(n%,6) = R%
  pieces%(n%,7) = G%
  pieces%(n%,8) = B%
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%) = n%
    next j%
  next i%
  2d_fill_color R%,G%,B%
  tx% = bord%+(x%-1)*unite%
  ty% = bord%+(y%-1)*unite%
  2d_rectangle tx%,ty%,tx%+nh%*unite%,ty%+nv%*unite%
  tx% = tx% + int((nh%*unite%)/2)
  ty% = ty% + int((nv%*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  if len(str$(n%)) = 1
    print_locate tx%-4,ty%-6
  else
    print_locate tx%-8,ty%-6
  end_if
  print n%
end_sub

sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, j%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(1)

'  x1% = mouse_x_left_up(1)
'  y1% = mouse_y_left_up(1)

  x1% = mouse_x_position(1)
  y1% = mouse_y_position(1)

  cx% = int((x%-bord%+unite%-1)/unite%)
  cy% = int((y%-bord%+unite%-1)/unite%)
  cx1% = int((x1%-bord%+unite%-1)/unite%)
  cy1% = int((y1%-bord%+unite%-1)/unite%)
  if cx%<1 then cx% = 1
  if cx%>4 then cx% = 4
  if cx1%<1 then cx1% = 1
  if cx1%>4 then cx1% = 4
  if cy%<1 then cy% = 1
  if cy%>4 then cy% = 5
  if cy1%<1 then cy1% = 1
  if cy1%>4 then cy1% = 5
  p% = terrain%(cx%,cy%)
  if p%=0 then exit_sub                    : ' on a cliqué dans un espace vide ?
  if terrain%(cx1%,cy1%)<>0 then exit_sub  : ' on veut tirer vers un espace occupé ?
  ' chercher si le décalage est possible
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  if cx1%<>cx%        : ' décaler horizontalement ?
    if cx1%>cx%        : ' décaler à droite ?
      if x%<4
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%+nh%,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          item_add 2,str$(p%)+"D"
          deplacer_droite(p%)
        end_if
      end_if
    else              : ' décaler à gauche !
      if x%>1
        cnt% = 0
        for i%=0 to nv%-1
          if terrain%(x%-1,y%+i%)=0 then cnt% = cnt% + 1
        next i%
        if cnt%=nv%
          item_add 2,str$(p%)+"G"
          deplacer_gauche(p%)
        end_if
      end_if
    end_if
  else                : ' pas de décalage horizontal !
    if cy1%<>cy%      : ' décaler verticalement ?
      if cy1%>cy%      : ' décaler en bas ?
        if y%<5
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%+nv%)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            item_add 2,str$(p%)+"B"
            deplacer_bas(p%)
          end_if
        end_if
      else            : ' décaler en haut !
        if y%>1
          cnt% = 0
          for i%=0 to nh%-1
            if terrain%(x%+i%,y%-1)=0 then cnt% = cnt% + 1
          next i%
          if cnt%=nh%
            item_add 2,str$(p%)+"H"
            deplacer_haut(p%)
          end_if
        end_if
      end_if
    end_if
  end_if
  if terrain%(4,4)=0
    cnt% = 0
    for i%=1 to 4
      for j%=1 to 4
        cnt% = cnt% + 1
        if cnt%<16
          if terrain%(i%,j%)<>cnt% then exit_sub
        end_if
      next j%
    next i%
    message "BRAVO ! C'est gagné !"
  end_if
end_sub

sub deplacer_gauche(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%-1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%+nh%-1,y%+i%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,2) = pieces%(p%,2) - 1
  dessiner_piece(p%)
end_sub

sub deplacer_haut(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=0 to nv%-1
      terrain%(x%+i%,y%+j%-1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%+nv%-1) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,3) = pieces%(p%,3) - 1
  dessiner_piece(p%)
end_sub

sub deplacer_droite(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=nh%-1 to 0 step -1
    for j%=0 to nv%-1
      terrain%(x%+i%+1,y%+j%) = p%
    next j%
  next i%
  for i%=0 to nv%-1
    terrain%(x%,y%+i%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,2) = pieces%(p%,2) + 1
  dessiner_piece(p%)
end_sub

sub deplacer_bas(p%)
  dim_local x%, y%, cx%, cy%, nh%, nv%, i%, j%
  x% = pieces%(p%,2)
  y% = pieces%(p%,3)
  nh% = pieces%(p%,4)
  nv% = pieces%(p%,5)
  for i%=0 to nh%-1
    for j%=nv%-1 to 0 step -1
      terrain%(x%+i%,y%+j%+1) = p%
    next j%
  next i%
  for i%=0 to nh%-1
    terrain%(x%+i%,y%) = 0
  next i%
  effacer_piece(p%)
  pieces%(p%,3) = pieces%(p%,3) + 1
  dessiner_piece(p%)
end_sub

sub effacer_piece(p%)
  dim_local tx%, ty%
  tx% = bord%+(pieces%(p%,2)-1)*unite%
  ty% = bord%+(pieces%(p%,3)-1)*unite%
  2d_fill_color 102,0,0
  2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
end_sub

sub dessiner_piece(p%)
  dim_local tx%, ty%
  tx% = bord%+(pieces%(p%,2)-1)*unite%
  ty% = bord%+(pieces%(p%,3)-1)*unite%
  2d_fill_color pieces%(p%,6), pieces%(p%,7), pieces%(p%,8)
  2d_rectangle tx%,ty%,tx%+pieces%(p%,4)*unite%,ty%+pieces%(p%,5)*unite%
  tx% = tx% + int((pieces%(p%,4)*unite%)/2)
  ty% = ty% + int((pieces%(p%,5)*unite%)/2)
  2d_circle tx%,ty%,int(unite%/5)
  if len(str$(p%)) = 1
    print_locate tx%-4,ty%-6
  else
    print_locate tx%-8,ty%-6
  end_if
  print p%
end_sub

sub defaire()
  dim_local s$, p%, d$, d%
  s$ = item_read$(2,count(2))
  item_delete 2,count(2)
  d$ = right$(s$,1)
  p% = val(left$(s$,len(s$)-1))
  d% = instr("GHDB",d$)
  select d%
    case 1: ' gauche
      deplacer_droite(p%)
    case 2: ' haut
      deplacer_bas(p%)
    case 3: ' droite
      deplacer_gauche(p%)
    case 4: ' bas
      deplacer_haut(p%)
  end_select
end_sub
Revenir en haut Aller en bas
Contenu sponsorisé





Le jeu de Taquin Empty
MessageSujet: Re: Le jeu de Taquin   Le jeu de Taquin Empty

Revenir en haut Aller en bas
 
Le jeu de Taquin
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» Taquin III
» Taquin II Le Retour
» Panoramic Android : jeu de Taquin
» Taquin Pousse Pousse

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
FORUM DE DISCUSSION SUR LE LANGAGE PANORAMIC :: PANORAMIC :: Les jeux faits avec Panoramic-
Sauter vers: