Advertisement
Shaun_B

C64 Bouncing ball for BASIC 50th anniversary

May 4th, 2014
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XBasic 4.07 KB | None | 0 0
  1. 0 print "{clear}"chr$(8)chr$(142);:poke 53280,0:poke 53281,0:gosub 63992:for i=0 to 24:poke x,160:poke y,160
  2. 1 poke 54272+x,11:poke 54272+y,11:x=x+40:y=y+40:next:x=x1:y=x1:x=x+(rnd(0)*37)
  3. 2 p(0)=1024+x+y*40:for i=s to 0 step -1:poke p(i),87:poke 54272+p(i),s(i):next:if x=>38 then x1=-1
  4. 3 if x<=2 then x1=1
  5. 4 if y=>23 then y1=-1
  6. 5 if y<=1 then y1=1
  7. 6 print"{home}{right}"d$(c)left$(a$,38)"{home}"d$(0)d$(c)left$(b$,38);:a$=right$(a$,253)+left$(a$,1):x=x+x1:y=y+y1:c=c+c1
  8. 7 b$=right$(b$,253)+left$(b$,1):if c=>4.5 then c1=-.5
  9. 8 if c<=1 then c1=.5
  10. 9 if s<4 then s=s+1
  11. 10 for i=4 to 1 step -1:if p(i-1)<>0 then p(i)=p(i-1)
  12. 11 next:for i=1375 to 0 step -1:next
  13. 12 wait 53265,128,128:goto 2
  14. 15 :
  15. 100 rem this has been written with cbm prg studio v2.9.0 by authur jordison
  16. 101 rem for the commodore 64, timed for the cmd supercpu @ 20mhz
  17. 102 rem line 0 clears the screen, sets petscii graphics mode and should also disable shift + c= key
  18. 103 rem the screen and border is set to black before going to sub routine at 63992.
  19. 104 rem lines 63992 through to 63999 (highest line number for cbm basic v2) sets up the variables used
  20. 105 rem used in the main loop from lines 2 throught to 12 as follows: d$ is used as colours for the scrolly text
  21. 106 rem except for d$(0), which is used to set the cursor to the bottom line to print the bottom scrolly
  22. 107 rem the array p is used to tract the previous positions of the ball, all initialised to zero
  23. 108 rem the array s is used as screen colours for the balls 'trail', from white to black, ie, the last
  24. 109 rem ball in the trail the same colour of the screen so it disappears. the string a$ is used for the
  25. 110 rem top scrolly text, and b$ is used for the bottom scrolly text. both scrollys are 254 characters long
  26. 111 rem i think. x and y is set to the 0th and 39th column of the screen, x1 and y1 are initialised to 1
  27. 112 rem c is used to count through the colours for the scrolly text (and back again) and c1 will be changed
  28. 113 rem to change c to count up or down. s will count up to 5 (and no higher), so the trail is maximum of 5
  29. 114 rem and i is initialised to zero before return. one return there is a reverse character outputted to
  30. 115 rem the 0th and 39th column, which is then coloured dark grey. x and y and then initialised, and the x
  31. 116 rem has a number added to it between 0 and 36 (I think) to set a different starting point for each time
  32. 117 rem the program is run. line 2, p(0) is the current ball position, then there is a step through from the
  33. 118 rem current ball to zero to output each ball (i.e., the trail); each ball is outputted with the colour
  34. 119 rem added as appropriate to add the trail. there are then checks through to line 5 so that the ball does
  35. 120 rem go out of bounds. line 6 and 7 outputs the scrolly texts and shuffles each string one character
  36. 121 rem line 7 (and line 8) also checks the colour bounds for the colour roll on the scrollys, either upwards
  37. 122 rem or downwards. line 9 counts up to the maximum number of the trail. line 10 tracks the balls movements
  38. 123 rem and puts the last positions into the p array. line 11 and 12 is simply a pause before it loops back to
  39. 124 rem line 2. you don't need lines 15 through to 125. ---== DONKEYSOFT MMXIV ==---
  40. 125 :
  41. 63992 dim d$(4):dim s(4):dim p(4):p(0)=0:p(1)=0:p(2)=0:p(3)=0:p(4)=0:s(0)=1:s(1)=15:s(2)=12:s(3)=11:s(4)=0:d$(0)="{home}{down*24}{right}":d$(1)="{dark gray}":d$(2)="{gray}":d$(3)="{light gray}":d$(4)="{white}"
  42. 63993 a$="hi. this is the 2nd basic demo that i have written. it is timed to run on the su"
  43. 63994 a$=a$+"percpu so may be slow @ 1mhz. this program uses the same logic as a sinclair zx8"
  44. 63995 a$=a$+"1 game called 'bounce' that i wrote a while back. i may as well do a version fo"
  45. 63996 a$=a$+"r the c64, eh? ":b$="ut it is 100% basic, the 2nd release in my attempt to write 50 "
  46. 63997 b$=b$+"basic programs for the 50th anniversary of the language. twitter me @shaunbeb"
  47. 63998 b$=b$+"bers.   boing! well, it's not quite the amiga bouncing ball demo, nor the c128 on"
  48. 63999 b$=b$+"e that is on the 1750 reu disk, b":x=1024:y=1063:x1=1:y1=x1:c=.5:c1=1:s=0:i=s:return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement