28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
5 rem joystick - commodore plus/4
|
|
6 rem for rosetta code
|
|
8 rem black bkg, white text, dk. grey border
|
|
9 color 0,1:color 4,2,1:color 1,2,7
|
|
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 print chr$(147);
|
|
15 sc=3072:x=20:y=13:poke sc+x+y*40,43
|
|
20 j=joy(jp)
|
|
25 print chr$(19);"joy status: ";
|
|
26 get k$:if k$="q" then print chr$(147):end
|
|
35 ox=x:oy=y
|
|
40 if(j and 15)=1 then d$="up ":x=20:y=1:goto 48
|
|
41 if(j and 15)=2 then d$="up right":x=39:y=1:goto 48
|
|
42 if(j and 15)=3 then d$=" right":x=39:y=13:goto 48
|
|
43 if(j and 15)=4 then d$="down right":x=39:y=24:goto 48
|
|
44 if(j and 15)=5 then d$="down ":x=20:y=24:goto 48
|
|
45 if(j and 15)=6 then d$="down left ":x=0:y=24:goto 48
|
|
46 if(j and 15)=7 then d$=" left ":x=0:y=13:goto 48
|
|
47 if(j and 15)=8 then d$="up left ":x=0:y=1
|
|
48 if(j and 128) then f$="fire!":c=24
|
|
49 if(j and 128)=0 then f$=" ":c=43
|
|
50 if(j=0) then d$=" ":x=20:y=13
|
|
65 print tab(12);d$;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
|