From 4e74910bfc091d876c9d2a7e5706be144faee84b Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 25 May 2016 16:27:32 -0400 Subject: [PATCH] ksp: have BASIC physics going --- ksp/Makefile | 5 ++++ ksp/c/ksp_launch.c | 23 +++++++++++----- ksp/physics.bas | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 7 deletions(-) create mode 100644 ksp/physics.bas diff --git a/ksp/Makefile b/ksp/Makefile index 629aa010..deb12204 100644 --- a/ksp/Makefile +++ b/ksp/Makefile @@ -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 diff --git a/ksp/c/ksp_launch.c b/ksp/c/ksp_launch.c index 987f929c..55805387 100644 --- a/ksp/c/ksp_launch.c +++ b/ksp/c/ksp_launch.c @@ -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