RosettaCodeData/Task/Joystick-position/Commodore-BASIC/joystick-position-2.basic

25 lines
889 B
Plaintext

5 rem joystick - commodore 64
6 rem for rosetta code
8 rem black bkg, white text, dk. grey border
9 poke 53280,11:poke 53281,0:poke 646,1
10 print chr$(147);"joystick port 1 or 2";:input jp
11 if jp<1 or jp>2 then print:print"invalid.":print:goto 10
12 jp=(jp=2)+56321:print chr$(147);
15 sc=1024:x=20:y=12:poke sc+x+y*40,43
20 j=not peek(jp) and 31
25 print chr$(19);"{CRSR DOWN 24}joy status: ";
26 get k$:if k$="q" then print chr$(147):end
35 ox=x:oy=y
40 if(j and 1) then y=0:ud$="up "
45 if(j and 2) then y=23:ud$="down"
46 if(j and 3)=0 then y=12:ud$=" "
50 if(j and 4) then x=0:lr$="left "
55 if(j and 8) then x=39:lr$="right"
56 if(j and 12)=0 then x=20:lr$=" "
60 if(j and 16) then f$="fire!":c=24
61 if(j and 16)=0 then f$=" ":c=43
65 print tab(12);ud$;tab(17);lr$;tab(23);f$;
85 poke sc+x+y*40,c:if (ox=x) and (oy=y) then goto 100
90 poke sc+ox+oy*40,32
100 goto 20