Advertisement
Guest User

UFO (the video game) - C64 BASIC

a guest
Sep 3rd, 2021
3,936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. 5 poke 53280,0:poke 53281,0:poke 646,1:gosub 1000: rem set up the screen
  2. 10 x=170:y=225: rem set the initial x and y co-ordinates for the sprites
  3. 70 for n=12800 to n+63: read a: poke n,a:next n: rem put sprite data in memory
  4. 71 for n=12864 to n+63: read a: poke n,a:next n: rem as above
  5. 72 for n=12928 to n+63: read a: poke n,a:next n: rem as above
  6. 73 for n=12992 to n+63: read a: poke n,a:next n: rem as above
  7. 100 poke 2040,200:poke 2041,201: rem set sprite pointers 0 & 1
  8. 101 poke 2042,202:poke 2043,203: rem set sprite pointers 2 & 3
  9. 110 poke 53248,x: rem sprite 0 x pos
  10. 111 poke 53250,x: rem sprite 1 x pos
  11. 112 poke 53252,0:ufo=peek(53252): rem sprite 2 x pos
  12. 120 poke 53249,y: rem sprite 0 y pos
  13. 121 poke 53251,y-20: rem sprite 1 y pos
  14. 122 poke 53253,50: rem sprite 2 y pos
  15. 135 poke 53269,5: rem display sprite 0 & 2
  16. 136 printchr$(147): rem clear the screen
  17. 140 k=peek(203): rem see if a key is pressed
  18. 150 if k=10 then gosub 200: rem if ‘A’ is pressed
  19. 160 if k=18 then gosub 300: rem if ‘D’ is pressed
  20. 170 if k=60 then gosub 500: rem if ‘SPACE’ is pressed
  21. 180 rem line 181 checks if the ufo has reached the ‘edge’ of the screen
  22. 181 if ufo=255 then ufo=0:poke 53253,peek(53253)+20
  23. 182 ufo=ufo+5:poke 53252,ufo:rem move ufo right by 5 pixels
  24. 183 rem line 184 checks if the ufo has hit the launcher
  25. 184 if peek(53278)>0 then print tab(30)"you lose!":gosub 600
  26. 190 goto 140: rem go back and check for a key press
  27. 200 if x>30 then x=x-5: rem if launcher is at left border then stop
  28. 201 poke 53248,x: rem put new x co-ordinate into sprite 0 location
  29. 210 return: rem go back from where this sub-routine was called
  30. 300 if x<255 then x=x+5: rem if launcher is at right border then stop
  31. 350 poke 53248,x: rem put new x co-ordinate into sprite 0 location
  32. 360 return: rem go back from where this sub-routine was called
  33. 500 poke 53269,7:poke 53250,x: rem show sprites 0, 1 & 2
  34. 501 rem line 520 starts the loop that moves the rocket up the screen
  35. 520 for m=peek(53251) to 0 step -9:poke 53251,m
  36. 521 vc=peek(53278): rem check for a collision
  37. 522 if vc=6 then print tab(32)"you win!":gosub 600: rem collision=win
  38. 523 poke 53278,0: rem set the collision detection back to none
  39. 524 if ufo=255 then ufo=0:poke 53253,peek(53253)+20: rem see 180
  40. 525 ufo=ufo+5:poke 53252,ufo: rem see 182
  41. 529 next m: rem back through the rocket launch loop
  42. 530 poke 53269,5: rem once the rocket leaves the screen switch sprite off
  43. 540 y=peek(53249):poke 53251,y-20: rem reset rocket starting position
  44. 550 poke 53250,x: rem as 540 but for x co-ordinate
  45. 590 return: rem go back to where this sub-routine was called
  46. 600 poke 53278,0: rem switch off collision detection
  47. 608 rem line 610 sets the collision detection to zero and the x&y…
  48. 609 rem …co-ordinates for sprite 3
  49. 610 vc=0:poke 53254,peek(53252):poke 53255,peek(53253)
  50. 619 rem line 620 flashes the boom sprite only on and off for a few secs
  51. 620 for o=0 to 200:poke 53269,0:poke53269,8:next o
  52. 629 rem line 630 switches all sprites off and turns off the collision flags
  53. 630 poke 53269,0:poke 53278,0:poke 53279,0
  54. 631 for buf=631 to 640:poke buf,0:next buf: rem clear keyboard buffer
  55. 632 print"press y to play again,”:?”any other key to quit”
  56. 633 a$="":get a$:if a$="" then goto 633
  57. 634 if a$="y" then goto 100
  58. 636 printchr$(147):poke 53269,0:end
  59. 1000 rem sprite_0 (launcher) / single colour / colour: 1
  60. 1010 data 0,0,0,3,0,192,2,255,64,2,0,64,2,0,64,2
  61. 1020 data 0,64,2,0,64,2,0,64,254,0,127,128,0,1,177,37
  62. 1030 data 111,170,213,69,178,198,101,170,197,69,170,213,69,169,37,101
  63. 1040 data 128,0,1,255,255,255,68,164,170,42,74,68,31,255,248,1
  64. 1050 rem sprite_1 (rocket) / single colour / colour: 1
  65. 1060 data 0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,0
  66. 1070 data 36,0,0,66,0,0,82,0,0,74,0,0,82,0,0,74
  67. 1080 data 0,0,82,0,0,74,0,0,82,0,0,74,0,0,129,0
  68. 1090 data 1,0,128,2,36,64,2,165,64,2,165,64,1,90,128,1
  69. 1100 rem sprite_2 (ufo) / single colour / colour: 1
  70. 1110 data 0,0,0,0,0,0,0,0,0,0,60,0,0,66,0,0
  71. 1120 data 153,0,1,36,128,1,36,128,1,60,128,31,24,248,33,90
  72. 1130 data 132,65,60,130,34,0,68,17,255,136,8,0,16,7,255,224
  73. 1140 data 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
  74. 1150 rem sprite_3 (boom) / single colour / colour: 1
  75. 1160 data 0,12,0,49,206,24,121,123,57,203,49,111,142,49,192,0
  76. 1170 data 0,8,241,156,220,155,214,244,154,82,180,178,82,134,178,82
  77. 1180 data 130,154,82,130,138,210,130,139,146,134,240,30,128,0,0,4
  78. 1190 data 140,28,196,143,55,102,151,227,26,230,98,6,68,0,2,1
  79. 2000 return
  80. run
  81.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement