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

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