home *** CD-ROM | disk | FTP | other *** search
/ Computer Life 1995 June / Computer_Life_Magazine_June_1995_Companion_CD.iso / swimdemo / wgame / safegame.txt
Encoding:
Text File  |  1994-07-12  |  9.6 KB  |  429 lines

  1. Safegame:
  2.  local NoOfPlayers 0
  3.  local QuestionNo 0
  4.  local QuestionList "Wgame\Questions.flc"
  5.  Local CurrPlayerNo 1
  6.  Local QuestionAnswer A
  7.  Local DiceNo 0
  8.  Local PlayerMaskLoaded @FALSE 
  9.  Local PlayerPieceDirection R
  10.  
  11.  mark 1 4
  12.    local PlayerPos$chr(@Loop) 1
  13.  loop
  14.  
  15.  Local CurrPlayerPos 1
  16.  Local NoOfSquares 35
  17.  Local ExitWaterGame @FALSE
  18.  
  19.  set ResetMemDisplay @TRUE
  20.  
  21.  cload Wgame\Play1$@PlayerPieceDirection$.pcx playerPiece 1
  22.  Local PieceX PlayerPiece->Xsize  PieceY Playerpiece->YSize
  23.  cfree Playerpiece
  24.   
  25.  pfade 0 "wgame\safegame.pcx" 
  26.  spread @blackpic "wgame\safegame.pcx" 15
  27.  pfree "wgame\safegame.pcx"
  28.  pfree @Blackpic
  29.  Tran on 2
  30.  
  31. ;DataBegin GameGrid
  32. ; mark 1 35
  33. ; set x1 @ y1 @ t1 @ t2 @
  34. ;  box @x1 @y1 @t1 @t2
  35. ; pgetbuf ans  @x1 @y1 @t1 @t2 1
  36. ; psave Square$@loop$.pic ans
  37. ;  putup @x1-3 @y1-3 PlayerPiece
  38. ;  cfree ans
  39. ; loop 
  40. ;waitkey
  41.  
  42.  
  43.  gosub SelectNoOfPlayers
  44.  gosub PlayerGo 1 
  45.  
  46.  SafeGameLoop:
  47.    if @DisplayMemoryOn==@TRUE
  48.      call MemDisp MemoryDisplay
  49.    endif
  50.  
  51.    getmouse MBut Mx1 My1 0
  52.  
  53.    if @ExitWaterGame==@TRUE 
  54.      goto ExitGame
  55.    endif
  56.  
  57.    ifkey ESC ExitGame
  58.    if @Mbut==1&&@Mx1>=5&&@My1>=3&&@Mx1<=120&&@My1<=46
  59.      goto ExitGame
  60.    endif 
  61.  
  62.    if @Mbut==1&&@Mx1>=192&&@Mx1<=449&&@My1>=37&&@My1<=102
  63.     if @PlayerMaskLoaded==@TRUE
  64.      Putup 192 37 PlayerGoMask 
  65.      cfree PlayerGoMask
  66.      set PlayerMaskLoaded @FALSE 
  67.  
  68.      Set QuestionNo random(1,70) 
  69.  
  70.      cgetbuf QuestionMask 92 199 387 390 1
  71.      Position QuestionMask 0 0 
  72.  
  73.      dload @QuestionList, , 1
  74.      putdff @QuestionList 1,0,@QuestionNo-1, 92 199     
  75.      dfree @QuestionList
  76.  
  77.      Databegin GameAnswers
  78.      DataSkip (@QuestionNo*2)-2
  79.      Set QuestionNo @
  80.      Set QuestionAnswer @
  81.     endif
  82.    endif
  83.  
  84.    if @Mbut==1&&@Mx1>=117&&@Mx1<=360&&@My1>=282&&@My1<=303
  85.     if @PlayerMaskLoaded==@FALSE
  86.      If @QuestionAnswer==A
  87.        gosub CorrectAnswer
  88.      else
  89.        gosub WrongAnswer
  90.      endif
  91.     endif
  92.    endif
  93.    if @Mbut==1&&@Mx1>=117&&@Mx1<=360&&@My1>=249&&@My1<=270
  94.     if @PlayerMaskLoaded==@FALSE
  95.      If @QuestionAnswer==B
  96.        gosub CorrectAnswer
  97.      else   
  98.        gosub WrongAnswer
  99.      endif
  100.     endif
  101.    endif
  102.    if @Mbut==1&&@Mx1>=117&&@Mx1<=360&&@My1>=216&&@My1<=235
  103.      If @QuestionAnswer==C
  104.        gosub CorrectAnswer
  105.      else
  106.        gosub WrongAnswer
  107.      endif
  108.    endif
  109.    if @CurrPlayerPos==@NoOfSquares
  110.      gosub Finished
  111.    endif
  112.    if @ExitWaterGame==@TRUE
  113.      goto ExitGame
  114.    endif 
  115.  goto SafeGameLoop
  116. return
  117.  
  118. SelectNoOfPlayers:
  119.   cload index\select NumPlayers 1
  120.   putup 92 199 NumPlayers
  121.   cfree NumPlayers
  122.  
  123.   Selectloop:
  124.     GetMouse Mbut Mx1 My1 0
  125.     if @Mbut==1&&@Mx1>=5&&@My1>=3&&@Mx1<=120&&@My1<=46
  126.       set ExitWaterGame @TRUE 
  127.       goto ExitNoOfPlayers 
  128.     endif 
  129.     ifkey ESC
  130.       set ExitWaterGame @TRUE 
  131.       goto ExitNoOfPlayers 
  132.     endif
  133.     if @Mbut==1&&@Mx1>=132&&@Mx1<=173&&@My1>=248&&@My1<=283
  134.       Set NoOfPlayers 1
  135.       goto ExitNoOfPlayers 
  136.     endif
  137.     if @Mbut==1&&@Mx1>=185&&@Mx1<=227&&@My1>=248&&@My1<=283 
  138.       Set NoOfPlayers 2
  139.       goto ExitNoOfPlayers
  140.     endif
  141.     if @Mbut==1&&@Mx1>=243&&@Mx1<=284&&@My1>=248&&@My1<=283
  142.       Set NoOfPlayers  3
  143.       goto ExitNoOfPlayers
  144.     endif 
  145.     if @Mbut==1&&@Mx1>=298&&@Mx1<=338&&@My1>=248&&@My1<=283
  146.       Set NoOfPlayers 4
  147.       goto ExitNoOfPlayers
  148.     endif
  149.  
  150.  
  151.  
  152.   goto SelectLoop  
  153.  
  154.   ExitNoOfPlayers:
  155.     Pfade 0 wgame\safegame.pcx 
  156.     pfree wgame\safegame.pcx 
  157. return
  158.  
  159. ExitGame:
  160.   if @PlayerMaskLoaded==@TRUE
  161.     cfree PlayerGoMask
  162.   endif 
  163.  
  164.   spread "wgame\safegame.pcx" @blackpic 15
  165.   exit  
  166.  
  167. Nextplayer:
  168.    set PlayerPos$chr(@CurrPlayerNo) @CurrPlayerPos
  169.  
  170.   if @CurrPlayerNo<@NoOfPlayers
  171.     set CurrPlayerNo @CurrPlayerNo+1
  172.   else
  173.     set CurrPlayerNo 1   
  174.   endif
  175. return
  176.  
  177. WrongAnswer:
  178.   Putup 92 199 QuestionMask    
  179.   Cfree QuestionMask
  180.   If @AudioSupport=="SoundBlaster"
  181.     @Sbdisk Play "Wave\no.voc"
  182.   endif
  183.   gosub NextPlayer
  184.   gosub PlayerGo @CurrPlayerNo
  185. return
  186.  
  187. CorrectAnswer:
  188.   local DiceFrames 0
  189.   local OldPos 0
  190.   local Sx1 0 Sy1 0 Sx2 0 Sy2 0 Ex1 0  Ey1 0 Ex2 0 Ey2 0
  191.  
  192.   If @AudioSupport=="SoundBlaster"
  193.     @Sbdisk Play "Wave\weldonef.voc"
  194.   endif  
  195.   
  196.   Putup 92 199 QuestionMask    
  197.   Cfree QuestionMask
  198.   
  199.   dload "index\diceanti.flc" dice 1
  200.   set DiceNo random(1,6)
  201. ;  set DiceNo 35
  202.   putdff Dice 5,0,36, 456 305     
  203.    
  204.   if @DiceNo==1 
  205.     set diceFrames 1
  206.   endif
  207.   if @DiceNo==2 
  208.     set diceFrames 7
  209.   endif
  210.   if @DiceNo==3 
  211.     set diceFrames 13
  212.   endif
  213.   if @DiceNo==4 
  214.     set diceFrames 31
  215.   endif
  216.   if @DiceNo==5 
  217.     set diceFrames 25
  218.   endif
  219.   if @DiceNo==6 
  220.     set diceFrames 19
  221.   endif
  222.   putdff Dice 5,0,@DiceFrames, 456 305     
  223.   Dfree Dice
  224.  
  225.   databegin GameGrid   
  226.   dataSkip ((@CurrPlayerPos*5)-5)
  227.   Set Sx1 @-3 Sy1 @-3 Sx2 @ Sy2 @
  228.   Set PlayerPieceDirection @
  229.  
  230.   set OldPos @CurrPlayerPos
  231.  
  232.   Set CurrPlayerPos (@CurrPlayerPos+@DiceNo)
  233.   if @CurrPlayerPos>@NoOfSquares
  234.     set CurrPlayerPos @NoOfSquares
  235.   endif
  236.  
  237.   gosub FreeSquare
  238.  
  239.   mark @oldpos @CurrPlayerPos-1
  240.     Set Ex1 @-3 Ey1 @-3 Ex2 @ Ey2 @
  241.     Set PlayerPieceDirection @
  242.     if @Loop==@OldPos
  243.       mark 1 @NoOfPlayers
  244.         if @OldPos==@(PlayerPos$chr(@Loop))&&@CurrPlayerNo<>@Loop 
  245.           cload wgame\play$@loop$@PlayerPieceDirection$.pcx tpiece 1
  246.           Putup @Sx1 @Sy1 tpiece
  247.           cfree tpiece 
  248.           break Found
  249.         endif    
  250.       loop
  251.       found:
  252.     endif
  253.  
  254.     timer
  255.     cload wgame\play$@CurrPlayerNo$@PlayerPieceDirection$.pcx PlayerPiece 1
  256.     float @Sx1 @Sy1 @Ex1 @Ey1 4 5 PlayerPiece 
  257.     EndFloat
  258.     Set Sx1 @Ex1 Sy1 @Ey1
  259.   loop
  260.   timer 
  261.   PutUp @Ex1 @Ey1 PlayerPiece
  262.   cfree PlayerPiece
  263.   waitkey 50
  264.  
  265.   if @CurrPlayerPos<@NoOfSquares
  266.     gosub NextPlayer
  267.     gosub PlayerGo @CurrPlayerNo
  268.   endif
  269.  
  270. Return
  271.  
  272.  
  273.  
  274. PlayerGo:
  275.  local Sx1 0 Sy1 0 Sx2 0 Sy2 0
  276.  
  277.  cload wgame\play$@CurrPlayerNo$go.pcx Play 1
  278.  cgetBuf PlayerGoMask 192 37 (Play->xsize+192) (Play->ysize+37)
  279.  Position PlayerGoMask 0 0
  280.  set PlayerMaskLoaded @TRUE 
  281.  
  282.  putup 192 37 Play
  283.  cfree Play    
  284.  
  285.  set CurrPlayerPos @(PlayerPos$chr(@CurrPlayerNo))  
  286.  
  287.  
  288.  databegin GameGrid   
  289.  dataSkip ((@CurrPlayerPos*5)-5)
  290.  Set Sx1 @-3 Sy1 @-3 Sx2 @ Sy2 @
  291.  Set PlayerPieceDirection @
  292.  
  293.  cload wgame\play$@1$@PlayerPieceDirection$.pcx PlayerPiece 1 
  294.  PutUp @Sx1 @Sy1 PlayerPiece
  295.  cfree PlayerPiece
  296. return 
  297.  
  298.  
  299.  
  300. FreeSquare:
  301.   local Sx1 0 Sy1 0 Sx2 0 Sy2 0
  302.    databegin GameGrid   
  303.  
  304.    dataSkip ((@OldPos*5)-5)
  305.    Set Sx1 @ Sy1 @ Sx2 @ Sy2 @
  306.    Set PlayerPieceDirection @
  307.  
  308.    cload wgame\$Square$@OldPos$.pic SqMask 1
  309.    position SqMask 0 0 
  310.    Putup @Sx1 @Sy1 SqMask
  311.    cfree SqMask
  312. return
  313.  
  314. Finished:
  315.   local StartSub 0
  316.   MOUSE POSITION 182 224
  317.   If @AudioSupport=="SoundBlaster"
  318.     @Sbdisk Play "Wave\cheer.voc"
  319.   endif  
  320.   if @CurrPlayerNo==1
  321.      dload "wgame\BlueSub.flc" ,Sub, 1   
  322.      local EndSub Sub->frames-1
  323.   endif
  324.   if @CurrPlayerNo==2
  325.      dload "wgame\yeloSub.flc" ,Sub, 1   
  326.      local EndSub Sub->frames-1
  327.   endif
  328.   if @CurrPlayerNo==3
  329.      dload "wgame\RedSub.flc" ,Sub, 1   
  330.      local EndSub Sub->frames-1
  331.   endif
  332.   if @CurrPlayerNo==4
  333.      dload "wgame\GreenSub.flc" ,Sub, 1   
  334.      local EndSub Sub->frames-1
  335.   endif  
  336.   Timer
  337.   set Mbut 0 Mx1 0 My1 0
  338.   Finishloop:
  339.  
  340.     ifkey ESC FinishExit 
  341.     if @Mbut==1&&@Mx1>=5&&@My1>=3&&@Mx1<=120&&@My1<=46
  342.      goto FinishExit
  343.     endif 
  344.  
  345.     if @Mbut==1&&@Mx1>=132&&@Mx1<=390&&@My1>=224&&@My1<=265 
  346.       gosub ResetGame 
  347.       goto FinishContinue
  348.     endif
  349.  
  350.     if @elapsed>50     
  351.       putdff Sub 0,@StartSub,@StartSub, 92 199     
  352.       Timer
  353.     endif
  354.  
  355.     if @StartSub>@EndSub
  356.       set StartSub 0
  357.     else
  358.       Set StartSub @StartSub+1
  359.     endif
  360.     getmouse Mbut Mx1 My1 0
  361.   goto FinishLoop
  362.  
  363.   FinishExit:
  364.     set ExitWaterGame @TRUE
  365.     return
  366.   FinishContinue:  
  367. return
  368.  
  369. ResetGame: 
  370.   mark 1 4
  371.    set PlayerPos$chr(@Loop) 1
  372.   loop
  373.   set CurrPlayerPos 1
  374.  
  375.   Pfade 0 "wgame\safegame.pcx" 
  376.   pfree "wgame\safegame.pcx" 
  377.  
  378.   gosub SelectNoOfPlayers  
  379.   gosub PlayerGo 1 
  380. return
  381.  
  382. GameAnswers:
  383. 1 B 2 C 3 A 4 B 5 A 6 B 7 C 8 A 9 B 10 A 11 A 12 B 13 C 14 B 15 A 16 A 17 A
  384. 18 B 19 A 20 C 21 C 22 B 23 A 24 B 25 C 26 A 27 B 28 C 29 B 30 A 31 C 32 B
  385. 33 C 34 B 35 B 36 C 37 A 38 B 39 B 40 C 41 B 42 A 43 A 44 B 45 C 46 A 47 B
  386. 48 C 49 B 50 A 51 C 52 C 53 A 54 B 55 C 56 B 57 B 58 C 59 A 60 C 61 B 62 C
  387. 63 B 64 A 65 C 66 B 67 C 68 B 69 B 70 A
  388. Dataend
  389.  
  390. GameGrid:
  391.       501   19       570   78   R
  392.       570   19       626   78   R
  393.       570   79       626   129  R
  394.       570   130      626   187  L
  395.       515   130      570   187  L
  396.       460   130      515   187  L
  397.       404   130      460   187  L
  398.       349   130      404   187  L
  399.       294   130      349   187  L 
  400.       239   130      294   187  L
  401.  
  402.       184   130      238   187  L
  403.       127   130      183   187  L
  404.       72    130      125   187  L
  405.       15    130      71   187   L
  406.       15   188      71   237    L
  407.       15   238      71   293    L 
  408.       15   294      71   350    L
  409.       15   351      71   400    L
  410.       15   401      71   460    R
  411.       72   401      126   460   R
  412.  
  413.       126   401      181   460  R
  414.       181   401      236   460  R
  415.       236   401      291   460  R
  416.       291   401      346   460  R
  417.       346   401      400   460  R
  418.       400   401      456   460  R
  419.       400   345      456   400  R
  420.       400   293      456   344  R
  421.       400   238      454   293  R 
  422.       455   238      509   293  R
  423.  
  424.       509   238      564   293  R
  425.       564   238      619   293  R
  426.       563   294      619   346  R
  427.       563   347      619   401  R
  428.       500   403      619   455  L
  429. dataend