here is a moon lander game. movement, crashing, fuel count, and gravity all work. i need 3-5 landing pads, a way to 'refuel' at those landing pads, a way to pause when you touch a landing pad so you dont fly right through it and crash, and a way to count scores... THE FIRST PERSON TO MAKE A FEASIBLE, WORKING OPTIMIZATION GETS THERE NAME IN THE CREDITS!!!!!!


Code:
:31→Z
:47→X
:1→W
:100→G
:Lbl 1
:If Z≤7 and Z≥0:Text(34,47,"CRASH!"
:If Z≤7 and Z≥0:Stop
:If G≤0:0→G
:W+.5→W
:Z-W→Z
:Horizontal(0
:Text(1,1,"FUEL:"
:Text(1,20,G
:Line(X-1,Z,X+1,Z
:Line(X-2,Z-1,X+2,Z-1
:Line(X-1,Z-2,X+1,Z-2
:Line(X-2,Z-3,X-2,Z-4
:Line(X+2,Z-3,X+2,Z-4
:Line(X,Z-3,X,Z-3
:If G≥1:Goto 2
:If G≤0:Goto 1
:Lbl 2
:If K=34:Line(X,Z-5,X,Z-6
:getKey→K
:If K=24:X+2→X:Z+.5→Z
:If K=34:Z+3→Z
:If K=34:W-1.25→W
:If K=26:X-2→X:Z+.5→Z
:If K=34:Line(X,Z-5,X,Z-6
:If K=34:G-1→G
:ClrDraw
:Goto 1
instead of using labels to loop why dont you use a for() or while/repeat loop?
Repeat would probably be best in this situation.
^++ I second the notion of loops, etc. (not to mention that "If Condition1:Statement1:If Condition1:Statement2" can be condensed to "If Condition1:Then:Statement1:Statement2:End"). We can always help on that.
After that's done so it's more readable, I might help Smile
rcplanegy, are you sure this program works as is? I put it on my calculator, and it doesn't seem to work almost at all.
qazz42 wrote:
instead of using labels to loop why dont you use a for() or while/repeat loop?
His use of Labels is fine. There's nothing wrong with labels in a program this small and when they are used correctly.
comicIDIOT wrote:
qazz42 wrote:
instead of using labels to loop why dont you use a for() or while/repeat loop?
His use of Labels is fine. There's nothing wrong with labels in a program this small and when they are used correctly.

It's not whether or not they're correct, it's that he wants it optimized, and there are better ways than what he's doing here with labels.
comicIDIOT wrote:
qazz42 wrote:
instead of using labels to loop why dont you use a for() or while/repeat loop?
His use of Labels is fine. There's nothing wrong with labels in a program this small and when they are used correctly.



yes, but he is asking for optimizations and frankly , loops are a bit faster....

(also, made the first optimization so credits Very Happy)
qazz42 wrote:
(also, made the first optimization so credits Very Happy)
Not so.

Quote:
THE FIRST PERSON TO MAKE A FEASIBLE, WORKING OPTIMIZATION GETS THERE NAME IN THE CREDITS!!!!!!
By working, he needs landing pads that pause the game (more than the Pause token), landing pads, a way to count scores, and a method to refuel while landed.

You did none of those Razz

Not to mention you didn't optimize anything. How would you get rid of the labels and add the loops? Share some optimized code with us, rather than suggesting.
qazz, you didn't actually change any code.

This is what an optimization looks like:

Code:

:0→Xmin
:1→ΔX
:0→Ymin
:1→ΔY
:E2→F
:31→D
:Ans→E
:47→O
:Ans→P
:DelVar HDelvar VClrDraw
:Repeat D≤.5
:Text(0,1,"FUEL: ",F,"   
:Pt-Off(P,E+1,3
:Pt-Off(P,E,2
:Pt-On(O,D+2
:Pt-On(O,D,2
:Pt-Off(O,D-1,3
:Horizontal(0
:getKey→G
:D→E
:O→P
:If F and max(G={24,25,26,34
:Then
:H-2(G=34)+2(G=25→H
:V+2(G=26)-2(G=24→V
:F-1→F
:End
:H-1→H
:D+HE‾2→D
:O+VE‾2→O
:End
:Pt-Off(O,2,2
:Pt-Off(O,3,2
:40≥√(H2+V2
:Pt-On(O,1,3-Ans
:Pt-On(O,2+Ans
:Text(6,1,sub("CRASHED!SAFE!",1+8Ans,8-3Ans
:Pause

Haven't added anything that wasn't already in the game, but it's smaller now, and has safe/crashed landing.
Why don't you use the SourceCoder optimizer?

http://sc.cemetech.net
It's not that kind of optimizer Razz
To my knowledge it does little more than removing closing parentheses/etc. and using Delvar.
Correct me if I'm wrong Smile
comicIDIOT wrote:
qazz42 wrote:
(also, made the first optimization so credits Very Happy)
Not so.

Quote:
THE FIRST PERSON TO MAKE A FEASIBLE, WORKING OPTIMIZATION GETS THERE NAME IN THE CREDITS!!!!!!
By working, he needs landing pads that pause the game (more than the Pause token), landing pads, a way to count scores, and a method to refuel while landed.

You did none of those Razz

Not to mention you didn't optimize anything. How would you get rid of the labels and add the loops? Share some optimized code with us, rather than suggesting.


hmm, bah, good point x.x

unfortunetly, the TI-Basic part of my brain is not functioning, but I will tell you what I come up with later if I get the time >.>
calcdude84se wrote:
It's not that kind of optimizer Razz
To my knowledge it does little more than removing closing parentheses/etc. and using Delvar.
Correct me if I'm wrong Smile
That's correct. There is a topic in the SourceCoder subforum about why its optimizer works the way it does, actually, and a call for suggestions and code from people who want to make it smarter. At rcplanegy, I recommend you work through your program piece by piece, add functionality one thing at a time (ie, first the craft movement, then drawing the pads, etc etc), and present each of the pieces of code to us to optimize. Therefore, after we finish helping you with this, I recommend that you try to add your extra features that you suggested, and present that code to us, rather than asking us to write the extra features for you. Smile
KermMartian wrote:
calcdude84se wrote:
It's not that kind of optimizer :P
To my knowledge it does little more than removing closing parentheses/etc. and using Delvar.
Correct me if I'm wrong :)
That's correct. There is a topic in the SourceCoder subforum about why its optimizer works the way it does, actually, and a call for suggestions and code from people who want to make it smarter. At rcplanegy, I recommend you work through your program piece by piece, add functionality one thing at a time (ie, first the craft movement, then drawing the pads, etc etc), and present each of the pieces of code to us to optimize. Therefore, after we finish helping you with this, I recommend that you try to add your extra features that you suggested, and present that code to us, rather than asking us to write the extra features for you. :)

Kerm++

Huge reason why I didn't add any functionality to the optimized program I made.

Besides, most people aren't going to go through those sorts of hoops if you're rewarding them a spot in the credits for a game they made.
also, one thing I would like to point out is not to use stop, it is considered bad programming style. Use return instead...

just to say that it can sometimes mess up a shell's parser
qazz42 wrote:
also, one thing I would like to point out is not to use stop, it is considered bad programming style. Use return instead...

just to say that it can sometimes mess up a shell's parser
An excellent point, qazz42. As of Doors CS 7, DCS successfully catches and mitigates the problems associated with Stop, but if you disable the library support, use a competitor shell, or use DCS 6.2 or earlier, Stop can cause problems.
Yikes, the lib support option also combats the stop crappyness? Weird... I would think it to be the parser hook...

anywho, I remember I crashed many calcs a day using stop with mirageOS
qazz42 wrote:
Yikes, the lib support option also combats the stop crappyness? Weird... I would think it to be the parser hook...

anywho, I remember I crashed many calcs a day using stop with mirageOS
I understand your confusion, let me clarify. The Parser Hook, aka HomeRun, is one parser hook: it catches program executions at the homescreen. That's all. Enabling/disabling third-party hybrid library support makes a different parser hook be enabled while a program is actually executing; that hook looks for real(, sum(, det(, and identity. I made it also watch for Stop, and if it is about to run it, throw a special type of TI-OS error code that Doors CS then catches and handles as a clean exit instead of letting the OS deal with it.
hmm, I get it, seems fair enough Very Happy

also, one more thing, the waiy you have

:If G≥1:Goto 2
:If G≤0:Goto 1

would be easier to read if it said

:If G≥1
:Goto 2
:If G≤0
:Goto 1

it just makes it a bit more understandable and easier on the eyes
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement