MateoC (on SAX) wrote:
5:27:20PM [#] [MateoC] If you post code people would be happy to suggest optimizations
5:27:23PM [#] *MateoC hided
So I'm going to ask for suggestion
Also, I'm still not sure how to do the physics of this. (I'm taking physics and calculus next year)
Or download the programs link removed
Outdated code
prgmCSP
Code: "Setup
ClrHome
Disp "CSP","Loading..."
"DECLARATIONS
"Misc-------------------
"Lists------------------
:"WORLD Chell
:"1 is mass
SetUpEditor ⌊CHELL
1→dim(⌊CHELL
1000→⌊CHELL(1)
SetUpEditor ⌊CSP11
5→dim(⌊CSP11
SetUpEditor ⌊CSP12
5→dim(⌊CSP12
SetUpEditor ⌊CSP13
5→dim(⌊CSP13
SetUpEditor ⌊CSP14
5→dim(⌊CSP14
SetUpEditor ⌊CSP15
5→dim(⌊CSP15
SetUpEditor ⌊CSP21
5→dim(⌊CSP11
SetUpEditor ⌊CSP22
5→dim(⌊CSP12
SetUpEditor ⌊CSP23
5→dim(⌊CSP13
SetUpEditor ⌊CSP24
5→dim(⌊CSP14
SetUpEditor ⌊CSP25
5→dim(⌊CSP15
SetUpEditor ⌊CSP31
5→dim(⌊CSP11
SetUpEditor ⌊CSP32
5→dim(⌊CSP12
SetUpEditor ⌊CSP33
5→dim(⌊CSP13
SetUpEditor ⌊CSP34
5→dim(⌊CSP14
SetUpEditor ⌊CSP35
5→dim(⌊CSP15
"Matrices---------------
:{5,5}→dim([B])
:"SETS UP MATRIX B (vab)
"Strings----------------
:"P/S| Fuel| Engn| Aero| -> →Str0
:"USED AS PARTS
::"→Str1
"Variables--------------
:"A for altitude
:"C is colum SEE R
1→C
:"D for direction
:"F IS FUEL
0→F
:"I IS PART ID
0→I
:"K is the getkey
0→K
:"M IS MASS
0→M
:"P is planet mass [zlaunch]
0→P
:"R is row SEE C
1→R
:"T IS THRUST
0→T
:"U untill empty(fuel consumed per second)
0→U
:"XY ARE PART CORDINATES
1→X
1→Y
"N and S are previous part coordinates
1→N
1→S
"
ClrHome
Output(2,12,"CSP
Output(9,23,"B.12
Output(10,23,"v.01
Pause
ClrHome
Disp " _____","| |","|/ / /|","|| | ||","|| | ||","|\ \ \|","|_____|"," VAB
Pause
ClrHome
"CLEARS MATRIX B
For(R,1,5
For(C,1,5
1→[B](R,C)
End
End
"PRINTS OUT GRID and ship
Lbl 1
Float
ClrHome
"prints out coordinates
For(X,1,5,1
Output(2,X+9,X
End
For(Y,1,5,1
Output(Y+2,9,Y
End
"Prints out ship
"NEEDS OPTIMIZATION--
For(X,10,14,1
For(Y,3,7,1
If [B](Y-2,X-9)=1
Output(Y,X,"·
If [B](Y-2,X-9)=2
Output(Y,X,"▫
If [B](Y-2,X-9)=3
Output(Y,X,"Ŝ
If [B](Y-2,X-9)=4
Output(Y,X,"^
If [B](Y-2,X-9)=5
Output(Y,X,"/
If [B](Y-2,X-9)=6
Output(Y,X,"\
End
End
"---------------------
Output(9,1,"Mass
Output(9,6,M
Output(10,1,"Prt| <- |Sv/Ld|Launch|Ext"
0→K
Lbl W2
getKey→K
If K≠0
"P FOR PARTS
If K=11
Goto P
"Undo
If K=12
Goto U
"Save/Load
If K=13
Goto R
"LAUNCH
If K=14
Goto L
"EXITS
If K=15
Goto E
If K>15
Goto W2
Goto W2
Lbl P
ClrHome
Output(10,1,Str0
getKey→K
If K≠15 or K≠0
prgmZPARTS
ClrHome
"checks to continue or not
If X=1
Goto 1
"Part movement setup
1→X
1→Y
"since X and Y were taken
1→S
1→N
"Coordinates
For(X,1,5,1
Output(2,X+9,X
End
For(Y,1,5,1
Output(Y+2,9,Y
End
"Prints out ship
"NEEDS OPTIMIZATION--
For(X,10,14,1
For(Y,3,7,1
If [B](Y-2,X-9)=1
Output(Y,X,"·
If [B](Y-2,X-9)=2
Output(Y,X,"▫
If [B](Y-2,X-9)=3
Output(Y,X,"Ŝ
If [B](Y-2,X-9)=4
Output(Y,X,"^
If [B](Y-2,X-9)=5
Output(Y,X,"/
If [B](Y-2,X-9)=6
Output(Y,X,"\
End
End
"--------------------
"makes it store correct part
Lbl W1
If I=2
"▫→Str1
If I=3
"Ŝ→Str1
If I=4
"^→Str1
If I=5
"/→Str1
If I=6
"\→Str1
"Part movement
0→K
Repeat abs(Ans-63)=42
While [B](S,N)≠1
1+S→S
If Y=5
N+1→N
End
Output(Y+2,X+9,"·
S→Y
N→X
Output(S+2,N+9,Str1
getKey→K
If Ans=24 and N-1≥1
N-1→N
If Ans=25 and S-1≥1
S-1→S
If Ans=26 and 5≥N+1
N+1→N
If Ans=34 and 5≥S+1
S+1→S
End
"stores ID in correct place on list
I→[B](S,N)
Goto 1
"Undo
Lbl U
1→[B](S,N)
Goto 1
"Save/load
Lbl R
ClrHome
Menu("Save/Load","Save",S,"Load",R1,"Back",1
Lbl R1
Menu("Load","Save Slot 1",R2,"Save Slot 2",R3,"Save Slot 3",R4,"Back",1
Lbl R2
Listmatr(⌊CSP11,⌊CSP12,⌊CSP13,⌊CSP14,⌊CSP15,[B]
For(X,10,14,1
For(Y,3,7,1
If [B](Y-2,X-9)=3
Then
150→F
200+M→M
Else
End
If [B](Y-2,X-9)=4
Then
300+M→M
5000+T→T
5+U→U
Else
End
If [B](Y-2,X-9)=5
End
If [B](Y-2,X-9)=6
End
End
End
Disp "Loaded!"
Pause
Goto 1
Lbl R3
Listmatr(⌊CSP21,⌊CSP22,⌊CSP23,⌊CSP24,⌊CSP25,[B]
For(X,10,14,1
For(Y,3,7,1
If [B](Y-2,X-9)=3
Then
150→F
200+M→M
Else
End
If [B](Y-2,X-9)=4
Then
300+M→M
5000+T→T
5+U→U
Else
End
If [B](Y-2,X-9)=5
End
If [B](Y-2,X-9)=6
End
End
End
Disp "Loaded!"
Pause
Goto 1
Lbl R4
Listmatr(⌊CSP31,⌊CSP32,⌊CSP33,⌊CSP34,⌊CSP35,[B]
For(X,10,14,1
For(Y,3,7,1
If [B](Y-2,X-9)=3
Then
150→F
200+M→M
Else
End
If [B](Y-2,X-9)=4
Then
300+M→M
5000+T→T
5+U→U
Else
End
If [B](Y-2,X-9)=5
End
If [B](Y-2,X-9)=6
End
End
End
Disp "Loaded!"
Pause
Goto 1
Lbl S
Menu("Save to","Save Slot 1",S1,"Save Slot 2",S2,"Save Slot 3",S3,"Back",1
Lbl S1
Matrlist([B],⌊CSP11,⌊CSP12,⌊CSP13,⌊CSP14,⌊CSP15
Disp "Saved!"
Pause
Goto 1
Lbl S2
Matrlist([B],⌊CSP21,⌊CSP22,⌊CSP23,⌊CSP24,⌊CSP25
Disp "Saved!"
Pause
Goto 1
Lbl S3
Matrlist([B],⌊CSP31,⌊CSP32,⌊CSP33,⌊CSP34,⌊CSP35
Disp "Saved!"
Pause
Goto 1
"LAUNCH
Lbl L
prgmZLAUNCH
If A=1
Goto 1
Lbl E
Disp "QUITTING...
DelVar L₁
DelVar L₂
DelVar L₃
DelVar L₄
DelVar L₅
Archive ⌊CHELL
Archive ⌊CSP11
Archive ⌊CSP12
Archive ⌊CSP13
Archive ⌊CSP14
Archive ⌊CSP15
Archive ⌊CSP21
Archive ⌊CSP22
Archive ⌊CSP23
Archive ⌊CSP24
Archive ⌊CSP25
Archive ⌊CSP31
Archive ⌊CSP32
Archive ⌊CSP33
Archive ⌊CSP34
Archive ⌊CSP35
"→Str1
"→Str2
"→Str3
"→Str4
"→Str5
Float
"END!
prgmZPARTS
Code: Lbl 0
ClrHome
"P/S| Fuel| Engn| Aero| -> →Str0
Output(10,1,Str0
0→K
Repeat K≠0
getKey→K
End
"GOTO POD
If K=11
Goto P
"GOTO FUEL
If K=12
Goto F
"GOTO ENGINE
If K=13
Goto E
"GOTO AERO
If K=14
Goto A
"EXIT
If K=15
Goto 98
"POD MENU
Lbl P
Menu("PODS","▫ Mk.1",P1,"BACK",0
Lbl P1
ClrHome
Disp "STATS:","MASS=2"
Output(10,1,"Continue Back"
Repeat max(K={11,12,15
getKey→K
End
If K=11 or K=12
2→I
If K=15
Goto 0
Goto 99
Lbl F
Menu("Fuel","Ŝ Mk.1",F1,"BACK",0
"Mk.1
Lbl F1
ClrHome
Disp "Stats:","Lf=150","Mass=200
Output(10,1,"Continue Back"
Repeat max(K={11,12,15
getKey→K
End
If K=11 or K=12
3→I
If K=15
Goto 0
Goto 99
Lbl E
Menu("Engines","^ Mk.1",E1,"BACK",0
Lbl E1
"^
ClrHome
Disp "Stats:","Thrust=2.5kN","Mass=300","5FpS
Output(10,1,"Continue Back"
Repeat max(K={11,12,15
getKey→K
End
If K=11 or K=12
4→I
If K=15
Goto 0
Goto 99
Lbl A
Menu("Aerodynamics","/ Mk.1 LEFT",A1,"\ Mk.1 RIGHT",A2,"Back",0
Lbl A1
"/
ClrHome
Disp "Stats:","LEFT","Stability= +1","Mass=.5"
Output(10,1,"Continue Back"
Repeat max(K={11,12,15
getKey→K
End
If K=11 or K=12
5→I
End
If K=15
Goto 0
Goto 99
Lbl A2
"\
ClrHome
Disp "Stats:","RIGHT","Stability= +1","Mass=.5"
Output(10,1,"Continue Back"
Repeat max(K={11,12,15
getKey→K
End
If K=11 or K=12
6→I
End
If K=15
Goto 0
Goto 99
"returns so you DONT move a part
Lbl 98
1→X
Return
"returns so you can move the part
Lbl 99
0→X
Return
prgmZLAUNCH
Code: "Prelaunch setup
ClrHome
Output(5,9,"Loading...
:SetUpEditor L₁
:7→dim(L₁)
:SetUpEditor L₂
:7→dim(L₂)
:SetUpEditor L₃
:7→dim(L₃)
:SetUpEditor L₄
:7→dim(L₄)
:SetUpEditor L₅
:7→dim(L₅)
"load variables
:"A for altitude
1→A
:"B for accelleration (bad var)
:"D for direction or tilt of craft
0→D
:"K is getKey
0→K
:"M is rocket Mass
:"S is speed
0→S
:"T is thrust
0→T
:"U is FpS
0→U
:"V is verifacation +1 per correct part
0→V
:"postion of ship
16→X
5→Y
"Load HUD strings
"Altitude-< >-→Str0
"get matrix into lists
Output(6,5,"Matrix to list
Matrlist([B],L₁,L₂,L₃,L₄,L₅
"verifys all needed parts are present
Output(6,5," Verifying...
If inString(toString([B]),"2"
Then
1+V→V
Else
Disp "Error","No pod!"
Pause
ClrHome
Return
End
If inString(toString([B]),"3"
Then
1+V→V
Else
Disp "Error","No fuel!"
Pause
ClrHome
Return
End
If inString(toString([B]),"4"
Then
1+V→V
Else
Disp "Error","No engine!"
Pause
ClrHome
Return
End
"loads ship parts
Output(6,5," Loading parts
For(X,10,14,1
For(Y,3,7,1
If [B](Y-2,X-9)=3
Then
150→F
200+M→M
5+U→U
Else
End
If [B](Y-2,X-9)=4
Then
300+M→M
2500+T→T
5+U→U
Else
End
If [B](Y-2,X-9)=5
Then
"No stability in this version
"1+S→S
End
If [B](Y-2,X-9)=6
Then
"No stability in this version
"1+S→S
End
End
End
"get lists to a string
Output(6,5,"List to string
:"?
:For(X,1,dim(L₁
:Ans+sub(" ▫Ŝ^/\",L₁(X),1
:End
:sub(Ans,2,length(Ans)-1→Str1
:"?
:For(X,1,dim(L₂
:Ans+sub(" ▫Ŝ^/\",L₂(X),1
:End
:sub(Ans,2,length(Ans)-1→Str2
:"?
:For(X,1,dim(L₃
:Ans+sub(" ▫Ŝ^/\",L₃(X),1
:End
:sub(Ans,2,length(Ans)-1→Str3
:"?
:For(X,1,dim(L₄
:Ans+sub(" ▫Ŝ^/\",L₄(X),1
:End
:sub(Ans,2,length(Ans)-1→Str4
:"?
:For(X,1,dim(L₅
:Ans+sub(" ▫Ŝ^/\",L₅(X),1
:End
:sub(Ans,2,length(Ans)-1→Str5
"calcs thrust (planet mass + rocket Mass)
Output(6,4," Thrust
If inString(toString(T),""
T*-1→T
T-(⌊CHELL(1)+M)→T
ClrHome
"outputs HUD
Output(1,1,Str0
Output(1,12,A
"Speed
Output(2,10,"MpS
Output(2,13,"0
"Fuel
Output(8,1,"Fuel
Output(9,1,F
Output(6,23,"___
Output(6,23,D
Output(6,26,"°
Output(7,22,"/ \
Output(8,22,"| |
Output(9,22,"\___/
"REASSIGNED CUZ OF FOR( LOOP
5→Y
"outputs final ship-----------
Output(2,1,"[ENTER!]
Output(Y,X,Str1
Output(Y+1,X,Str2
Output(Y+2,X,Str3
Output(Y+3,X,Str4
Output(Y+4,X,Str5
Pause
Output(2,1,"LAUNCH!
Output(2,1,"
"Just looks neat
Y-1→Y
Output(Y,X,Str1
Output(Y+1,X,Str2
Output(Y+2,X,Str3
Output(Y+3,X,Str4
Output(Y+4,X,Str5
Output(9,8,"
Fix 2
"Actuall Launch--------------------
Lbl 0
0→K
"Flight end checker
" If clear is pressed or if Altitude is less than 0
Repeat K=45 or A<0
getKey→K
"Fuel and thrust check
If F<0
Then
0→U
T*1→T
0→F
"Just looks neat
Y+1→Y
"Domain error######
Output(Y,X,Str1
Output(Y+1,X,Str2
Output(Y+2,X,Str3
Output(Y+3,X,Str4
Output(Y+4,X,Str5
End
"Calculations___________________
"accelleration
T/M→B
"momentum
M*B→S
"simple calc for altitude
A+S→A
"Fuel depletion
F-U→F
Output(1,1,Str0
"displayes altitude
Output(1,12,A
"Displayes speed/ aceleration
Output(2,13,S
"Disp fuel
Output(9,1,F
End
Pause
Menu("Options","Resume",0,"Revert to VAB",98,"Quit",99
Lbl 98
"so it'll go to VAB
1→A
Return
Lbl 99
"so it'll quit
0→A
Return
Sorry about the double posting, I thought my post would look cleaner if I just made a new one.
Anyways, any suggestions would be nice, I feel like I'm at a good spot to make major changes to the code without messing everything up.