home *** CD-ROM | disk | FTP | other *** search
/ Fun Online 1997 April / FOL0497.iso / win95 / tvml.z / grid.$$$ < prev    next >
Text File  |  1996-02-03  |  11KB  |  686 lines

  1.  
  2. sub read_sprite_tile_game()
  3.  
  4.  
  5.     spritebank 11
  6.     transparentcolour 0,89,155,78
  7.  
  8.     SPRITEFILE gif,server+country+`/`+current_n
  9.     DEFSPRITE 0, 41, 31,230,230    
  10.     DEFSPRITE 1, 271, 31,230,230    
  11.     DEFSPRITE 2, 501, 31,230,230    
  12.     DEFSPRITE 3, 731, 31,230,230    
  13.     DEFSPRITE 4, 41, 261,230,230    
  14.     DEFSPRITE 5, 271, 261,230,230    
  15.     DEFSPRITE 6, 501, 261,230,230    
  16.     DEFSPRITE 7, 731, 261,230,230    
  17.     DEFSPRITE 8, 41, 491,230,230    
  18.     DEFSPRITE 9, 271, 491,230,230    
  19.     DEFSPRITE 10, 501, 491,230,230    
  20.     DEFSPRITE 11, 731, 491,230,230    
  21.  
  22.     spritebank 10
  23.     SPRITEFILE gif,server_games+`mask.bmp`
  24.     DEFSPRITE 0, 0, 0,242,242    
  25.     spritebank 0
  26.  
  27.  
  28.  
  29. end sub
  30.  
  31. sub display_sprite_tile_game()
  32. local
  33.  
  34.     int row,col
  35.  
  36. end local
  37.  
  38.  
  39. //    activepage 1
  40. //    loadimage 1100,160,170,170,gif,server+country+`/`+current_n
  41. //    activepage 0
  42. //    clearscreen 1100,160,170,170,standard,1,255
  43.  
  44.     cut_sprite_tile_game=0
  45.     pencolour 0,0,0,0
  46.  
  47.     forc(row=166;row<892;row+=242)
  48.     {
  49.         forc(col=116;col<1084;col+=242)
  50.         {
  51.             pos_x_tile_game[cut_sprite_tile_game]=col
  52.             pos_y_tile_game[cut_sprite_tile_game]=row
  53.  
  54.             SPRITEb cut_sprite_tile_game+100,col-6,row-6,LOOPED,1,100,10,[0]
  55.             SpriteFlags2 cut_sprite_tile_game+100, enabled|visible, UNBOUND
  56.  
  57.             SPRITEb cut_sprite_tile_game,col,row,looped,1,100,11,[cut_sprite_tile_game]
  58.             SpriteFlags2 cut_sprite_tile_game, visible|enabled, UNBOUND
  59. //            SpriteFlags2 cut_sprite_tile_game, clickable|visible|enabled, UNBOUND
  60.  
  61.  
  62.             grid[cut_sprite_tile_game]=cut_sprite_tile_game
  63.             cut_sprite_tile_game++
  64.  
  65.         }
  66.     }
  67.  
  68.  
  69.     grid[0]=0
  70.     last_grid=0
  71.     movespriteto 0,5000,500
  72.     movespriteto 100,5000,5000
  73.  
  74.  
  75.  
  76. end sub
  77.  
  78. sub move_accross_left_tile_game(start_x as int,y_pos as int,sprite_no as int)
  79. local
  80.     int end_x
  81. end local
  82.  
  83.     end_x=start_x-242
  84.     ifc(random_is_on==0)
  85.         sound server_games+`move.wav wave`
  86.     forc(count_tile_game=start_x;count_tile_game>end_x;count_tile_game-=20)
  87.     {
  88.         movespriteto sprite_no+100,count_tile_game-6,y_pos-6
  89.         movespriteto sprite_no,count_tile_game,y_pos
  90.         wait tile_speed
  91.     }
  92.     movespriteto sprite_no,end_x,y_pos
  93.     movespriteto sprite_no+100,end_x-6,y_pos-6
  94.  
  95.     move=2
  96. end sub
  97.  
  98.  
  99. sub move_accross_right_tile_game(start_x as int ,y_pos as int ,sprite_no as int)
  100. local
  101.     int end_x
  102. end local
  103.  
  104.     end_x=start_x+242
  105.     ifc(random_is_on==0)
  106.         sound server_games+`move.wav wave`
  107.  
  108.     forc(count_tile_game=start_x;count_tile_game<end_x;count_tile_game+=20)
  109.     {
  110.         movespriteto sprite_no+100,count_tile_game-6,y_pos-6
  111.         movespriteto sprite_no,count_tile_game,y_pos
  112.         wait tile_speed
  113.     }
  114.     movespriteto sprite_no+100,end_x-6,y_pos-6
  115.     movespriteto sprite_no,end_x,y_pos
  116.     move=2
  117.  
  118. end sub
  119.  
  120.  
  121. sub move_up_tile_game(x_pos as int ,start_y as int ,sprite_no as int)
  122. local
  123.  
  124.     int end_y
  125. end local
  126.  
  127.     end_y=start_y-242
  128.     ifc(random_is_on==0)
  129.         sound server_games+`move.wav wave`
  130.     forc(count_tile_game=start_y;count_tile_game>end_y;count_tile_game-=20)
  131.     {
  132.         movespriteto sprite_no+100,x_pos-6,count_tile_game-6
  133.         movespriteto sprite_no,x_pos,count_tile_game
  134.         wait tile_speed
  135.     }
  136.     movespriteto sprite_no+100,x_pos-6,end_y-6
  137.     movespriteto sprite_no,x_pos,end_y
  138.     move=2
  139.  
  140. end sub
  141.  
  142.  
  143. sub move_down_tile_game(x_pos as int ,start_y as int ,sprite_no as int)
  144. local
  145.  
  146.     int end_y
  147. end local
  148.  
  149.     end_y=start_y+242
  150.     ifc(random_is_on==0)
  151.         sound server_games+`move.wav wave`
  152.     forc(count_tile_game=start_y;count_tile_game<end_y;count_tile_game+=24)
  153.     {
  154.         movespriteto sprite_no+100,x_pos-6,count_tile_game-6
  155.         movespriteto sprite_no,x_pos,count_tile_game
  156.         wait tile_speed
  157.     }
  158.     movespriteto sprite_no+100,x_pos-6,end_y-6
  159.     movespriteto sprite_no,x_pos,end_y
  160.  
  161.     move=2
  162.  
  163.  
  164. end sub
  165.  
  166. sub    check_last_tile_game(new_sel as int)
  167.  
  168.         ifc(per_last_grid=chosen)
  169.             chosen=new_sel
  170.  
  171.  
  172. end sub
  173.  
  174. sub random_move_tile_game()
  175. local
  176.  
  177.     int    use_sprite
  178.  
  179. end local
  180.  
  181.     random_is_on=1
  182.     gettime hr,m,s,c
  183.  
  184.     randomise(s)
  185.     ran_no=random()
  186.     per_last_grid=0
  187.     forc(total_moves=1;total_moves<random_moves;total_moves++)
  188.     {
  189.  
  190.         ifc(last_grid==0)
  191.         {
  192.             ran_no=random()
  193.             ifc(int(ran_no*10)>5)
  194.             {
  195.                 chosen=1
  196.                 check_last_tile_game(4)
  197.             }    
  198.             else
  199.             {
  200.                 chosen=4
  201.                 check_last_tile_game(1)
  202.             }
  203.  
  204.         }
  205.  
  206.  
  207.         ifc(last_grid==1)
  208.         {
  209.             ran_no=random()
  210.             ifc(int(ran_no*10)<3)
  211.             {
  212.                 chosen=0
  213.                 check_last_tile_game(5)
  214.             }    
  215.             else
  216.             {
  217.                 ifc(int(ran_no*10)<6)
  218.                 {
  219.                     chosen=5
  220.                     check_last_tile_game(2)
  221.                 }
  222.                 else
  223.                 {
  224.                     chosen=2
  225.                     check_last_tile_game(0)
  226.                 }
  227.             }
  228.  
  229.         }
  230.  
  231.         ifc(last_grid==2)
  232.         {
  233.             ran_no=random()
  234.             ifc(int(ran_no*10)<3)
  235.             {
  236.                 chosen=1
  237.                 check_last_tile_game(6)
  238.             }    
  239.             else
  240.             {
  241.                 ifc(int(ran_no*10)<6)
  242.                 {
  243.                     chosen=6
  244.                     check_last_tile_game(3)
  245.                 }
  246.                 else
  247.                 {
  248.                     chosen=3
  249.                     check_last_tile_game(1)
  250.                 }
  251.             }
  252.  
  253.         }
  254.  
  255.         ifc(last_grid==3)
  256.         {
  257.             ran_no=random()
  258.             ifc(int(ran_no*10)<5)
  259.             {
  260.                 chosen=2
  261.                 check_last_tile_game(7)
  262.             }    
  263.             else
  264.             {    
  265.                 chosen=7
  266.                 check_last_tile_game(2)
  267.             }
  268.  
  269.         }
  270.  
  271.  
  272.         ifc(last_grid==4)
  273.         {
  274.             ran_no=random()
  275.             ifc(int(ran_no*10)<3)
  276.             {
  277.                 chosen=5
  278.                 check_last_tile_game(8)
  279.             }    
  280.             else
  281.             {
  282.                 ifc(int(ran_no*10)<6)
  283.                 {
  284.                     chosen=8
  285.                     check_last_tile_game(0)
  286.                 }
  287.                 else
  288.                 {
  289.                     chosen=0
  290.                     check_last_tile_game(5)
  291.                 }
  292.             }
  293.  
  294.         }
  295.  
  296.         ifc(last_grid==5)
  297.         {
  298.             ran_no=random()
  299.             ifc(ran_no*10<2.5)
  300.             {
  301.                 chosen=1
  302.                 check_last_tile_game(6)
  303.             }
  304.             else
  305.             {
  306.                 ifc(ran_no*10<5.0)
  307.                 {
  308.                     chosen=6
  309.                     check_last_tile_game(9)
  310.                 }
  311.                 else
  312.                 {
  313.                     ifc(ran_no*10<7.5)
  314.                     {
  315.                         chosen=9
  316.                         check_last_tile_game(4)
  317.                     }
  318.                     else
  319.                     {
  320.                         chosen=4
  321.                         check_last_tile_game(1)
  322.                     }
  323.                 }
  324.             }
  325.  
  326.         }
  327.  
  328.  
  329.         ifc(last_grid==6)
  330.         {
  331.             ran_no=random()
  332.             ifc(ran_no*10<2.5)
  333.             {
  334.                 chosen=2
  335.                 check_last_tile_game(7)
  336.             }
  337.             else
  338.             {
  339.                 ifc(ran_no*10<5.0)
  340.                 {
  341.                     chosen=7
  342.                     check_last_tile_game(10)
  343.                 }
  344.                 else
  345.                 {
  346.                     ifc(ran_no*10<7.5)
  347.                     {
  348.                         chosen=10
  349.                         check_last_tile_game(5)
  350.                     }
  351.                     else
  352.                     {
  353.                         chosen=5
  354.                         check_last_tile_game(2)
  355.                     }
  356.                 }
  357.             }
  358.  
  359.         }
  360.  
  361.  
  362.         ifc(last_grid==7)
  363.         {
  364.             ran_no=random()
  365.             ifc(int(ran_no*10)<3)
  366.             {
  367.                 chosen=3
  368.                 check_last_tile_game(6)
  369.             }    
  370.             else
  371.             {
  372.                 ifc(int(ran_no*10)<6)
  373.                 {
  374.                     chosen=6
  375.                     check_last_tile_game(11)
  376.                 }
  377.                 else
  378.                 {
  379.                     chosen=11
  380.                     check_last_tile_game(3)
  381.                 }
  382.             }
  383.  
  384.         }
  385.  
  386.  
  387.         ifc(last_grid==8)
  388.         {
  389.             ran_no=random()
  390.             ifc(int(ran_no*10)<5)
  391.             {
  392.                 chosen=4
  393.                 check_last_tile_game(9)
  394.             }    
  395.             else
  396.             {    
  397.                 chosen=9
  398.                 check_last_tile_game(4)
  399.             }
  400.  
  401.         }
  402.  
  403.  
  404.         ifc(last_grid==9)
  405.         {
  406.             ran_no=random()
  407.             ifc(int(ran_no*10)<3)
  408.             {
  409.                 chosen=8
  410.                 check_last_tile_game(5)
  411.             }    
  412.             else
  413.             {
  414.                 ifc(int(ran_no*10)<6)
  415.                 {
  416.                     chosen=5
  417.                     check_last_tile_game(10)
  418.                 }
  419.                 else
  420.                 {
  421.                     chosen=10
  422.                     check_last_tile_game(8)
  423.                 }
  424.             }
  425.  
  426.         }
  427.  
  428.         ifc(last_grid==10)
  429.         {
  430.             ran_no=random()
  431.             ifc(int(ran_no*10)<3)
  432.             {
  433.                 chosen=11
  434.                 check_last_tile_game(6)
  435.             }    
  436.             else
  437.             {
  438.                 ifc(int(ran_no*10)<6)
  439.                 {
  440.                     chosen=6
  441.                     check_last_tile_game(9)
  442.                 }
  443.                 else
  444.                 {
  445.                     chosen=9
  446.                     check_last_tile_game(11)
  447.                 }
  448.             }
  449.  
  450.         }
  451.  
  452.  
  453.         ifc(last_grid==11)
  454.         {
  455.             ran_no=random()
  456.             ifc(int(ran_no*10)<5)
  457.             {
  458.                 chosen=10
  459.                 check_last_tile_game(7)
  460.             }    
  461.             else
  462.             {    
  463.                 chosen=7
  464.                 check_last_tile_game(10)
  465.             }
  466.  
  467.         }
  468.  
  469.  
  470.  
  471.  
  472.         x=pos_x_tile_game[chosen]
  473.         y=pos_y_tile_game[chosen]
  474.  
  475.         per_last_grid=last_grid
  476.  
  477.             ifc(blank_x==x-242 && blank_y==y)
  478.             {
  479.                 move_accross_left_tile_game(x,blank_y,grid[chosen])
  480.                 blank_x=x
  481.                 grid[last_grid]=grid[last_grid+1]
  482.                 grid[last_grid+1]=0
  483.                 last_grid++
  484.                 grid[last_grid]=0
  485.             }
  486.  
  487.             ifc(blank_x==x+242 && blank_y==y)
  488.             {
  489.                 move_accross_right_tile_game(x,blank_y,grid[chosen])
  490.                 blank_x=x
  491.                 grid[last_grid]=grid[last_grid-1]
  492.                 last_grid--
  493.                 grid[last_grid]=0
  494.             }
  495.             ifc(blank_x==x && blank_y==y-242)
  496.             {
  497.                 move_up_tile_game(blank_x,y,grid[chosen])
  498.                 blank_y=y
  499.                 grid[last_grid]=grid[last_grid+4]
  500.                 grid[last_grid+4]=0
  501.                 last_grid+=4
  502.                 grid[last_grid]=0
  503.  
  504.             }
  505.             ifc(blank_x==x && blank_y==y+242)
  506.             {
  507.                 move=1
  508.                 move_down_tile_game(blank_x,y,grid[chosen])
  509.                 blank_y=y
  510.                 grid[last_grid]=grid[last_grid-4]
  511.                 grid[last_grid-4]=0
  512.                 last_grid-=4
  513.                 grid[last_grid]=0
  514.             }
  515.  
  516.  
  517.     }
  518.  
  519.  
  520.     random_is_on=0
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.     forc(use_sprite=0;use_sprite<cut_sprite_tile_game;use_sprite++)
  528.     {
  529.         SpriteFlags2 use_sprite, clickable|visible|enabled, UNBOUND
  530.     }
  531.  
  532.  
  533.  
  534.  
  535. end sub
  536.  
  537.  
  538.  
  539. sub    check_done_tile_game()
  540. local
  541.     int    check_pos
  542. end local
  543.  
  544.     ts=1
  545.     forc(check_pos=1;check_pos<12;check_pos++)
  546.     {
  547.         ifc(check_pos==grid[check_pos])
  548.             ts++
  549.     }
  550.  
  551. end sub
  552.  
  553.  
  554.  
  555. sub start_to_use_tile_game()
  556.  
  557.  
  558.     on_sprite_drop id,x,y,
  559.     {
  560.  
  561.         print " blank x  ",blank_x,"\n"
  562.         print " blank y  ",blank_y,"\n"
  563.  
  564.  
  565.         ifc(move==0)
  566.         {
  567.             ifc(blank_x==x-242 && blank_y==y)
  568.             {
  569.                 move=1
  570.                 move_accross_left_tile_game(x,blank_y,id)
  571.                 blank_x=x
  572.                 grid[last_grid]=id
  573.                 last_grid++
  574.             }
  575.         }
  576.  
  577.         ifc(move==0)
  578.         {    
  579.             ifc(blank_x==x+242 && blank_y==y)
  580.             {
  581.                 move=1
  582.                 move_accross_right_tile_game(x,blank_y,id)
  583.                 blank_x=x
  584.                 grid[last_grid]=id
  585.                 last_grid--
  586.             }
  587.         }
  588.         ifc(move==0)
  589.         {    
  590.             ifc(blank_x==x && blank_y==y-242)
  591.             {
  592.                 move=1
  593.                 move_up_tile_game(blank_x,y,id)
  594.                 blank_y=y
  595.                 grid[last_grid]=id
  596.                 last_grid+=4
  597.             }
  598.         }
  599.         ifc(move==0)
  600.         {    
  601.             ifc(blank_x==x && blank_y==y+242)
  602.             {
  603.                 move=1
  604.                 move_down_tile_game(blank_x,y,id)
  605.                 blank_y=y
  606.                 grid[last_grid]=id
  607.                 last_grid-=4
  608.             }
  609.         }
  610.         id1=98
  611.         settext id1, itostr(last_grid)
  612.  
  613.         ifc(move==2)
  614.         {
  615.             move=0
  616.             check_done_tile_game()
  617.             ifc(ts==12)
  618.             {
  619.                 sound server_games+`done.wav wave`
  620. //                activepage 1
  621. //                loadimage 110,160,968,726,gif,server+country+`/`+current_n
  622. //                activepage 0
  623. //                clearscreen 0,0,1280,960,standard,1,255
  624.                 wait 3000
  625.                 forc(cut_sprite_tile_game=0;cut_sprite_tile_game<12;cut_sprite_tile_game++)
  626.                 {
  627.                     delsprite cut_sprite_tile_game+100
  628.                     delsprite cut_sprite_tile_game
  629.                 }
  630.  
  631. //                start_to_use_tile_game()
  632.             }    
  633.  
  634.         }
  635.     }
  636.  
  637.  
  638.  
  639.  
  640.  
  641. end sub
  642.  
  643. sub tile_game(start_sprite as int)
  644.  
  645.     on_sprite_drop id,x,y,
  646.     {
  647.         null
  648.     }
  649.     total_moves=0
  650.     blank_x=116
  651.     blank_y=166
  652.  
  653.     dg_no_tile_game=start_sprite
  654.     current_n=filename(itostr(dg_no_tile_game))+`l`+load_ext4
  655.  
  656. //    activepage 1
  657. //    loadimage 110,160,968,726,gif,server+country+`/`+current_n
  658. //    activepage 0
  659. //    clearscreen 0,0,1280,960,standard,1,255
  660.  
  661.  
  662.  
  663.  
  664.     move=0
  665.     read_sprite_tile_game()
  666.     display_sprite_tile_game()
  667.     wait 2000
  668.  
  669.     ifc(exit_tile==0)
  670.     {
  671.         FILLMASK1 255,255,255
  672.         pencolour 0,255,255,255
  673.         activepage 1
  674.         rectangle 110,160,968,726
  675.         activepage 0
  676.         clearscreen 110,160,968,726,standard,1,255
  677.     }
  678.     ifc(total_moves!=random_moves)
  679.     {            
  680.         random_move_tile_game()
  681.         start_to_use_tile_game()
  682.     }
  683.  
  684. end sub
  685.  
  686.