Post Reply 
Rocket Game - from 101 BASIC Computer Games
08-18-2015, 12:14 PM
Post: #4
RE: Rocket Game - from 101 BASIC Computer Games
I was wondering how you were detecting the result of your most current burn rate? As provided the program seems to just show the input screen, until the "Lander" terminates successfully, or not.

However, if a "wait(R);" is used immediately after the INPUT(R); line, the corresponding output becomes viewable.

The details for making the program more interactive are more than I want to undertake, but you could make use of graphic commands (described in the user guide) to not only watch the lander progress, but influence the craft as it falls to the landing zone. That would allow you to more easily land the craft at very close to zero velocity, fairly gracefully.

Code:

EXPORT Lander()
BEGIN
  PRINT();
  L:=0;       // ELAPSED TIME
  T:=10;      // SEC PER INTERVAL
  A:=120;     // MI
  V:=1;       // MI/S
  M:=33000;   // Capsule Weight LB
  N:=16500;   // Fuel Weight LB
  G:=1.6249;  // MOON G IN M/S^2

  PRINT("SEC : " +"MI+FT : " +"MPH : " +"LB_FUEL : " +"RATE : ");

  A:=A*1609.344; // CONVERT ALT TO METERS
  V:=V*1609.344; // CONVERT VEL TO M/S

  WHILE A>0 DO  // while not yet landed
    PRINT(L +" : " +IP(A/1609.344) +"+" +IP(5280*FP(A/1609.344)) +" : " +IP((3600*(V/1609.344))) +" : " +(M-N) +" : ");
    INPUT(R);   // GET BURN RATE

    wait(R);    //  Result of current burn rate

    IF M-N>R*T THEN  // if fuel left      
      M:=M-(R*T);
    END;

    D:=(V*T+0.5*G*T^2);
    A:=A-D;
    V:=(V+G*T);
    L:=L+T;

  END;

  PRINT(L +" : " +IP(A/1609.344) +"+" +IP(5280*FP(A/1609.344)) +" : " +IP((3600*(V/1609.344))) +" : " +(M-N) +" : ");
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Rocket Game - from 101 BASIC Computer Games - DrD - 08-18-2015 12:14 PM



User(s) browsing this thread: 1 Guest(s)