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
» 2D_fill_color
Le jeu de l'Ane Rouge Emptypar Marc Hier à 14:25

» Consommation gaz électricité
Le jeu de l'Ane Rouge Emptypar leclode Mer 17 Avr 2024 - 11:07

» trop de fichiers en cours
Le jeu de l'Ane Rouge Emptypar lepetitmarocain Mer 17 Avr 2024 - 10:19

» on_key_down (résolu)
Le jeu de l'Ane Rouge Emptypar leclode Mar 16 Avr 2024 - 11:01

» Sous-programme(résolu)
Le jeu de l'Ane Rouge Emptypar jjn4 Jeu 4 Avr 2024 - 14:42

» Bataille-navale
Le jeu de l'Ane Rouge Emptypar jjn4 Mer 3 Avr 2024 - 14:08

» Minimiser une fenêtre Panoramic.
Le jeu de l'Ane Rouge Emptypar Pedro Mar 2 Avr 2024 - 13:50

» Récapitulatif ludothèque panoramic jjn4
Le jeu de l'Ane Rouge Emptypar jjn4 Lun 1 Avr 2024 - 18:04

» demande explication KGF pour imprimer en mm
Le jeu de l'Ane Rouge Emptypar JL35 Jeu 28 Mar 2024 - 17:28

» Petit passage furtif
Le jeu de l'Ane Rouge Emptypar Froggy One Mer 27 Mar 2024 - 14:26

» SPIN et aide langage (résolu)
Le jeu de l'Ane Rouge Emptypar leclode Sam 23 Mar 2024 - 15:20

» Aide-mémoire des mots-clés Panoramic
Le jeu de l'Ane Rouge Emptypar papydall Mer 20 Mar 2024 - 21:23

» Je ne comprend pas pourquoi la largeur de la scene 3d change
Le jeu de l'Ane Rouge Emptypar Marc Mar 12 Mar 2024 - 20:06

» Comment télécharger panoramic?
Le jeu de l'Ane Rouge Emptypar lepetitmarocain Sam 9 Mar 2024 - 13:31

» @lepetitmarocain <==> KGFGrid
Le jeu de l'Ane Rouge Emptypar Klaus Dim 3 Mar 2024 - 9:59

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Avril 2024
LunMarMerJeuVenSamDim
1234567
891011121314
15161718192021
22232425262728
2930     
CalendrierCalendrier
Le Deal du moment :
Display One Piece Card Game Japon OP-08 – Two ...
Voir le deal

 

 Le jeu de l'Ane Rouge

Aller en bas 
5 participants
AuteurMessage
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 2:41

L’âne est enfin Liiiiiibre !!!
Ça sera presque parfait sans ce clignotement désagréable !


Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem ============================================================================

label click

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

dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 400
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,20 : left 200,530 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,20 : left 300,620 : font_bold 300 : caption 300,"Quit"
on_click 100,click : on_click 200,click : on_click 300,click
alpha 400  : top 400,25 : left 400,720 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
  end_select
  deplacer_piece()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
sub dessiner_terrain()
  dim_local p%, tx%, ty%
  color 1,102,0,0
  for p%=1 to 10
    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)
    if p%=1
      2d_circle tx%,ty%,int(unite%/2.5)
      print_locate tx%-28,ty%-5
      print "Ane rouge"
    else
      2d_circle tx%,ty%,int(unite%/5)
      print_locate tx%-5,ty%-5
      print p%
    end_if
  next p%
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : ' pause 1000
    restore : read coup$
    while coup$ <> "fin"
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while

    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 9:03

Voici une version sans ce clignotement désagréable:
Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem ============================================================================

label click

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

dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 400
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,20 : left 200,530 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,20 : left 300,620 : font_bold 300 : caption 300,"Quit"
on_click 100,click : on_click 200,click : on_click 300,click
alpha 400  : top 400,25 : left 400,720 : font_bold 400 : font_color 400, 255,0,0

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

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
  end_select
  deplacer_piece()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : ' pause 1000
    restore : read coup$
    while coup$ <> "fin"
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while

    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================

