Source code of 6.1.6 - Oblique shot |
10 CLS ' Clear the screen 11 CLEAR ' Delete the contents of all variables 12 DEFINT I-K, P 13 DEFLNG L 15 DEFSNG Q-Z 17 CONST CPI = 3.145933 18 CONST CGr = 9.806645 20 REM Than this number further starts the program code 25 SCREEN 0 30 INPUT "Enter the initial speed of the object:" v IF v = 0 OR v > 1500 THEN PRINT "Initial speed is not set limits" PRINT "Enter a value within the set!" SLEEP 5 CLS : GOTO 30 END IF 40 INPUT "Enter the value of the angle at which the object is ejected:" q IF q <= 0 OR q >= 90 THEN CLS PRINT "Angles less than 0 and greater than 90 do not make sense." PRINT "Enter a value within the set!" SLEEP 5 GOTO 40 ELSE CLS PRINT "Initial speed ejections are: " v, "m/s" PRINT "Angle value ejections of object is: " q, "degrees" Z = (q * CPI) / 180 Tm = (Z * v * SIN(Z)) / CGr MaxY = (v ^ 2 * (SIN(Z)) ^ 2) / (2 * CGr) MaxX = (v ^ 2 * (SIN(2 * Z))) / CGr PRINT PRINT "Maximum height of the object is: " MaxY; "m" PRINT "Oblique range shot is: " MaxX; "m" PRINT "Time of flight of the object is: " Tm; "sec" PRINT PRINT "Followed by drawing flight curve" SLEEP 5 END IF 800 GOSUB 1100 900 SLEEP 999 END ' Completion of the programming code 1000 REM Than this number further start sub-programs 1100 SCREEN 0 1150 CLS 1200 t = 0 1250 coeff = 5500 ' normalization of the size on the screen for largest x & y 1300 REM Back to the drawing x = v * t * COS(Z) y = v * t * SIN(Z) - (CGr * t ^ 2) / 2 px = x / coeff py = y / coeff IF py >= 23 OR py < 0 OR px < 0 OR px >= 79 THEN GOTO 2000 ELSE LOCATE (24 - py), (2 + px), 0: PRINT "*" END IF t = t + 1: GOTO 1300 2000 RETURN |
In this example uses a program structure for supervision on award of variables. Missing is the part that would supervise whether the letter is pressed instead of digits. This can be solved by using INKEY$ and control keys marked with numerals. Of course, that adds to the program but is more stable and robust. So for enhanced use always consult RTFM.
Mathematics calculating of oblique shot some effort but not a big problem in this linguistic processor prevents the characters from the display in the graphical display (SCREEN MOD), especially on the newer platforms. Therefore, it is used to display the curve character-mode, and the results had to be processed in a way that can be displayed in a field of 24×80 character with asterisks. What does normalization of results?
In this example, the individual command lines using the logical operators. But it should be borne in mind that the logical structure of type py >= 23 OR py <0 correct and 23 <= py <0 is not.
Citing of this page: Radic, Drago. " Informatics Alphabet " Split-Croatia. {Date of access}; https://informatics.buzdo.com/file. Copyright © by Drago Radic. All rights reserved. | Disclaimer |