I was bored on a Sunday morning, so I decided to make a flappy bird program. I was following a tutorial because I don't know how to use the graph screen (yet). However, I came upon a bug in the collision detection, and I can't find where it is. As soon as the game loop begins, the program detects the "Bird" on top of its self and ends the program.

Code:

PlotsOff
FnOff
GridOff
AxesOff
0->Xmin
264->Xmax
0->Ymin
164->Ymax
ClrDraw
0->S
Lbl P
For(I,1,4
   randInt(80,134)->R
   For(J,1,26)
      60I+J->A
      Line(A,164,A,R,14)
      Line(A,R-45,A,0,14)
End:End
17->X
82->Y
4->W
X->P
Y->Q
Pt-On(X,Y,2,19)
Pt-On(X,Y,1,11)
getKey->K
Repeat K=105 or K=25
   getKey->K
   If K=22:Return
End
"GAME LOOP
Repeat K=22
   getKey->K
   If K=105 or K=25:12->W
   W-3->W
   X+4->X
   Y+W->Y
   If Y<0 or Y>164
   Goto GO
   Pt-Off(P,Q,2)
   Pt-Off(P,Q,1)
   Pt-On(X,Y,2,19)
   Pt-On(X,Y,1,11)
   If pxl-Test(164-Y,X)
   Goto GO
   X->P:Y->Q
   If X=85 or X=145 or X=205 or X>259
   Then
      S+1->S
      Text(0,1220S
      If X>259
      Goto P
   End
   
   Lbl GO
   Pt-On(X,Y,2,19)
   Pt-On(X,Y,1,11)
   TextColor(11)
   Text(70,100," GAME OVER
   Text(84,100," SCORE:            "
   Text(84,150,S
   Pause
End

I am really new to all of this, so a pointer would be appreciated.
I attempted to fix your code, here is the result of a bit less than 2 hours of tweaking:

Code:

PlotsOff
FnOff
GridOff
AxesOff
0->Xmin
264->Xmax
0->Ymin
164->Ymax
0->S
Lbl P
0->F
ClrDraw
For(I,1,4
   randInt(80,134)->R
   For(J,1,26)
      60I+J->A
      Line(A,164,A,R,14)
      Line(A,R-45,A,0,14)
End:End
17->X
82->Y
4->W
X->P
Y->Q
Pt-On(X,Y,2,18)
Pt-On(X,Y,1,11)
getKey->K
Repeat K=105 or K=25
   getKey->K
   If K=22:Return
End

Repeat K=22 or F
   getKey->K
   If K=105 or K=25:12->W
   W-3->W
   X+4->X
   Y+W->Y
   If Y<0 or Y>164
   22->K
   Pt-Off(P,Q,2)
   Pt-Off(P,Q,1)
   Pt-On(X,Y,2,18)
   Pt-On(X,Y,1,11)
   If pxl-Test(164(Y<=8)+(172-Y)(Y>8),X) or pxl-Test((156-Y)(Y<=156),X)
   22->K
   X->P:Y->Q
   If X=85 or X=145 or X=205 or X>259
   Then
      S+1->S
      Text(0,12,S
      If X>259:1->F
   End
End
If F:Goto P
Pt-On(X,Y,2,18)
Pt-On(X,Y,1,11)
TextColor(11)
Text(70,100," GAME OVER
Text(84,100," SCORE:            "
Text(84,150,S


It more or less works, so far, but it's a big improvement from what you originally had. The program in your original post wouldn't even run properly because you had your GAME OVER menu showing up immediately and the Pause command was in the main loop. So, I took it out of the main loop, and placed it at the very end of the program.

I changed the color of the bird from yellow to blue, for my sake (don't mind that). I also attempted to fix handling whether you have crashed into a pipe or not. And I fixed a memory leak you had with going to Label P - I instead implemented a flag variable which will tell the main loop to exit before jumping back to the label.

I know it's not perfect, but that's what I had time for. Hopefully you can figure out the rest! Good job on this by the way - once I got it working it was pretty fun to play. If you have any questions let me know.
Can these calculators even run TI-BASIC Programs fast enough to make them decently enjoyable?
Depends what you call enjoyable.
jcgter777 wrote:
Depends what you call enjoyable.


I mean, without like the screen flashing each time the screen refreshes. I firmly believe asm is much better than BASIC for games, but if he \ she can make it work well, it will be very, very impressive,
  
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