Bravo pour l'Autorun - c'est vraiment spectaculaire.

Ceci dit, tu as mis une des solutions possibles - c'est bien. Mais regarde tes MP - je t'ai envoyé ce qu'il faut pour avoir la solution "optimale" en 81 coups...


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

Jean Claude


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 9:15

Bravo !
Un jolie jeu, pas facile, mais intéressant.
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 l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 9:50

Oui, merci, un bon case-tête bien costaud ...
Revenir en haut Aller en bas
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 13:18

Je propose une nouvelle version de ce jeu, avec la possibilité d'annuler le ou les derniers mouvements, jusqu'au retour à la position initiale. Pour cela, j'ai ajouté un bouton "Annuler":
Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem ============================================================================

label click, annul

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

dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 400
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,20 : left 200,530 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,20 : left 300,620 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,20 : left 350,710 : font_bold 350 : caption 350,"Annuler"
on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul
alpha 400  : top 400,25 : left 400,720 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : ' pause 1000
    restore : read coup$
    while coup$ <> "fin"
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while

    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 13:25

Ça devient de plus en plus pro.
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Jean Claude

Jean Claude


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 13:34

Ce bouton "annuler" est le bienvenu, çà permet d'être plus rapide.


J'ai fait deux petites modifications:

1) j'ai désactivé le bouton autorun pendant l'autorun pour éviter une erreur.
2) j'ai modifier la couleur des N° des cases, car le blanc sur fond jaune c'est pratiquement illisible (Pour moi, en tout cas)

Code:
rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem ============================================================================

label click, annul

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

dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 400
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,20 : left 200,530 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,20 : left 300,620 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,20 : left 350,710 : font_bold 350 : caption 350,"Annuler"
on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul
alpha 400  : top 400,25 : left 400,720 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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,105,105
            font_bold 1

dlist 2  : ' pour "défaire" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5)
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : inactive 200 : ' pause 1000
    restore : read coup$
    while coup$ <> "fin"
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while
    active 200
    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"

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 l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 14:32

Perso, j'avais du mal à lire sur le bleu foncé, j'ai donc éclairci ce bleu comme les autres couleurs sont assez clair et j'ai foncé la couleur des caractères.

J'ai fais une petite modif aussi pour le 10 qui était mal centré. Ca donne:
Code:
rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem ============================================================================

label click, annul

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

dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge ;      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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 400 : height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2        : top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,20 : left 200,530 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,20 : left 300,620 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,20 : left 350,710 : font_bold 350 : caption 350,"Annuler"
on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul
alpha 400  : top 400,25 : left 400,720 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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,45,25,25
            font_bold 1

dlist 2  : ' pour "défaire" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,90,90,254)
  creer_piece( 3,4,1,1,2,90,90,254)
  creer_piece( 4,1,3,1,2,90,90,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,90,90,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
sub creer_piece(n%,x%,y%,nh%,nv%,R%,G%,B%)
  dim_local i%, j%, tx%, ty% , l%
  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)
  if n%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    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_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5)
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    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_if
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : inactive 200 : ' pause 1000
    restore : read coup$
    while coup$ <> "fin"
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while
    active 200
    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"

Dites moi si vous préférez ces couleurs ?

Edit - J'ai corrigé un petit oubli
Revenir en haut Aller en bas
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 15:53

Bien, je m'amuse.

Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem      Avec la participation de Jean Claude, de Jicehel, et qui encore ?
rem ============================================================================

label click, annul

dim unite% : unite% = 100
dim bord%  : bord%  = 10
dim stoppp
dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 100
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,50 : left 200,430 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,80 : left 300,430 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,110 : left 350,430 : font_bold 350 : caption 350,"Annuler"
button 360 : top 360,140 : left 360,430 : font_bold 360 : caption 360,"Stop"

inactive 360 : on_click 360,click

on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul

alpha 400  : top 400,250 : left 400,430 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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,105,105
            font_bold 1

