mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-12-25 05:29:34 +00:00
ksp: have BASIC physics going
This commit is contained in:
parent
e5f2c1de1a
commit
4e74910bfc
@ -15,6 +15,9 @@ LAUNCH.BAS: launch.bas
|
||||
LOADING.BAS: loading.bas
|
||||
$(TXT2BAS) < loading.bas > LOADING.BAS
|
||||
|
||||
PHYSICS.BAS: physics.bas
|
||||
$(TXT2BAS) < physics.bas > PHYSICS.BAS
|
||||
|
||||
VAB.BAS: vab.bas
|
||||
$(TXT2BAS) < vab.bas > VAB.BAS
|
||||
|
||||
@ -23,6 +26,7 @@ VAB.BAS: vab.bas
|
||||
ksp.dsk: ACMPLX.BAS \
|
||||
LAUNCH.BAS \
|
||||
LOADING.BAS LOADING.HGR SQUAD.HGR TITLE.HGR \
|
||||
PHYSICS.BAS \
|
||||
VAB.BAS VAB.HGR
|
||||
$(DOS33) -y ksp.dsk SAVE B LOADING.HGR
|
||||
$(DOS33) -y ksp.dsk SAVE B SQUAD.HGR
|
||||
@ -32,6 +36,7 @@ ksp.dsk: ACMPLX.BAS \
|
||||
$(DOS33) -y ksp.dsk SAVE A LOADING.BAS
|
||||
$(DOS33) -y ksp.dsk SAVE A ACMPLX.BAS
|
||||
$(DOS33) -y ksp.dsk SAVE A LAUNCH.BAS
|
||||
$(DOS33) -y ksp.dsk SAVE A PHYSICS.BAS
|
||||
|
||||
|
||||
LOADING.HGR: loading.pcx
|
||||
|
@ -120,9 +120,10 @@ int main(int argc, char **argv) {
|
||||
|
||||
while(1) {
|
||||
|
||||
/* 4010 */
|
||||
fuel_left=fuel_mass*100.0/total_fuel;
|
||||
|
||||
thrusting=autopilot(fuel_left, rocket_altitude,&angle);
|
||||
thrusting=1;//autopilot(fuel_left, rocket_altitude,&angle);
|
||||
|
||||
if (thrusting) {
|
||||
if (fuel_mass<0.1) {
|
||||
@ -144,12 +145,15 @@ int main(int argc, char **argv) {
|
||||
rocket_acceleration_y=0.0;
|
||||
}
|
||||
|
||||
if (rocket_y<0) gravity_angle=PI+atan(rocket_x/rocket_y);
|
||||
else gravity_angle=atan(rocket_x/rocket_y);
|
||||
/* 4060 */
|
||||
gravity_angle=atan(rocket_x/rocket_y);
|
||||
if (rocket_y<0) gravity_angle+=PI;
|
||||
|
||||
/* 4070 */
|
||||
gravity_y=cos(gravity_angle)*gravity;
|
||||
gravity_x=sin(gravity_angle)*gravity;
|
||||
|
||||
/* 4080 */
|
||||
rocket_acceleration_y+=gravity_y;
|
||||
rocket_acceleration_x+=gravity_x;
|
||||
|
||||
@ -168,6 +172,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
rocket_altitude=vector_magnitude(rocket_x,rocket_y);
|
||||
|
||||
/* 5020 */
|
||||
|
||||
if (rocket_altitude<KERBIN_RADIUS) {
|
||||
if (rocket_velocity<20.0) {
|
||||
printf("LANDED!\n");
|
||||
@ -178,6 +184,7 @@ int main(int argc, char **argv) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* 5030 */
|
||||
/* Adjust gravity */
|
||||
gravity=-9.8/(
|
||||
((rocket_altitude)/KERBIN_RADIUS)*
|
||||
@ -188,13 +195,14 @@ int main(int argc, char **argv) {
|
||||
htabvtab(1,21);
|
||||
|
||||
printf("Time: %lf\n",time);
|
||||
printf("ALT: %lf m\tg=%lf\n",rocket_altitude-KERBIN_RADIUS,gravity);
|
||||
printf("ALT: %lf km\tg=%lf\n",(rocket_altitude-KERBIN_RADIUS)/1000.0,
|
||||
gravity);
|
||||
printf("VEL: %lf m/s\tStage: %d\n",
|
||||
rocket_velocity,
|
||||
stage);
|
||||
printf("ACCEL: %lf g\tFuel: %lf%%",
|
||||
vector_magnitude(rocket_acceleration_x,rocket_acceleration_y)/9.8,
|
||||
fuel_mass*100.0/total_fuel);
|
||||
fuel_left);
|
||||
|
||||
htabvtab(30,21);
|
||||
printf("ZURGTROYD");
|
||||
@ -212,8 +220,9 @@ int main(int argc, char **argv) {
|
||||
printf("x=%lf y=%lf\n",rocket_x,rocket_y);
|
||||
|
||||
htabvtab(20,11);
|
||||
printf("vx=%lf vy=%lf\n",rocket_velocity_x,
|
||||
rocket_velocity_y);
|
||||
printf("vx=%lf vy=%lf ax=%lf ay=%lf\n",
|
||||
rocket_velocity_x,rocket_velocity_y,
|
||||
rocket_acceleration_x,rocket_acceleration_y);
|
||||
htabvtab(20,10);
|
||||
printf("angle=%lf\n",angle);
|
||||
|
||||
|
69
ksp/physics.bas
Normal file
69
ksp/physics.bas
Normal file
@ -0,0 +1,69 @@
|
||||
3000 AN=0.785
|
||||
3001 CM=1
|
||||
3002 E=3
|
||||
3003 EI=270
|
||||
3004 EM=1.5*E
|
||||
3005 ET=168*E
|
||||
3006 T=6
|
||||
3007 KM=0.5*T
|
||||
3008 FM=4.0*T
|
||||
3009 TF=FM
|
||||
3010 FL=100
|
||||
3011 G=-9.8
|
||||
3012 GX=0:GY=-9.8:GA=0
|
||||
3013 V=0:VX=0:VY=0
|
||||
3014 AX=0:AY=0
|
||||
3015 KR=600000
|
||||
3016 RX=0:RY=KR+10
|
||||
3017 RA=KR
|
||||
3018 S=1:TH=1:T=0
|
||||
3020 TM=EM+KM+FM+CM
|
||||
3021 MT=TM-FM
|
||||
3022 DV=EI*G*LOG(TM/MT)
|
||||
3025 TW=ET/(TM*-G)
|
||||
3030 FR=ET/(EI*-G)
|
||||
3035 PRINT "DELTAV=";DV
|
||||
3040 PRINT "THRUST/WEIGHT=";TW
|
||||
3050 PRINT "FUEL FLOW RATE=";FR
|
||||
4000 REM
|
||||
4010 FL=FM*100/TF
|
||||
4020 IF TH<>1 THEN GOTO 4050
|
||||
4025 IF FM<0.1 THEN FM=0:AX=0:AY=0:GOTO 4050
|
||||
4030 AX=(ET/TM)*SIN(AN)
|
||||
4035 AY=(ET/TM)*COS(AN)
|
||||
4037 PRINT "ET=";ET;" TM=";TM
|
||||
4040 FM=FM-FR
|
||||
4045 TM=EM+KM+FM+CM
|
||||
4047 GOTO 4060
|
||||
4050 REM NOT THRUSTING
|
||||
4055 AX=0:AY=0
|
||||
4060 GA=ATN(RX/RY)
|
||||
4062 PRINT "GA=";GA;" AY=";AY
|
||||
4065 IF RY<0 THEN GA=GA+3.14
|
||||
4070 GY=COS(GA)*G
|
||||
4075 GX=SIN(GA)*G
|
||||
4080 AY=AY+GY
|
||||
4085 AX=AX+GX
|
||||
4090 ZX=VX
|
||||
4095 ZY=VY
|
||||
5000 VY=ZY+AY
|
||||
5005 VX=ZX+AX
|
||||
5010 V=SQR(VX*VX+VY*VY)
|
||||
5012 RY=RY+0.5*(ZY+VY)
|
||||
5014 RX=RX+0.5*(ZX+VX)
|
||||
5018 RA=SQR(RX*RX+RY*RY)
|
||||
5020 IF RA<KR THEN PRINT "CRASH": END
|
||||
5030 G=-9.8/((RA/KR)*(RA/KR))
|
||||
5035 PRINT "-------------------------"
|
||||
5040 PRINT "TIME: ";T
|
||||
5050 PRINT "ALT: ";(RA-KR)/1000;"KM","G ";G
|
||||
5060 PRINT "VEL: ";V;"M/S","STAGE: ";S
|
||||
5070 PRINT "ACCEL: ","FUEL: ";INT(FL);"%"
|
||||
5080 PRINT "GRAVANGLE ";GA*180/3.14
|
||||
5090 PRINT "X: ";RX;" Y: ";RY
|
||||
5100 PRINT "VX: ";VX;" VY: ";VY
|
||||
5110 PRINT "ANGLE: ";AN
|
||||
5112 PRINT "AX: ";AX;"AY: ";AY
|
||||
5118 T=T+1
|
||||
5120 REM GET A$:IF A$="Q" THEN END
|
||||
5130 GOTO 4000
|
Loading…
Reference in New Issue
Block a user