Advertisement
Guest User

Asteroid for TI84+

a guest
Feb 11th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. 15->W //speed of asteroids - set to a factor of 150
  2. ClrHome
  3. 2->X //player X
  4. 5->Y //player Y
  5. 3->L //starting live #
  6. 0->S //resets score
  7. ">"->Str1 //player sprite
  8. "*"->Str2 //asteroid sprite
  9. 16-round(0/10,0)->R //sets initial asteroid X posistion
  10. randInt(2,8)->E //sets initial asteroid Y posistion
  11. getKey->K
  12. 0->N //resets loop variable
  13. Repeat K=45 or L<=0
  14. If Y=E and X=R //collision for player and asteroid
  15. Then
  16. 0->N
  17. randInt(2,8)->E
  18. S+1->S //increases score
  19. End
  20. E->Q //stores asteroid Y pos before it is set for the frame
  21. If N>=150 //resets loop once it is 150 (touches the left of the screen)
  22. Then
  23. 0->N
  24. randInt(2,8)->E
  25. L-1->L
  26. End
  27. getKey->K
  28. Y->F //stores player Y pos before it is set for the frame
  29. If K!=0 //key detection 25 is up 34 is down (sets player Y)
  30. Then
  31. If K=25
  32. Then
  33. If Y>2
  34. Then
  35. Y-1->Y
  36. End
  37. Else
  38. If K=34
  39. Then
  40. If Y<8
  41. Then
  42. Y+1->Y
  43. End
  44. End
  45. End
  46. End
  47. N+W->N //increases loop by speed (W)
  48. R->O //sets asteroid X pos before it is set for the frame
  49. 16-round(N/10,0)->R //sets asteroid X posistion
  50. If O!=R or F!=Y or Q!=E //checks for any changes in posistion from the last frame
  51. Then
  52. If Q!=E
  53. Then
  54. Output(Q,O," ") //clears old asteroid posistion when it reaches the end
  55. End
  56. If O!=R
  57. Then
  58. Output(E,O," ") //clears old asteroid posistion
  59. End
  60. If F!=Y
  61. Then
  62. Output(F,X," ") //clears old player posistion
  63. End
  64. Output(Y,X,Str1)
  65. Output(E,R,Str2)
  66. For(I,1,3) //displays lives
  67. If I<=L
  68. Then
  69. Output(1,I+1,Str1)
  70. Output(1,L+2," ")
  71. Output(1,L+3," ")
  72. End
  73. End
  74. Output(1,14,S) //displays score
  75. End
  76. End
  77. ClrHome
  78. Output(4,4,"GAME OVER") //game over screen
  79. Output(3,5,"SCORE=")
  80. Output(3,11,S)
  81. " //prevents DONE from appearing when the program finishes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement