In this game, you're told how far in the future you want to go. You then input the distance of the trip (in light-years), and the speed of the ship from 0 to 1, where 1 is light-speed and 0 is a dead stop. According to Einsteinian physics, the universe will age more quickly (relative to you) the faster you go.
Example: With light-speed 1 and a distance of 20 light years, you would age 20 years, but the universe would have aged infinitely. With light-speed 0.9 and a distance of 20 light years, you would age 22.2222... years while the universe would age 50.98 years. And so on.
Note that you cannot enter light speeds of 0 or 1 into this program, as that would either not move, or age the universe infinitely. Always choose a number between 0.00001 and 0.9999.
The purpose of the game is to travel forward in time to within five years of the target date, without aging more than fifty years (at which point you die). Basically, fiddle around with the numbers until you get the idea.
In the above image, from top to bottom, the text boxes are named txtSpeed and txtDistance; and the 4 labels are named lblIntroMessage, lblTimeInside, lblTimeOutside, and lblStatus. The clock image at the top is a PictureBox, using Visual Basic\Graphics\Icons\Misc\Clock02.ico.
For the button marked GO!:' Get speed and distance from the appropriate text controls speed = Val(txtSpeed.Text) distance = Val(txtDistance.Text) ' Calculate number of years you've aged and number of years the universe has aged TripTimeInside = Int(distance / speed) TripTimeOutside = Int(TripTimeInside / Sqr(1 - speed * speed)) ' Display those two values lblTimeInside.Caption = Str$(TripTimeInside) lblTimeOutside.Caption = Str$(TripTimeOutside) If TripTimeInside > 50 Then ' More than 50 years have passed lblStatus.Caption = "You died on the way." ElseIf Abs(t - TripTimeOutside) > 5 Then ' Over 5 years difference lblStatus.Caption = "Not even close!" Else lblStatus.Caption = "You arrived on-time." End If |
' t = between 25 and 125 years, as target t = Int(Rnd * 100 + 25) ' Display the introductory message lblIntroMessage.Caption = "You wish to return" + Str$(t) + " years in the future." txtSpeed.Text = "" txtDistance.Text = "" lblTimeInside.Caption = "" lblTimeOutside.Caption = "" lblStatus.Caption = "" |
Randomize Timer ' t = between 25 and 125 years, as target t = Int(Rnd * 100 + 25) ' Display the introductory message lblIntroMessage.Caption = "You wish to return" + Str$(t) + " years in the future." |
Dim t As Double Dim speed As Double Dim distance As Double Dim TripTimeInside As Double Dim TripTimeOutside As Double |
Unload Me |
Extra Improvements: