Advertisement
Armakuni

simple pong basic code

Nov 29th, 2021
6,608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 10?"{clear}":xb=20:yb=13:dx=1:dy=1:yp=13:dw$="{down}":fort=1to5:dw$=dw$+dw$:next
  2. 15 sc=0:ye=13:oc=32+128:b(1)=32:b(6)=32:fort=2to5:b(t)=32+128:next:poke53281,1:poke53280,1:gosub2000
  3. 20 a$=" {down}{left}{reverse on} {down}{left} {down}{left} {down}{left} {down}{left}{reverse off} "
  4. 30 j=peek(56320):yp=yp+(j=126)-(j=125):rem if up then j=126 gives -1, so yp=yp-1.same for down
  5. 35 gosub 1000:gosub 1050:gosub1080
  6. 38 if xb=5and(yb<yp+5 and yb>yp)thendy=1+dy*(j=126orj=125):dx=-dx:sc=sc+1:rem spin
  7. 39 if xb=34and(yb<ye+5 and yb>ye)then dx=-dx:dy=-dy
  8. 40 if xb<5 then print"{clear}you lose! score: "sc"{return}press return":input z$: run
  9. 42 if xb>35 then print"{clear}you win! score: "sc"{return}press return":input z$: run
  10. 45 if ye+3<yb then ye=ye+1
  11. 48 if ye+3>yb then ye=ye-1
  12. 49 print"{home}";left$(dw$,24)sc;
  13. 50 goto30
  14. 1000 rem move the ball
  15. 1010 poke 1024+xb+yb*40,oc:rem delete old ball
  16. 1020 xb=xb+dx:yb=yb+dy:rem ?"{home}"xb,yb,yp
  17. 1021 if yb<1  then y=1:dy=-dy
  18. 1022 if yb>=24 then y=24: dy=-dy
  19. 1026 if yb<0 then yb=1:dy=1
  20. 1030 nl=1024+xb+yb*40:oc=peek(nl):poke nl,81
  21. 1040 return
  22. 1050 rem ? player s bar
  23. 1055 if yp<0thenyp=0
  24. 1058 if yp>20thenyp=20
  25. 1060 fort=1to6:poke1028+40*(yp+t-1),b(t):next
  26. 1070 return
  27. 1080 rem enemy movement
  28. 1090 if ye<0thenye=0
  29. 1100 if ye>18thenye=18
  30. 1110 ? "{home}"spc(35)left$(dw$,ye)a$
  31. 1120 return
  32. 2000 REM SCREEN 1 -
  33. 2010 ? "{clear}                     {light gray}NM                 ";
  34. 2020 ? "                    N  M                ";
  35. 2030 ? "                   N{reverse on}{dark gray}{127}{reverse off}  {reverse on}{gray}{169}{reverse off}                ";
  36. 2040 ? "                  {light gray}N {reverse on}{dark gray} {127}{gray}{169} {reverse off}                ";
  37. 2050 ? "                 {light gray}N {reverse on}{gray}{169}{dark gray}  {gray}  {reverse off}                ";
  38. 2060 ? "                {light gray}N {reverse on}{gray}{169} {dark gray}  {gray}  {reverse off}                ";
  39. 2070 ? "               {light gray}N {reverse on}{gray}{169} {reverse off}{169}{reverse on}{dark gray}  {gray}  {reverse off}                ";
  40. 2080 ? "              {light gray}N {reverse on}{gray}{169} {reverse off}{169} {reverse on}{dark gray}  {gray}  {reverse off}                ";
  41. 2090 ? "             {light gray}N {reverse on}{gray}{169} {reverse off}{169}  {reverse on}{dark gray}  {gray}  {reverse off}                ";
  42. 2100 ? "            {light gray}N {reverse on}{gray}{169} {reverse off}{169}   {reverse on}{dark gray}  {gray}  {reverse off}                ";
  43. 2110 ? "           {light gray}N {reverse on}{gray}{169} {reverse off}{169}    {reverse on}{dark gray}  {gray}  {reverse off}                ";
  44. 2120 ? "           {reverse on}{dark gray}{127}{reverse off} {gray}{127}{169}     {reverse on}{dark gray}  {gray}  {reverse off}                ";
  45. 2130 ? "           {reverse on}{dark gray} {127}{reverse off} {light gray}M     {reverse on}{dark gray}  {gray}  {reverse off}                ";
  46. 2140 ? "           {dark gray}{127}{reverse on} {127}{reverse off} {light gray}M    {reverse on}{dark gray}  {gray}  {reverse off}                ";
  47. 2150 ? "            {dark gray}{127}{reverse on} {127}{reverse off} {light gray}M   {reverse on}{dark gray}  {gray}  {reverse off}                ";
  48. 2160 ? "             {dark gray}{127}{reverse on} {127}{reverse off} {light gray}M  {reverse on}{dark gray}  {gray}  {reverse off}                ";
  49. 2170 ? "              {dark gray}{127}{reverse on} {127}{reverse off} {light gray}M {reverse on}{dark gray}  {gray}  {reverse off}                ";
  50. 2180 ? "               {dark gray}{127}{reverse on} {127}{reverse off} {light gray}M{reverse on}{dark gray}  {gray}  {reverse off}                ";
  51. 2190 ? "                {dark gray}{127}{reverse on} {127}{reverse off} {reverse on}  {gray}  {reverse off}                ";
  52. 2200 ? "                 {dark gray}{127}{reverse on} {127}  {gray}  {reverse off}                ";
  53. 2210 ? "                  {dark gray}{127}{reverse on}   {gray}  {reverse off}                ";
  54. 2220 ? "                   {dark gray}{127}{reverse on}  {gray}  {reverse off}                ";
  55. 2230 ? "                    {dark gray}{127}{reverse on} {gray} {reverse off}{169}                ";
  56. 2240 ? "                     {dark gray}{127}{gray}{169}                 ";
  57. 2260 return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement