# "PAX" version 2 for Casio-CFX-9850G # (based on Spectrum48k game I wrote c.1990) # (C) Roy Maclean 1996-1999 # EMAIL: rfamgm at gmail # WEB: http://www.spiderpixel.co.uk/caspro # (21.11.96) version 1 # (12.03.97) version 1.1 # (??.04.97) version with bitfields (thanks to Tom Lynn) # (27.05.99) version 2 # Your character appears as the letter 'O'. Using the arrow keys you must # move your character about the screen and clear away all the stars '*' # before the time runs out. But there is a catch - you must figure out how # to get rid of the stars- it is not as simple as just going over them. # (This differs from previous versions where you only had to clear some # of the stars.) Now they all have to be cleared. # If you move off one side of the screen you appear on the other side. # You will probably need to use this facility of moving off the screen # in order to complete the game. # On the second level you must fill up the entire screen instead of # clearing it, and on all odd levels you have to clear the screen # and on even levels, fill it. # Each level starts the timer with 100 less than previous level. # If you fail to complete a level you return to level 1. # The randomly generated screens may be easy or hard depending # on how they are arranged. # screenshot: # O I # *** I # * I # * *I 399 # ** ***I # * ** I LEVEL1 # **** * I # As you can see the playing field is on the left and the timer on the # right. The above picture shows that you are on the first level and # there are 399 time units to go. # ___________________________________________ 10->J:Lbl 0 ; 1 "STARTING TIMER AT" ; 2 100J_ ; 3 0->R:ClrText ; 4 Locate 15,7,"LEVEL" ; 5 Locate 20,7,11-J ; 6 48->K:Frac .5J=0=>0->K ; 7 0Identity 7->Mat A ; 8: zero * indentity For 1->A To 7 ; 9: Locate 8,A,"I" ; 10: For 2->B To 7 ; 11: make sure you don't mistype the 2 here Ran#<.5=>Goto 4 ; 12 1->Mat A[A,B ; 13 Isz R:Locate B,A,"*" ; 14: '*' is on the sybl menu Lbl 4:Next:Next ; 15 100J->T:1->X~Y ; 16 Lbl 1 ; 17 Locate 16,4," " ; 18: 4 spaces Locate 16,4,T ; 19 Locate X,Y,"O" ; 20 Getkey->A ; 21 A<>27 And A<>28 And A<>37 And A<>38=>Goto 3 ; 22 21-20Frac .1A->S ; 23 X->E:Y->F ; 24 A=27 Or A=38=>1+7Frac (X+S)%7->X ; 25: use fraction symbol for % E=X=>1+7Frac (Y+S)%7->Y ; 26 Mat A[Y,X ; 27 Locate E,F,"*" ; 28 Ans=>Locate E,F," " ; 29: 1 space R-2Ans+1->R ; 30 1-Ans->Mat A[F,E ; 31 Lbl 3 ; 32 R=K=>Goto 2 ; 33 Dsz T:Goto 1 ; 34 ClrText ; 35 "TIME UP"_ ; 36: _ represents disp thing on |shift|vars|f5| 10->J:Goto 0 ; 37 Lbl 2:ClrText ; 38 "WELL DONE" ; 39 "TIME LEFT" ; 40 T_ ; 41 Dsz J:Goto 0 ; 42 ClrText:"THE END" ; 43 # ___________________________________________ # Now follows information for those interested in how this program works. # Lines 9-15 randomly distribute '*'s on the screen. On Line 11 # the For loop for variable B starts at 2 to avoid displaying a '*' # at location 1,1 because this is where 'O' appears at start of game and # would otherwise cause the '*' counter to be wrong. # Lbl1..Goto1 is the main loop in which Getkey is tested and the timer # counts down. When the timer stored in variable T reaches 0 the loop ends. # Line 18 is used to clear extra digit for when the number of digits of # timer goes from 3 to 2 and from 2 to 1. Clearing them every time # causes some flicker but takes up less memory than 'If' tests. # The units digit of the key pressed is given by 10Frac .1A # Moving Down or right increases x or y coordinates by 1 # Moving up or left decreases x or y by 1. The formula 15-2Unit # or 15-20Frac .1A->S converts unit digits into +1 or -1 # depending on whether (down or right) or (up or left) is pressed # Modular arithmetic means when reach end of screen you appear on # the other side. However mod arithmetic works on the range 0..6 # whereas the locate command works on 1..7 # So if locate also worked on range 0..6 we could use 7Frac ((X+S)/7 # However this now becomes 1+7Frac ((X-1+S)/7 to convert X into mod range # and then result back into locate range. However mod arithmetic remainders # can be negative in range -6..0 so we need to add 7 to bring into positive # range. Hence 1+7Frac((7+X-1+S)/7 or 1+7Frac((X+S+6)/7 which can be # shortened to 1+7Frac((X+S)/7 by adding 6 to S: 21-20Frac .1A->S # or 1+7Frac (X+S)%7 using the fraction symbol for % # Note that 7Frac 7^-1 X produces rounding errors # whereas 7Frac X%7 doesn't. # A=27 Or A=38=>1+7Frac (X+S)%7->X ; 25 # E=X=>1+7Frac (Y+S)%7->Y ; 26 # Line 26 could have started A=28 or A=37 but since E holds the old value # of X, it is shorter to use E=X=> to test whether line 25 was executed. # lines 27-31 are equivalent to but shorter than: # Mat A[Y,X]->C # C=0=>Locate E,F,"*" # C=1=>Locate E,F," " # R-2C+1->R # 1-C->Mat A[F,E] # ___________________________________________ @@ Program "PAX2" 10->J:Lbl 0 "STARTING TIMER AT" 100J_ 0->R:ClrText Locate 15,7,"LEVEL" Locate 20,7,11-J 48->K:Frac .5J=0=>0->K 0Identity 7->Mat A For 1->A To 7 Locate 8,A,"I" For 2->B To 7 Ran#<.5=>Goto 4 1->Mat A[A,B Isz R:Locate B,A,"*" Lbl 4:Next:Next 100J->T:1->X~Y Lbl 1 Locate 16,4," " Locate 16,4,T Locate X,Y,"O" Getkey->A A<>27 And A<>28 And A<>37 And A<>38=>Goto 3 21-20Frac .1A->S X->E:Y->F A=27 Or A=38=>1+7Frac (X+S)%7->X E=X=>1+7Frac (Y+S)%7->Y Mat A[Y,X Locate E,F,"*" Ans=>Locate E,F," " R-2Ans+1->R 1-Ans->Mat A[F,E Lbl 3 R=K=>Goto 2 Dsz T:Goto 1 ClrText "TIME UP"_ 10->J:Goto 0 Lbl 2:ClrText "WELL DONE" "TIME LEFT" T_ Dsz J:Goto 0 ClrText:"THE END"