Skip to main content
guest
Join | Help | Sign In
Liberty BASIC Community Wiki Home
guest| Join | Help | Sign In
Liberty BASIC Community Wiki
  • Wiki Home
  • Recent Changes
  • Pages and Files
  • Members
  • Home
    • Liberty BASIC FAQ
    • Contests
    • Tutorials
    • Science
    • Shared Code
    • Tips
    • DLLs
    • PublicDomainSprites
    • Member Pages
    • Links
    • Sandbox

Joystick test USB

Edit 0 1 …
  • 0 Tags
    • No tags
  • Notify
  • RSS
  • Backlinks
  • Source
  • Print
  • Export (PDF)
Older Version Newer Version

bluatigro bluatigro Apr 4, 2010

WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global balx , baly , balz
balx = WindowWidth / 2
baly = WindowHeight / 2
balz = 10
nomainwin
timer 100 , [tmr]
open "Joy-Test" for graphics as #m
print #m , "trapclose [quit]"
wait
[tmr]
readjoystick 1
dx = 0
if Joy1x > 256 * 256 * 2 / 3 then
dx = 10
end if
if Joy1x < 256 * 256 / 3 then
dx = -10
end if
if balx + dx < 0 then dx = 0
if balx + dx > WindowWidth then dx = 0
dy = 0
if Joy1y > 256 * 256 * 2 / 3 then
dy = 10
end if
if Joy1y < 256 * 256 / 3 then
dy = -10
end if
if baly + dy < 0 then dy = 0
if baly + dy > WindowHeight then dy = 0
dz = 0
if Joy1z > 256 * 256 * 2 / 3 then
dz = 10
end if
if Joy1z < 256 * 256 / 3 then
dz = -10
end if
if balz + dz < 20 then dz = 0
if balz + dz > 200 then dz = 0
balx = balx + dx
baly = baly + dy
balz = balz + dz
#m , "cls"
if Joy1button1 then
#m , "color red"
#m , "backcolor red"
else
#m , "color black"
#m , "backcolor black"
end if
if Joy1button2 then
#m , "goto " ; balx - balz _
; " " ; baly - balz
#m , "down"
#m , "boxfilled " ; balx + balz _
; " " ; baly + balz
else
#m , "goto " ; balx ; " " ; baly
#m , "down"
#m , "size " ; balz / 10
#m , "circle " ; balz
end if
#m , "up"
#m , "flush"
wait
[quit]
close #m
end
Help · About · Pricing · Privacy · Terms · Support · Upgrade
Contributions to https://basic.wikispaces.com/ are licensed under a Creative Commons Attribution Share-Alike 2.5 License. Creative Commons Attribution Share-Alike 2.5 License
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world
Turn off "Getting Started"
  1. Home
  2. ...
Loading...