dlist 2  : ' pour "défaire" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
    case 360 : stop()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2 : active 350
  stoppp = 0
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1

    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-5,ty%-5
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : inactive 200 : active 360 : inactive 350
    restore : read coup$
    while coup$ <> "fin"  and stoppp = 0
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while
    active 200
    if clicked(360) > 0 then stop() : exit_sub
    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
rem ============================================================================
SUB Stop()
    while scancode = 1
       inactive 360 : active 100 : stoppp = 1
       pause 10
    end_while

END_SUB
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:01

La présentation est plus concise,et c'est mieux ainsi. Faudrait trouver une couleur claire sympa, pour mettre dans les ronds...

Le bouton Stop est parfait pour stopper l'Aurorun.
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:05

Un autre bouton Reprendre sera tout aussi utile.
Qui veut s'en occuper ?
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Jicehel

Jicehel


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:06

Bouh, tu n'as pas gardé mon centrage pour le 10 Sad C'est mieux pourtant au niveau visuel, je trouve.
Tu peux même éviter le if en faisant un -4*len(str$(variable)) directement dans les 2 formules
Revenir en haut Aller en bas
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:09

J'ai modifié la procédure defaire() pour qu'elle décompte les coups en cas d'annulation:
Code:
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
  n = n - 1 : caption 400,"N = " + str$(n)
end_sub
Qu'est-ce que tu en penses ?
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:28

Bon, pour faire plaisir à Jicehel, j'incorpore le centrage du 10 et j'en profite pour corriger une petite chose pour le confort.
J'adopte aussi la modification de la procédure defaire() de Klaus

Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem      Avec la participation de Jean Claude, de Jicehel, et qui encore ?
rem ============================================================================

label click, annul

dim unite% : unite% = 100
dim bord%  : bord%  = 10
dim stoppp
dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 100
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,50 : left 200,430 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,80 : left 300,430 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,110 : left 350,430 : font_bold 350 : caption 350,"Annuler"
button 360 : top 360,140 : left 360,430 : font_bold 360 : caption 360,"Stop"

inactive 360 : on_click 360,click

on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul

alpha 400  : top 400,250 : left 400,430 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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,105,105
            font_bold 1

dlist 2  : ' pour "défaire" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun() : return
    case 300 : Quitter()
    case 360 : stop()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2 : active 350
  stoppp = 0
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1

    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    if len(str$(n%)) = 1
      print_locate tx%-4,ty%-6
    else
      print_locate tx%-8,ty%-6
    end_if
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun()
    dim_local coup$,num,dir$ ,t$
    initialiser() : inactive 100 : inactive 200 : active 360 : inactive 350
    pause 1000 : restore : read coup$
    while coup$ <> "fin"  and stoppp = 0
          if len(coup$) = 2
              num = val(left$(coup$,1))
          else
              num = val(left$(coup$,2))
          end_if

          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
          pause 1000 : ' à adapter
          read coup$
    end_while
    active 200
    if clicked(360) > 0 then stop() : exit_sub
    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
  n = n - 1 : caption 400,"N = " + str$(n)
end_sub

rem ============================================================================
SUB Stop()
    while scancode = 1
      inactive 360 : active 100 : stoppp = 1
      pause 10
    end_while

END_SUB
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:30

Aïe.... j'allais poster une version avec le bouton "Reprise" de l'Autorun, mais je vois une nouvelle version. Je n'ai plus qu'à recommencer...
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:38

En réalité, j’ai numéroté les pièces, pour l’unique raison de me connaître lors du codage des lignes DATA, pour savoir quelle pièce doit se déplacer.
J’ai laissé ces numéros sur les pièces (par oubli !), mais il parait que vous avez apprécié ;  alors autant les laisser.

Je viens de réaliser que je n’ai pas mangé depuis le matin.
Je cours faire le plein !
A+
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 16:50

