Discussion forum about PANORAMIC language

Mac, Windows & Android application development with PANORAMIC language
 
HomeFAQSearchRegisterMemberlistUsergroupsLog in
Latest topics
» Hello world.
by Mon Jun 19, 2017 1:37 am

» Biomorphes de PICKOVER
by Sun Jun 18, 2017 2:33 am

» In less than 10 lines of code
by Fri Jun 16, 2017 5:03 am

» Effect Dopler
by Fri Jun 16, 2017 3:29 am

» SuperEllipse
by Wed Jun 14, 2017 4:01 am

» Plants
by Wed Jun 14, 2017 3:38 am

» Mira's attractor
by Wed Jun 14, 2017 3:30 am

» Triangle of Sierpinski
by Wed Jun 14, 2017 3:22 am

» Esthétique polaire
by Wed Jun 14, 2017 3:16 am

» Butterfly effect : Lorenz equations
by Wed Jun 14, 2017 3:08 am

» Collision detection
by Tue Jun 13, 2017 5:09 am

» The Bees Laline Paull Epub Books
by Mon Oct 10, 2016 8:58 pm

» PANORAMIC for Mac OSX 10 is available
by Tue Aug 09, 2016 6:08 pm

» ide
by Sat Jul 16, 2016 12:27 am

» Can I change the program icon/logo in my application ?
by Thu Jul 07, 2016 3:32 am

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Share | 
 

 The tower of Hanoï

View previous topic View next topic Go down 
AuthorMessage
bignono

avatar

Number of posts : 11
Age : 60
Localisation : Champigny-sur-Marne, 94500, France
Registration date : 2013-03-12

PostSubject: The tower of Hanoï   Tue Mar 12, 2013 9:53 pm

Hello, Smile
I am usually on the French forum. There is little world on your forum.
I hope like Jicehel to attract new people! Here a small code which I carried out
in June 2012: The tower of Hanoï. I hope that it will be useful for you.
Excuse my English, I am French and I make use of a translator to write this
message. So long and good programming! Wink Wink Wink
Code:
' TOUR DE HANOÏ en 3D fait en Panoramic par Jean-Louis NAUDIN du 08 Juin 2012: Version 2.00
dim i,j,k,h,hy,ma,r,v,b,md,mvt,pas,n,td1,td3,d(3,13),a$,nv$
label mat,dplc,mntr,blq,dblq,niveau,mvmnt,init
width 0,800:left 0,(screen_x-width(0))/2:scene3d 1:full_space 1:color 1,180,180,235
3d_text 1,"TOUR DE HANOÏ":3d_position 1,-7,10,-15:3d_scale 1,2,2,2:3d_color 1,0,60,0
3d_text 2,"MOUVEMENT IMPOSSIBLE":3d_hide 2:3d_position 2,-8.2,8,-15:3d_scale 2,1.5,1.5,1.5:3d_color 2,190,60,0
3d_text 3,"":3d_position 3,-8.2,8,-15:3d_scale 3,1.5,1.5,1.5:3d_color 3,190,60,0
light_x_position 60  : light_y_position -10  : light_z_position -60
restore:j=-2.5:for i=4 to 13:3d_torus i,2,1.5:3d_position i,-13,j,-20:3d_x_rotate i,90:3d_scale i,(1+((i-13)/15))*2,1,0.25::read r:read v:read b:3d_color i,r,v,b:j=j-0.75:next i: ' Les 10 disques
data 0,50,0,30,100,0,140,140,0,80,65,10,105,70,0,125,40,0,155,40,25,165,115,80,130,150,95,180,215,95
j=150:for i=14 to 16:button i:left i,j:top i,410:font_bold i:caption i,"Départ":j=j+200:on_click i,mat:next i: ' Les 3 boutons Arrivée/Départ
for i=17 to 24:button i:hide i:width i,85:left i,((i-16)*95)-80:top i,50:font_name i,"Arial Narrow"
font_bold i:font_size i,9:read nv$:caption i,nv$:on_click i,niveau:next i:' Les 8 boutons niveaux et en data le nom du niveau
data "TROP FACILE","FACILE","MOINS FACILE","NORMAL","DIFFICILE","TRES DIFFICILE","TRUC DE OUF!","SUICIDAIRE"
3d_box 25,40,1,5:3d_position 25,0,-10.75,-20:3d_color 25,125,80,80: ' Le socle
3d_cylinder 26,10,0.5,0.5:3d_position 26,-13,-5,-20:3d_cylinder 27,10,0.5,0.5:3d_position 27,0,-5,-20:3d_cylinder 28,10,0.5,0.5:3d_position 28,13,-5,-20:' Les 3 piquets
memo 29:width 29,782:height 29,86:top 29,75:font_bold 29:font_size 29,12
item_add 29,"But du jeu: Il faut déplacer tous les disques du mât gauche vers le mât droit en vous aidant du "
item_add 29,"mât central en un minimum de mouvements, sachant qu'on ne peut manipuler qu'un seul disque "
item_add 29,"à la fois et qu'on ne peut le poser que sur un plus grand que lui ou sur un mât vide."
inactive 29:gosub init
end
init:
for i=4 to 13:3d_x_position i,-13:next i:for i=4 to 13:d(1,i)=i:d(2,i)=0:d(3,i)=0:3d_hide i:next i: ' Initialisation
3d_hide 3:mvt=0:gosub mvmnt:for j=17 to 24:show j:next j
return
mat:
if (number_click=14 and caption$(14)="Départ")
  if d(1,13)=0 then return
  caption 15,"Arrivée":caption 16,"Arrivée":gosub blq:md=1:gosub mntr:gosub dblq
end_if
if (number_click=14 and caption$(14)="Arrivée")
  caption 14,"Départ":caption 15,"Départ":caption 16,"Départ":gosub blq:ma=1:gosub dplc:gosub dblq
end_if
if (number_click=15 and caption$(15)="Départ")
  if d(2,13)=0 then return
  caption 14,"Arrivée":caption 16,"Arrivée":gosub blq:md=2:gosub mntr:gosub dblq
end_if
if (number_click=15 and caption$(15)="Arrivée")
  caption 14,"Départ":caption 15,"Départ":caption 16,"Départ":gosub blq:ma=2:gosub dplc:gosub dblq
end_if
if (number_click=16 and caption$(16)="Départ")
  if d(3,13)=0 then return
  caption 14,"Arrivée":caption 15,"Arrivée":gosub blq:md=3:gosub mntr:gosub dblq
end_if
if (number_click=16 and caption$(16)="Arrivée")
  caption 14,"Départ":caption 15,"Départ":caption 16,"Départ":gosub blq:ma=3:gosub dplc:gosub dblq
end_if
return
dplc:
  for j=13 to n step -1:if d(ma,j)=0 then exit_for
  next j
  if j<13
      if d(ma,j+1)<d(md,i)
      beep:3d_hide 3:3d_show 2:wait 900
        for k=2 to h step -0.5:3d_y_position d(md,i),k:wait 15:next k:3d_hide 2:3d_show 3:return
      end_if
  end_if
  if (md=1 and ma=2) then hy=o3d_x_position(d(md,i))+13:pas=0.5
  if (md=1 and ma=3) then hy=o3d_x_position(d(md,i))+26:pas=0.5
  if (md=2 and ma=3) then hy=o3d_x_position(d(md,i))+13:pas=0.5
  if (md=2 and ma=1) then hy=o3d_x_position(d(md,i))-13:pas=-0.5
  if (md=3 and ma=1) then hy=o3d_x_position(d(md,i))-26:pas=-0.5
  if (md=3 and ma=2) then hy=o3d_x_position(d(md,i))-13:pas=-0.5
  for k=o3d_x_position(d(md,i)) to hy step pas:3d_x_position (d(md,i)),k:wait 15:next k:for k=o3d_y_position(d(md,i)) to -0.75*j step abs(pas)*-1:3d_y_position (d(md,i)),k:wait 15:next k
  d(ma,j)=d(md,i):d(md,i)=0:mvt=mvt+1:gosub mvmnt:td3=0:for i=n to 13:td3=td3+d(3,i):next i
  if td3=td1
      if mvt=power(2,(14-n))-1
        message "BRAVO! VOUS ETES UN CHAMPION!"
      else
        message "Vous avez réussi, mais hélas vous avez fait "+str$(mvt-(power(2,(14-n))-1))+" mouvements en trop"
      end_if
      if message_confirmation_yes_no("Voulez-vous rejouer?")=1
        gosub init
      else
        terminate
      end_if
  end_if
return
mntr:
  for i=n to 13:if d(md,i)>0 then exit_for
  next i:h=o3d_y_position(d(md,i)):for j=h to 2 step 0.5:3d_y_position d(md,i),j:wait 15:next j
return
mvmnt:
a$="Nombre de mouvements:"+str$(mvt):3d_text_change 3,a$
return
niveau:
n=number_click-((number_click-14)*2):td1=0:message "Ce niveau est réalisable en "+str$(power(2,(14-n))-1)+" mouvements. Bonne chance!"
for i=n to 13:td1=td1+d(1,i):3d_show i:next i:for j=17 to 24:hide j:next j:3d_show 3:return
blq:
inactive 14:inactive 15:inactive 16:return
dblq:
active 14:active 15:active 16:return
Back to top Go down
View user profile
 
The tower of Hanoï
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Eiffel Tower Restaurant Trivia Contest
» Review: Pandora's Tower (Wii Retail)
» Nintendo Is Looking To Sign TowerFall Creator As An Official Wii U And 3DS Developer!
» Matsumoto Jun's CM/Shows/Videos
» LEFT WING ART CRITIC SNEERS AT TOWER OF LONDON POPPY TRIBUTE

Permissions in this forum:You cannot reply to topics in this forum
Discussion forum about PANORAMIC language :: Panoramic for Windows :: Source code (snippets)-
Jump to: