home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / progmisc / euphor10.zip / VARS.E < prev    next >
Text File  |  1993-06-08  |  8KB  |  281 lines

  1. -- vars.e
  2. -- declarations of global variables and constants
  3. global constant TRUE = 1, FALSE = 0
  4.  
  5. global constant CRT = 1 -- output device
  6.  
  7. global constant G_SIZE = 7 -- the galaxy is a G_SIZE x G_SIZE
  8.                -- array of quadrants
  9.  
  10. global constant INVISIBLE_CHAR = ' ' + 256 -- prints as ' '
  11.                        -- but has different value
  12.  
  13. global type boolean(object x)
  14.     return x = TRUE or x = FALSE
  15. end type
  16.  
  17. global type char(integer c)
  18. -- true if c is a character that can be printed on the screen
  19.     return c >= ' ' and c <= 127 or c = INVISIBLE_CHAR
  20. end type
  21.  
  22. global type byte(integer x)
  23.     return x >= -1 and x <= 255
  24. end type
  25.  
  26. global type positive_int(integer x)
  27.     return x >= 0
  28. end type
  29.  
  30. global type positive_atom(atom x)
  31.     return x >= 0
  32. end type
  33.  
  34. -----------------------------------------------------------------------------
  35. -- the "f" array: (objects in the current quadrant)
  36. -----------------------------------------------------------------------------
  37. global constant
  38.     FROWS = 30,   -- number of rows (objects) in the f array
  39.     FCOLS = 12    -- number of columns in the f array
  40. global constant
  41.     F_TYPE =   1, -- type of object
  42.     F_EN   =   2, -- energy
  43.     F_TORP =   3, -- number of torpedoes
  44.     F_DEFL =   4, -- number of deflectors
  45.     F_FRATE =  5, -- firing rate
  46.     F_MRATE =  6, -- moving rate
  47.     F_TARG =   7, -- target
  48.     F_DOCK =   8, -- docked yet?
  49.     F_PBX =    9, -- planet/base index
  50.     F_X =     10, -- x coordinate
  51.     F_Y =     11, -- y coordinate
  52.     F_UNDER = 12  -- characters underneath
  53.  
  54. global sequence f
  55. f = repeat(repeat(0, FCOLS), FROWS)
  56.  
  57. global type valid_f_row(integer x)
  58. -- true if x is a valid row number in the f array
  59.     return x >= 1 and x <= FROWS
  60. end type
  61.  
  62. global type f_row(object x)
  63. -- either an f_row or -1 (null value)
  64.     return valid_f_row(x) or x = -1 or x = 0
  65. end type
  66.  
  67. -- the f array elements always appear according to the following order
  68. -- where row 1 is always the Enterprise. The following variables mark
  69. -- the start of each group of objects, where a group may be empty:
  70. global constant ENTERPRISE = 1                       -- row 1 is Enterprise
  71.                              -- row 2 is first planet
  72.                              -- (if any)
  73. global f_row
  74.     fb1,  -- first base
  75.     fr1,  -- first Romulan
  76.     ft1,  -- first Tholian
  77.     fk1,  -- first Klingon
  78.     fnext -- first empty row
  79.  
  80. -----------------------------------------------------------------------------
  81. -- the galaxy array: (records numbers of objects across
  82. --                    all quadrants of the galaxy)
  83. -----------------------------------------------------------------------------
  84. global constant
  85.     G_EN = 1,  -- Enterprise (in g [1] is used to mark if Enterprise has been
  86.            --             this quadrant)
  87.     G_SK = 2,  -- small klingon
  88.     G_BK = 3,  -- big klingon
  89.     G_JM = 4,  -- jumbo klingon
  90.     G_RM = 5,  -- romulan
  91.     G_TH = 6,  -- tholian
  92.     G_PL = 7,  -- planet
  93.     G_BS = 8,  -- base
  94.     NTYPES = 8 -- number of different types of object
  95.  
  96. global sequence otype
  97.  
  98. global type object_type(integer x)
  99. -- is x a type of object?
  100.     return x >= 1 and x <= NTYPES
  101. end type
  102.  
  103. global sequence g
  104.  
  105. -----------------------------------------------------------------------------
  106. -- the planet/base array (records info on each planet and base in the galaxy)
  107. -----------------------------------------------------------------------------
  108. global constant
  109.     PROWS = 9,    -- number of planets + bases
  110.     PCOLS = 8     -- number of columns
  111. global constant
  112.     P_EXIST = 1, -- does it exist?
  113.     P_QR    = 2, -- quadrant row
  114.     P_QC    = 3, -- quadrant column
  115.     P_X     = 4, -- x coordinate within quadrant
  116.     P_Y     = 5, -- y coordinate within quadrant
  117.     P_EN    = 6, -- energy available
  118.     P_TORP  = 7, -- torpedos available
  119.     P_POD   = 8  -- pods available (new weapon system, not yet implemented)
  120.  
  121. global constant DESTROYED = 1, DOCKED_WITH = 2, NEVER_DOCKED = 3
  122.  
  123. global sequence pb
  124. pb = repeat(repeat(0, PCOLS), PROWS)
  125.  
  126. global type pb_row(integer x)
  127. -- is x a valid row in the planet/base array?
  128.     return x >= 1 and x <= PROWS
  129. end type
  130.  
  131. global type g_index(integer x)
  132. -- a valid row or column index into the galaxy array
  133.     return x >= 1 and x <= G_SIZE
  134. end type
  135.  
  136. global boolean gameover  -- is game over?
  137.  
  138. global g_index qrow, qcol  -- current quadrant row and column
  139.  
  140. ------------------
  141. -- Romulan status:
  142. ------------------
  143. global constant
  144.     TRUCE    = 0,
  145.     HOSTILE  = 1,
  146.     CLOAKING = 2
  147.  
  148. global type romulan_status(object x)
  149.     return find(x, {TRUCE, HOSTILE, CLOAKING})
  150. end type
  151.  
  152. global romulan_status rstat
  153.  
  154. global f_row rtarg -- Romulan group target
  155.  
  156. global boolean truce_broken  -- was the truce with the Romulans broken?
  157.  
  158. global boolean gal -- are we in the Galileo?
  159.  
  160. -----------------
  161. -- multiple tasks
  162. -----------------
  163. global constant NTASKS = 10 -- number of tasks
  164.  
  165. global constant
  166.     TASK_KEYB     = 1, -- keyboard input
  167.     TASK_EMOVE    = 2, -- Enterprise move
  168.     TASK_LIFE     = 3, -- life support energy consumption
  169.     TASK_DEAD     = 4, -- dead body cleanup
  170.     TASK_RSTAT    = 5, -- Romulan status change
  171.     TASK_FIRE     = 6, -- enemy firing
  172.     TASK_MOVE     = 7, -- enemy moving
  173.     TASK_UREM     = 8, -- units remaining delayed print
  174.     TASK_DAMAGE   = 9, -- damage count-down
  175.     TASK_ENTER    = 10 -- enemy ships enter quadrant
  176.  
  177. global type task(integer x)
  178. -- is x a valid task number?
  179.     return x >= 1 and x <= NTASKS
  180. end type
  181.  
  182. global task current_task -- current task executing
  183. global sequence tcb      -- task activation times
  184. global sequence eat      -- early activation tolerance
  185. global sequence wait     -- waiting time, in seconds, between activations
  186.  
  187. -----------------
  188. -- damage report:
  189. -----------------
  190. global constant NSYS = 5  -- number of systems that can be damaged
  191. global constant ENGINES        = 1,
  192.         TORPEDOS       = 2,
  193.         GUIDANCE       = 3,
  194.         PHASORS        = 4,
  195.         GALAXY_SENSORS = 5
  196.  
  197. global constant dtype = {"ENGINES",
  198.              "TORPEDO LAUNCHER",
  199.              "GUIDANCE SYSTEM",
  200.              "PHASORS",
  201.              "SENSORS"}
  202. global type subsystem(integer x)
  203.     return x >= 1 and x <= NSYS
  204. end type
  205.  
  206. global sequence reptime  -- time to repair a subsystem
  207. reptime = repeat(0, NSYS)
  208.  
  209. type damage_count(integer x)
  210.     return x >= 0 and x <= NSYS
  211. end type
  212.  
  213. global damage_count ndmg
  214.  
  215. --------------
  216. -- warp speed:
  217. --------------
  218. global constant MAX_WARP = 5
  219.  
  220. global type warp(integer x)
  221.     return x >= 0 and x <= MAX_WARP
  222. end type
  223.  
  224. global warp curwarp, wlimit
  225.  
  226. --------------------------------------
  227. -- Graphic symbols for some objects --
  228. --------------------------------------
  229. global constant
  230.     STAR = '.',
  231.     TORPEDO = '+',
  232.     POD = '*',
  233.     DEFLECTOR = 'd',
  234.     BASE = "<>-<>",         -- both halves
  235.     PLANET_TOP    = INVISIBLE_CHAR & "OOOO" & INVISIBLE_CHAR,
  236.     PLANET_MIDDLE = "OOOOOO",
  237.     PLANET_BOTTOM = INVISIBLE_CHAR & "OOOO" & INVISIBLE_CHAR,
  238.     ROMULAN_L = "-=##:",
  239.     ROMULAN_R = ":##=-",
  240.     SHUTTLE_L = "-=:",
  241.     SHUTTLE_R = ":=-",
  242.     ENTERPRISE_L = "O-=",
  243.     ENTERPRISE_R = "=-O",
  244.     THOLIAN_L = "-+<",
  245.     THOLIAN_R = ">+-",
  246.     S_KLINGON_L = "O**<",
  247.     S_KLINGON_R = ">**O",
  248.     B_KLINGON_L = "-8**<",
  249.     B_KLINGON_R = ">**8-",
  250.     J_KLINGON_L = "=8**<",
  251.     J_KLINGON_R = ">**8="
  252.  
  253. -------------------------------------
  254. -- Enterprise position and direction:
  255. -------------------------------------
  256. type enterprise_x_inc(integer x)
  257.     return x >= -3 and x <= +3
  258. end type
  259.  
  260. type enterprise_y_inc(integer x)
  261.     return x >= -1 and x <= +1
  262. end type
  263.  
  264. global enterprise_x_inc    exi
  265. global enterprise_y_inc eyi
  266.  
  267. global sequence esym,   -- enterprise/shuttle symbol
  268.         esyml,  -- enterprise/shuttle facing left
  269.         esymr   -- enterprise/shuttle facing right
  270.  
  271.  
  272. global sequence nobj  -- number of each type of object in galaxy
  273.  
  274. global positive_atom dist, ur
  275. global object_type urt
  276. global valid_f_row shooter
  277. global f_row victim
  278. global sequence wipeout
  279. wipeout = {}
  280.  
  281.