1. Home
  2. Computing & Technology
  3. C / C++ / C#

Star Trek Game Conversion Project

By David Bolton, About.com

6 of 8

What Each Variable Holds

These are the variables used in the original program. I changed these to reasonably meaningful names. I tend to favour pascal capitalization LikeThis, though I may have missed the odd one.
  • A, I, M and J - General reuse for input and loop indices.
  • S, G, L, P, R, W and T - Subroutine line numbers also generally reused.
  • O - DOcked Flag.
  • U and V - Location of Enterprise in Quadrants.
  • X and Y - Location of enterprise in Sectors.
  • F - Number of Photon Torpedoes.
  • E - Enterprise Energy.
  • D - Days Left.
  • C - Casualties.
  • K - Number of Klingons.
  • N - Number of Klingons in Quadrant.
  • B - number of Starbases.
  • H - Number of Klingons to kill. (Copy of K)
  • Y - Difficulty Level. 2999 (Normal), 999 (Hard) or 987 (replay After being Killed).

How the @ Array was used

  • 0-63 Quadrants - Each Quadrant has a 3 digit number. KBS where K = # Klingons, B = Bases, S= # Stars.
  • 64-70 Damage flags for Starship equipment as follows. Numbers 64-70 are positions in the @ array.
    1. short_range_sensors - 64
    2. computer_display - 65
    3. long_range_sensors - 66
    4. phasers - 67
    5. warp_engine - 68
    6. photon torpedo tubes - 69
    7. shield - 70
  • 71-127 Sectors Each sector holds an single int with the following values:
    0 Empty
    1 Klingon
    2 StarBase
    3 Star
    4 Enterprise
  • 134-151 Klingons (3 x 6 bytes)
  • (134-139) - Energy. Initially 300
  • (140-145) - Sector X of Klingon
  • (146-151) - Sector Y of Klingon
On the next page : Architectural changes I made

6 of 8

Explore C / C++ / C#

More from About.com

  1. Home
  2. Computing & Technology
  3. C / C++ / C#
  4. Projects
  5. Star Trek Conversion
  6. What Each Variable Holds

©2008 About.com, a part of The New York Times Company.

All rights reserved.