Voilà le bouton "Reprise" de l'Autorun. j'ai dû inverser la logique de la boucle du Autorun pour passer d'un while/end_while à un repeat/until.
Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem      Avec la participation de Jean Claude, de Jicehel, et qui encore ?
rem ============================================================================

label click, annul

dim unite% : unite% = 100
dim bord%  : bord%  = 10
dim stoppp
dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 100
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20 : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,50 : left 200,430 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,80 : left 300,430 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,110 : left 350,430 : font_bold 350 : caption 350,"Annuler"
button 360 : top 360,140 : left 360,430 : font_bold 360 : caption 360,"Stop"
button 370 : top 370,170 : left 370,430 : font_bold 370 : caption 370,"Reprise"

inactive 360 : on_click 360,click
inactive 370 : on_click 370,click

on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul

alpha 400  : top 400,250 : left 400,430 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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,105,105
            font_bold 1

dlist 2  : ' pour "défaire" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun(1) : return
    case 300 : Quitter()
    case 360 : stop()
    case 370 : reprise()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2 : active 350
  stoppp = 0
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1

    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    if len(str$(n%)) = 1
      print_locate tx%-4,ty%-6
    else
      print_locate tx%-8,ty%-6
    end_if
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun(x%)
    dim_local coup$,num,dir$ ,t$
    if x%=1 then initialiser() :  restore
    inactive 100 : inactive 200 : active 360 : inactive 350 : inactive 370
    repeat
          pause 1000 : ' à adapter
          read coup$
          if coup$="fini" then exit_repeat
          num = val(left$(coup$,len(coup$)-1))
          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)  : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
    until coup$ = "fin"  or stoppp <> 0
    active 200
    if stoppp>0
          active 370
          exit_sub
    end_if
    if clicked(360) > 0 then stop() : exit_sub
    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
  n = n - 1 : caption 400,"N = " + str$(n)
end_sub

rem ============================================================================
SUB Stop()
    stoppp = 1
    inactive 360
    active 100
END_SUB
rem ============================================================================
rem ============================================================================
SUB Reprise()
    stoppp = 0
    Autorun(0)
END_SUB
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================


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

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 18:08

Quand on demande un stop puis Autorun, ça va vite et on ne voit pas le 1er coup.
Ajouter dans SUB Autorun(x%) au début (et au plus tard avant REPEAT)
Code:
Pause 1000

Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 18:18

J'ai décalé le "pause 1000" de la fin de la boucle vers le début de la boucle, et ça fait l'affaire.
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 18:26

Oui,ça marche aussi.

Les 2 lignes de test if x% = 1 …
En une seule
Code:
 if x%=1 then restore : initialiser()
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Klaus

Klaus


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptyDim 22 Fév 2015 - 18:34

Exact. C'est fait...
Revenir en haut Aller en bas
http://klauspanoramic.comxa.com/index.html
papydall

papydall


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptySam 23 Mai 2015 - 13:51

Correction d’un "minibug".
Toute ressemblance avec un autre Minibug est purement fortuite !

Code:

rem ============================================================================
rem              Jeu : Ane Rouge
rem            Par Klaus et Papydall
rem      Avec la participation de Jean Claude, de Jicehel, et qui encore ?
rem ============================================================================

label click, annul

dim unite% : unite% = 100
dim bord%  : bord%  = 10
dim stoppp
dim pieces%(10,8),n
  ' (n%,d%)  n%=1 carré rouge
  '          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,5) : ' 5 lignes de 4 colonnes

width  0,4*unite%+2*bord% + 16  + 100
height 0,5*unite%+2*bord% + 39
left  0,(screen_x-width(0))/2
top 0,(screen_y-height(0))/2
caption 0,"Le jeu de l'âne rouge"
button 100 : top 100,20  : left 100,430 : font_bold 100 : caption 100,"Init"
button 200 : top 200,50  : left 200,430 : font_bold 200 : caption 200,"Autorun"
button 300 : top 300,80  : left 300,430 : font_bold 300 : caption 300,"Quit"
button 350 : top 350,110 : left 350,430 : font_bold 350 : caption 350,"Annuler"
button 360 : top 360,140 : left 360,430 : font_bold 360 : caption 360,"Stop"
button 370 : top 370,170 : left 370,430 : font_bold 370 : caption 370,"Reprise"

inactive 360 : on_click 360,click
inactive 370 : on_click 370,click

on_click 100,click : on_click 200,click : on_click 300,click : on_click 350,annul

alpha 400  : top 400,250 : left 400,430 : font_bold 400 : font_color 400, 255,0,0

picture 1 : width 1,4*unite%+2*bord% : height 1,5*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,105,105
            font_bold 1

dlist 2  : ' pour "défaire" par "espace"

initialiser()
end
rem ============================================================================

click:
  select number_click
    case 100 : initialiser()
    case 200 : Autorun(1) : return
    case 300 : Quitter()
    case 360 : stop()
    case 370 : reprise()
  end_select
  deplacer_piece()
  return
rem ============================================================================
annul:
  if count(2)>0 then defaire()
  return
rem ============================================================================
sub initialiser()

  dim_local i%, j%
  clear 2 : active 350
  stoppp = 0
  cls : n = 0 : caption 400,"N = " + str$(n)
  for i%=1 to 4
    for j%=1 to 5
      terrain%(i%,j%) = 0
    next j%
  next i%
  color 1,102,0,0
  creer_piece( 1,2,1,2,2,254,0,0)
  creer_piece( 2,1,1,1,2,0,0,254)
  creer_piece( 3,4,1,1,2,0,0,254)
  creer_piece( 4,1,3,1,2,0,0,254)
  creer_piece( 5,2,3,2,1,0,254,0)
  creer_piece( 6,4,3,1,2,0,0,254)
  creer_piece( 7,2,4,1,1,254,204,0)
  creer_piece( 8,3,4,1,1,254,204,0)
  creer_piece( 9,1,5,1,1,254,204,0)
  creer_piece(10,4,5,1,1,254,204,0)
end_sub
rem ============================================================================
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)
  if n%=1

    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    if len(str$(n%)) = 1
      print_locate tx%-4,ty%-6
    else
      print_locate tx%-8,ty%-6
    end_if
    print n%
  end_if
