译文由本站 robot-v1.0 翻译
A conversion of the old Text Based Star Trek into Windows using VB.NET 2008 Express
使用VB.NET 2008 Express将旧的基于文本的<星际迷航>转换为Windows
展示在注意小细节的情况下可以做什么.(Shows what can be done with attention to small details.)
1978年前后,我曾经经常玩Apple-] [Trek]很多小时.(I used to play Apple-][ Trek a lot back around 1978 or so for many many hours.)
使用代码(Using the Code)
我将带行号的代码转换为Visual Basic样式代码.然后,我修改了代码部分以简化内容以及自记录的已使用变量和子例程名称.(I took the code with line numbers and converted into a Visual Basic style code. Then I modified sections of code to simplify things as well as used variables and subroutine names that are self documenting.)
这是程序顶部的注释之一,用于解释代码的原始来源:(Here’s one of the comments at the top of the program explaining where the code came from originally:)
' *2. Took the original source code found on a web site about
' Star Trek (Basic) and modified it to be Windows Based
' version of the Text Based Star Trek. Took some inspiration
' from the "Apple-][ Trek" program which I enjoyed a lot
' back in the late 1970's and into early 1980's. Did this
' project on my own time over a several weeks to get the
' code up to the current version. Here a little, there a
' little bit of time.
' Here's the header comments from that code.
' - Extracted from HP tape image 16-Nov-2003 by Pete Turnbull
' - HP BASIC PROGRAM LIBRARY
' - STTR1: STAR TREK
' - 36243 REV B -- 10/73
' - CONTRIBUTED PROGRAM
' - STAR TREK: BY MIKE MAYFIELD, CENTERLINE ENGINEERING
' - TOTAL INTERACTION GAME - ORIG. 20 OCT 1972
兴趣点(Points of Interest)
代码中有许多更改的地方.这是在代码中记录的.(There were many things that have been changed in the code. This is documented within the code.)
如果有人花时间去做,有很多地方可以改进.(There are many areas that can be improved if someone were to take the time to do so.)
历史/附加数据(History / Additional Data)
' * Designed the Form Layout using many concepts gained
' from a lot of Apple-][ Trek and my desire to have
' everything on one form without constantly having to
' remap a console to work like the old Apple-][ Trek
' did things.
' * Next customized the code by removing line numbers that
' were not referenced anywhere else in the code. Then
' modified the code to use subroutines to work properly
' in Windows. Later changed the name of the subroutines to
' tell what each routine does.
' * Customized some of the logic. Things like:
' - Pseudo Random Number generator to ensure a different
' starting layout each time the initialization logic is
' - This is accomplished by the logic using the current
' date and time as the Pseudo Random Number generator
' then randomly generating the initialization for the
' - Unrolled Array Data in the original program for Long
' Range Scanner and Sector arrays.
' - For Example, Unrolled the Data for the Sector Array
' into ONLY 64 characters instead of using an 8 by 8
' array which requires a lot more variable space to use.
' - The ">" to the left of the Current Quadrant where the
' Enterprise is on the Quadrant Map.
' - Allowed Warping around the edge of the map. Such as
' warping from Quadrant 2,7 at sector 1,4 in Warp
' Direction of 4.5 at Warp Factor 3!
' - Added Function Buttons that bring up a TabControl based
' on certain functions for:
' - Navigation
' - Photon Torpedo
' - Phaser Control
' - Shields Control
' *** Text Based Data for each tab added to each tab
' which took away the need for complex list of text
' needed to show the instructions.
' *** When the TabControl is needed, it is shown. Then
' after the function is done, then TabControl is
' *** TabControl gets moved from its' hidden location to
' cover up the function buttons when it is needed
' by using the upper left location of the hidden
' control named OverlayLocation.
' - Added Constant Values where needed to simplify changing
' of Global Values instead of having to find each variable
' inside of the code to change that value every place it
' was setup in the original code.
' - See:
' Const BaseEnergy = 5000
' Const BasePhotons = 25
' Const BaseShields = 1000
' Const MaxStarDates = 30
' Const StarBaseToken = "B" ' Star Base
' Const EnterpriseToken = "E" ' Enterprise
' Const StarSpotToken = "*" ' Star on the map
' Const EmptySpotToken = " " ' Unoccupied space
' Const KlingonToken = "K" ' Klingon Cruiser
' - To match the original programs' values to:
' Const BaseEnergy = 3000
' Const BasePhotons = 10
' - I added BaseShields value of 1000 to make sure that
' each time the program runs or another game is chosen
' or we dock with a Star Base that the Enterprise's
' Shields will start at 1000 units of Energy.
' - Added Sound Functionality with the ability to turn sound
' on and off within the program.
' - Plays the Wave Files as per the filenames listed inside
' of this program. The Wave Files are used from the
' location / directory where the executable program
' exists. If the Wave File is not found, this program is
' smart enough not to crash when the file is not there.
' - See this logic:
' ' Make Sound!
' Dim SoundFile As String = _
' System.AppDomain.CurrentDomain.BaseDirectory + _
' If System.IO.File.Exists(SoundFile) Then
' End If
' - Damage Control Function was automated. So there is no
' need to press a button to get a report.
' - Added "Spock used a new repair technique!" like was
' occasionally seen in Apple-][ Trek when a device was
' repaired beyond 1 Star Date when moving.
' - Short Range Scan for the Current Quadrant is shown in
' the Long Range Scan even if the Long Range Scanner is
' - If Short Range Scanner is damaged, then ONLY up to 1
' unit around the Enterprise is shown in the current
' quadrant instead of being totally blind in the current
' - Upon Docking with a Star Base, ALL damaged devices are
' repaired and the Shields and Energy are reset to the
' initial values.
' - Displays the Current Date and Time in the lower right
' corner of the interface.
' - Displays Condition Status Text in Color.
' - "Green" is displayed in Green.
' - "Red" is displayed in Red.
' - "Yellow" is displayed in Yellow.
' * There are many areas that the program could be enhanced.
' Such as:
' - Adding a Library Computer Function to automatically
' target every Klingon in the current Quadrant then fire
' Photon Torpedoes at them.
' - Adding a Library Computer Function to calculate moving
' from the current Sector in this Quadrant to another
' Sector in the current Quadrant.
' - Adding a Library Computer Function to calculate the
' Warp Factor and Warp Direction to move to another
' - For Example, Calculating the shortest distance from
' Quadrant 2,7 to Quadrant 4,1.
' - Allowing the Klingons to move like in Apple-][ Trek did
' when Klingons were nearly destroyed but barely had
' enough energy to escape to a connected Quadrant if said
' Klingon was on the outer edge of the current Quadrant
' BUT ONLY if the Klingon wouldn't cause the Quadrant it
' wants to move into would not cause the number of
' Klingons to go above 9!
' - X or Y values of either 1 or 8.
' - Allowing User Input for up to 200 Klingons with 1 Star
' Base and 1 Star Base for Every 10 after that.
' - Allow up to a Maximum Value of 9 Klingons per any
' randomly chosen Quadrant.
' * This was done on January 25, 2009 *
' - Allowing up to 9 Klingons per Quadrant.
' - Modified the Klingon Array to allow up to 9 but didn't
' modify the code to generate up to 9 in a quadrant.
' - See "KlingonSectorAndShieldsData" Array!
' - Efficiency Rating needs to be reworked to a better
' formula. I would suggest something like the way Apple-][
' Trek did it!
' - Star Date fine tuning to allow subwarp speeds to not
' calculate as 1 full Star Date. (Warp Speeds under 1)
' - Randomly place Enterprise if Warp Speed is 1 or more
' and successfully warped.
' - Currently places Enterprise at the same sector value
' if Warp Factor is a whole number between 1 and 7.
' - So if you started at Quadrant 1,2 at Sector 3,4
' and you warped 2 at direction 1, the Enterprise
' would end up at Quadrant 3,2 at Sector 3,4.
' * There are bugs that may still be in this program!
' For example: Saw this bug on November 15, 2008:
' Firing a Photon Torpedo from this location that doesn't
' destroy the star like the message log showed.
' - FIXED this bug on January 5, 2009! See the note below!
' Current Quadrant Map displayed as follows for the
' "Sector (Short Range Sensor Scan)":
' | 1 2 3 4 5 6 7 8 |
' | 1 * |
' | 2 * |
' | 3 |
' | 4 K * |
' | 5 * |
' | 6 * |
' | 7 E |
' | 8 |
' Used the "Compute Enemy Direction and Distance" button.
' Fired Photon Torpedo at Direction of "4.5".
' Message Log showed:
' - Direction = 4.5
' - Distance = 6.70820393249937
' - Photon Torpedo Track: (6,6) (6,5) (5,4) (5,3) (4,2)
' - *** Star Destroyed ***
' IF the Photon Torpedo Track were accurate, Star at 5,4
' should have been destroyed. Then if the SAME direction
' of 4.5 would have been used then the Star at 4,2 should
' have been destroyed.
' *** Note *** FIXED on January 5, 2009 by ensuring that the
' values for Z1 and Z2 are integers by using
' the following logic:
' - Z1 = Int(S1 + 0.5) ' X location
' - Z2 = Int(S2 + 0.5) ' Y location
' - InsertIntoStringArrayForSector(InputData)
' * This adjusts the Photon Torpedo Track to:
' (7,6) (6,5) (6,4) (5,3) (5,2) (4,1)
' * This would mean that the Klingon at 4,1 is destroyed!
' *** This points out why one should be very careful to
' use integer values when integer values are expected!
' - For Example, If we pass a double value of 7.99 to
' an integer value, the program will drop the
' fractional part (.99) which results in a value of 7
' instead of 8!
' - That is why I changed "Z1 = S1" to
' "Z1 = Int(S1 + 0.5)" to make sure if the value of
' S1 is almost 8 that 8 will be used for Z1!
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。