So I've made a program that inverses the graph screen, but it is very slow. I was wondering if anyone would be willing to look at the code (it's not very long), optimize it, and explain why you did that? Thank you in advance!

Code:
ClrDraw
DelVar ADelVarBRepeat A=62 and B=95
Pxl-Change(A,B
B+1→B
If B=95 and A≠62
DelVar BA+1→A
End
prgmSHOOT

Code:
AxesOff
DelVarSDelvarFClrDraw
0→Xmin
47→Xmax
0→Ymin
31→Ymax
23→P
Lbl 4
ClrHome
Disp "RANDOM=0
Input "SPEED(200-1):",J
If (J<1 and J≠0) or J>200
Goto 4
ClrHome
If J=0
randInt(1,200→J
Lbl 1
ClrDraw
DelVarA47→H
randInt(3,44→T
Repeat T=P and H=0
Pt-On(T,H,2
Pt-On(P,0,3
Text(25,0,2
Text(33,0,1
Line(0,15,2,15
Line(47,15,45,15
getKey→D
Pt-Off(P,0,3
If F=1
Text(-1,6,0,"x
If F=2
Then
Text(-1,6,0,"x
Text(-1,6,8,"x
End
If F=3
Then
Text(0,0,S
Text(-1,6,0,"x
Text(-1,6,8,"x
For(L,1,5
DelVarKText(-1,6,16,"     " // 5 spaces, I left out the end quotation mark
For(K,1,60
End
End
ClrDraw
ClrHome
Disp "YOU LOSE!","FINAL SCORE:
Output(2,13,S
Stop
End
If D=21 or D=25
Then
Repeat (P=T and A=H) or A=32
Pt-On(P,A
For(O,1,20
End
A+1→A
Pt-Off(P,A-2
If P=T and A=H and A≤15
Then
Text(0,75,"HIT!
Text(6,65,"+1 POINT
Pt-Off(P,A,2
Pt-Off(P,A,3
Pt-On(P,A,3
For(L,1,350
End
S+1→S
Goto 1
If P=T and A=H and A≥15
Then
Text(0,75,"HIT!
Text(6,61,"+2 POINTS
Pt-Off(P,A,2
Pt-Off(P,A,3
Pt-On(P,A,3
For(L,1,350
End
S+2→S
Goto 1
End
If P≠T and A>H
Then
Lbl 3
Text(0,68,"MISSED!
F+1→F
For(L,1,350
End
Goto 1
End
If A=32
Then
ClrDraw
Goto 3
End
End
End
P-(D=24 and P≠2)+(D=26 and P≠45)→P
Pt-On(P,0,3
For(K,1,JEnd
Pt-Off(T,H,c
H-1→H
If P≠T and H=0
Then
F+1→F
Goto 1
End
Text(0,0,S
If D=22
Then
ClrDraw
AxesOn
ClrHome
Disp "FINAL SCORE:
Output(1,13,S
Stop
End
If D=23
Pause
If D=31
prgmSMENU
End
Goto 1


I'll do the subcode on another post so you can start this one.
gaventemples31415 wrote:
So I've made a program that inverses the graph screen, but it is very slow. I was wondering if anyone would be willing to look at the code (it's not very long), optimize it, and explain why you did that? Thank you in advance!

Code:
ClrDraw
DelVar ADelVarBRepeat A=62 and B=95
Pxl-Change(A,B
B+1→B
If B=95 and A≠62
DelVar BA+1→A
End


Code:
ClrDraw
For(A,0,62
For(B,0,94
Pxl-Change(A,B
End
End
If you're using ClrDraw.. Are you just wanting to have a black screen? Just use the Shade( command, or loop a Line( command to fill it to black.
No, that's to get rid of any other pixels on the screen. It's just fun to change your graphs and axes to white and background to black. That's why I use Pxl-Change( instead of one of those. Thanks though!
  
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 1
» 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