Casio Calculator Program Library

Program name: Gravity (v. 1.1)  --(Back to Index)--

CTF file name: gravity.ctf
Author: Tom Lynn
Date: 1995-1997
Models: 9700, 9800, 9750, 9850, 9950, 7400

Screenshots:

[screenshot] [screenshot]


Description:

   In this game (based on a version I saw for an Acorn Archimedes)
   two players take it in turns to lob missiles at each other in
   space.  The paths of the missiles are, however, affected by the
   gravity of nearby planetoids, so this requires some skill and
   patience.  The game plays similarly to Scorched Earth (SCORCH)
   or Gorillas.
              

* How to play *

   Players take turns at firing missiles (exactly as they do in real
   wars :-).  To aim a missile, position your cursor at a point which
   you want to aim at and press [EXE].  The distance from the tip of
   your spaceship represents the initial speed of the missile.
              

* Missing the target *

   In most games of this sort, once a missile goes off the screen, the
   turn ends.  In this game, when a missile goes off the screen, there
   is a snazzy 'zoom out', as the missile may loop round and come back
   for the kill...
   
   ...and if you are not careful, your own missile can loop round and
   kill you!
   
   Missiles stop when they hit either player, when they hit a planetoid,
   or when they go off the 'zoomed out' screen.
              

* Stopping a turn short *

   If a missile seems to be taking ages to hit something and both players
   agree, you can press [AC] to stop the game and restart.  The game will
   continue from where you left off, except that it will be the next
   player's turn.  This also means you can use [AC] as a 'bosskey' if a
   teacher or other official comes past, or as a pause key if you want
   to actually use the calculator to do maths...  This will only fail if
   you change any of the variables used by the program while it is paused.
              

* Entering the programs *

   Type the programs as they appear here.  Tokens starting with a \ are
   non-printable symbols.  They should usually be self-explanatory.  If
   not, you should check their meaning in the CTF (address at top).
   
   This program needs Matrix U to be defined as 3x3 manually before
   you try running it, as it uses this to store the planetoid sizes and
   co-ordinates.  This means the prog will not work on pre-9700 calcs,
   unless it is cunningly hacked to use the statistics memories.
   
   If you are using a 9750, 9850 or 9950, you will have to rename these
   progs to the commented names, and use the alternative lines where
   indicated.  This program should still work 'as is' even if you are
   using a non-widescreen calc.
              
Program source code:
Program "~GRAVITY"

   Prog V
              
Program V (MATRIX) [9x50s: "~GRAVITY"]

   'GRAVITY
   M=\pi\sqr=>Goto C
   \pi\sqr->M
   74+30Ran#->A
   74+30Ran#->B
   144->Q
   A->R
   240->S
   B->T
   Prog T             ; 9x50s: Prog "GRSTEUP"
   0->P
   Lbl 0
   Range 129,255,0,65,127,0
   Prog S             ; 9x50s: Prog "GRDRAWSC"
   
   Plot Q[2P],R[2P]   ; 9x50s: P=0=>Plot Q,R
                      ; 9x50s: P=1=>Plot S,T
   Plot X,Y_
   
   X->Q[2P]           ; 9x50s: P=0=>X->Q
                      ; 9x50s: P=1=>X->S
   
   Y->R[2P]           ; 9x50s: P=0=>Y->R
                      ; 9x50s: P=1=>Y->T
   
   Y-A[P]->H          ; 9x50s: P=0=>Y-A->H
                      ; 9x50s: P=1=>Y-B->H
   
   X-144-96P->G
   Deg
   \sqrt(G\sqr+H\sqr->\r
   \acos (H/\r->\th
   \r>15=>15->\r
   G<0=>360-\th->\th
   P=1=>360-\th->\th
   Abs (\th-270<30=>Goto Y
   P=1=>360-\th->\th
   144+96P->J
   
   A[P]->K          ; 9x50s: P=0=>A->K
                    ; 9x50s: P=1=>B->K
   Plot J,K
   .3\r->\r
   \rsin \th->U
   \rcos \th->V
   0->Z
   Lbl 1
   J+U->J
   K+V->K
   Plot J,K
   Z=1=>Plot J,K
   Line
   J<129=>Goto D
   J>255=>Goto D
   K<65=>Goto D
   K>127=>Goto D
   Z=0=>Goto E
   0->Z
   Range 129,255,0,65,127,0
   Prog S             ; 9x50s: Prog "GRDRAWSC"
   Plot J,K
   Lbl E
   J>383=>Goto C
   K>191=>Goto C
   J<1=>Goto C
   K<1=>Goto C
   1->D
   Lbl 3
   (J-Mat U[D,1])\sqr+(K-Mat U[D,2])\sqr<=Mat U[D,3]\sqr=>Goto C
   Isz D
   D<=C=>Goto 3
   X>=133=>11(Y-A<=720-5X=>11(Y-A>=5X-720=>Goto N
   X<=251=>11(Y-B<=5X-1200=>11(Y-B>=1200-5X=>Goto O
   Prog W             ; 9x50s: Prog "GRDIVERT"
   Goto 1
   Lbl C
   1-P->P
   Goto 0
   Lbl D
   Z=1=>Goto E
   1->Z
   Range 2,380,0,2,188,0
   Prog S             ; 9x50s: Prog "GRDRAWSC"
   Plot 129,65
   Plot 255,Y
   Line
   Plot X,127
   Line
   Plot 129,Y
   Line
   Plot 129,65
   Line
   Goto E
   Lbl Y
   "      SUICIDE!"
   " "
   P=1=>Goto O
   Lbl N
   " (-) PLAYER 2 WINS! (-)"   ; (-) means the negative sign, as in -3.
   Goto Z
   Lbl O
   " (-) PLAYER 1 WINS! (-)"
   Lbl Z
   0->M
   ""
              
Program W (MATRIX) [9x50s: "GRDIVERT"]

   'GRDIVERT
   0->D~F
   Isz D
   Lbl 4
   Mat U[D,1]->G
   Mat U[D,2]->H
   Mat U[D,3]->I
   I\sqr/((G-J)\sqr+(H-K)\sqr->L
   E+.08L(G-J->E
   F+.08L(H-K->F
   Isz D
   D<=C=>Goto 4
   U+E->U
   V+F->V
              
Program S (MATRIX) [9x50s: "GRDRAWSC"]

   'GRDRAWSCR
   Plot 133,A-5
   Plot X,A+5
   Line
   Plot 144,A
   Line
   Plot 133,A-5
   Line
   Plot 240,B
   Plot 251,B+5
   Line
   Plot X,B-5
   Line
   Plot 240,B
   Line
   1->D
   Lbl 0
   Mat U[D,1]->E
   Mat U[D,2]->F
   Mat U[D,3]->G
   Plot E-G,F
   Plot E-.7G,F+.7G
   Line
   Plot E,F+G
   Line
   Plot E+.7G,F+.7G
   Line
   Plot E+G,F
   Line
   Plot E+.7G,F-.7G
   Line
   Plot E,F-G
   Line
   Plot E-.7G,F-.7G
   Line
   Plot E-G,F
   Line
   Isz D
   D<=C=>Goto 0
              
Program T (MATRIX) [9x50s: "GRSETUP"]

   'GRSETUP
   1+Int (3Ran#->C
   1->D
   Lbl 0
   158+Int (60Ran#->Mat U[D,1
   78+Int (40Ran#->Mat U[D,2
   3+Int (7Ran#->Mat U[D,3
   1->E
   Lbl 1
   E=D=>Goto 2
   Mat U[D,3]+Mat U[E,3]->F
   Abs (Mat U[D,1]-Mat U[E,1<=F=>Goto 0
   Abs (Mat U[D,2]-Mat U[E,2<=F=>Goto 0
   Isz E
   Goto 1
   Lbl 2
   Isz D
   D<=C=>Goto 0
              


This page was created by Tom Lynn (tom-calcs@mythic-beasts.com).
This page last updated: Friday, 30 April, 1999

Written in notepad and compiled with WTA, for clean, consistent HTML.
Part of the Casio Graphical Calculator Encyclopaedia.

Best Viewed With Any Browser