end_sub
rem ============================================================================
sub deplacer_piece()
  dim_local x%, y%, x1%, y1%, cx%, cy%, cx1%, cy1%, p%, nh%, nv%, i%, cnt%
  x% = mouse_x_left_down(1)
  y% = mouse_y_left_down(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
  n = n + 1 : caption 400,"N = " + str$(n)
  if p%=1
    if (pieces%(p%,2)=2)
      if (pieces%(p%,3)=4)
        message "BRAVO ! C'est gagné !"
      end_if
    end_if
  end_if
end_sub
rem ============================================================================

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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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
rem ============================================================================
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)
  if p%=1
    2d_circle tx%,ty%,int(unite%/2.5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-28,ty%-5
    print "Ane rouge"
  else
    2d_circle tx%,ty%,int(unite%/5) : 2d_flood tx%,ty%,255,255,255
    print_locate tx%-5,ty%-5
    print p%
  end_if
end_sub
rem ============================================================================
SUB Autorun(x%)
    dim_local coup$,num,dir$ ,t$
    if x%=1 then initialiser() :  restore
    inactive 100 : inactive 200 : active 360 : inactive 350 : inactive 370
    repeat
          pause 1000 : ' à adapter
          read coup$
          if coup$ = "fin" then exit_repeat
          num = val(left$(coup$,len(coup$)-1))
          dir$ = upper$(right$(coup$,1))
          select asc(dir$)
              case 72 : deplacer_haut(num)   : ' vers le haut
              case 66 : deplacer_bas(num)    : ' vers le bas
              case 71 : deplacer_gauche(num) : ' vers la gauche
              case 68 : deplacer_droite(num) : ' vert la droite
          end_select
          n = n + 1 : caption 400,"N = " + str$(n)
    until coup$ = "fin"  or stoppp <> 0
    active 200
    if stoppp>0
          active 370
          exit_sub
    end_if
    if clicked(360) > 0 then stop() : exit_sub
    t$ = "je te salue, ô Liberté" + chr$(13)+chr$(13)
    t$ = t$ + " Je suis libre !" + chr$(13)
    t$ = t$ + "I am free !" + chr$(13)
    t$ = t$ + "Ich bin frei ! " + chr$(13)
    t$ = t$ + "Sono libero !" + chr$(13)
    message t$
    active 100
END_SUB
rem ============================================================================
SUB Quitter()
    if message_confirmation_yes_no("Vous voulez vraiment quitter ?") = 1
      terminate
    end_if
END_SUB
rem ============================================================================
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
  n = n - 1 : caption 400,"N = " + str$(n)
end_sub

rem ============================================================================
SUB Stop()
    stoppp = 1
    inactive 360
    active 100
END_SUB
rem ============================================================================
rem ============================================================================
SUB Reprise()
    stoppp = 0
    Autorun(0)
END_SUB
rem ============================================================================
data "9d" , "4b" , "5g" , "8b" , "6g" , "10h" , "8d" , "6b" , "5d" , "5d"
data "7h" , "7g" , "9h" , "9h" , "6g" , "10g" , "10b", "5b" , "9d" , "9d"
data "7d" , "7d" , "4h" , "6h" , "10g", "10g" , "8g" , "8g" , "5b" , "7b"
data "7d" , "6d" , "8h" , "8h" , "10d", "10h" , "5g" , "5g" , "7b" , "9b"
data "7g" , "9b" , "6d" , "8d" , "10d", "4d"  , "2b" , "2b" , "1g" , "8h"
data "8h" , "10h", "10h", "7h" , "7h" , "9g"  , "9h" , "5d" , "5d" , "2b"
data "4b" , "1b" , "8g" , "8g" , "10h", "10g" , "7h" , "7h" , "1d" , "2h"
data "2h" , "4g" , "9g" , "9b" , "1b" , "7b"  , "7g" , "3g" , "6h" , "6h"
data "1d" , "7b" , "7b" , "10b", "8d" , "2h"  , "4h" , "9g" , "7b" , "1g"
data "6b" , "6b" , "3d" , "8d" , "10d", "2d"  , "4h" , "4h" , "1g" , "10b"
data "10b", "8b" , "8b" , "3g" , "6h" , "6h"  , "8d" , "10h", "5h" , "7d"
data "7d" , "9d" , "9d" , "1b" , "10g", "10g" , "8g" , "8g" , "5h" , "9h"
data "9d" , "1d"

data "fin"
rem ============================================================================
Revenir en haut Aller en bas
http://papydall-panoramic.forumarabia.com/
Jicehel

Jicehel


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

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptySam 23 Mai 2015 - 14:30

tu peux mettre avec une participation collégiale du forum panoramic pour n'oublier personne Wink
Revenir en haut Aller en bas
Minibug

Minibug


Nombre de messages : 4566
Age : 57
Localisation : Vienne (86)
Date d'inscription : 09/02/2012

Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge EmptySam 23 Mai 2015 - 16:30

@papydall :

LOL !! il y un minibug dans le jeu de l’âne ? ! Et j'étais même pas au courant ! drunken

Je me demande ce que je faisais là ? LOL Very Happy Wink
Revenir en haut Aller en bas
http://gpp.panoramic.free.fr
Contenu sponsorisé





Le jeu de l'Ane Rouge Empty
MessageSujet: Re: Le jeu de l'Ane Rouge   Le jeu de l'Ane Rouge Empty

Revenir en haut Aller en bas
 
Le jeu de l'Ane Rouge
Revenir en haut 
Page 1 sur 1
 Sujets similaires
-
» mon fil rouge de l'ete
» Fermeture Form par la croix rouge
» Solution ultime pour bloquer la croix rouge !
» Appliquer un filtre (rouge, vert ou bleu) à une image bitmap

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: