home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
education
/
a
/
juggling
/
!Jugglin27
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1994-10-07
|
8KB
|
381 lines
>!RunImage
!Juggling
by Nick Craig-Wood
This juggles patterns in the Cambridge Jugglers Association
standard juggling format
starting hand is right hand = 0
28:
27:
!*Print <Juggling$Dir>.WimpPal
screeny%=960: screenx%=1280
resetbanks
error
%bally%=screeny%/40: ballx%=bally%
rhand%=ballx%*4
(lx%=0.25*screenx%: rx%=0.75*screenx%
$lx0%=lx%+rhand%: lx1%=lx%-rhand%
$rx0%=rx%-rhand%: rx1%=rx%+rhand%
midx%=0.5*screenx%
chesty%=0.7*screeny%
shoulderx%=0.15*screenx%
shouldery%=0.65*screeny%
elbowx%=0.25*screenx%
elbowy%=0.37*screeny%
headd%=0.12*screeny%
heady%=screeny%-headd%
bottomy%=0
heighty%=0.8*screeny%
basey%=rhand%+bally%
rtick%=32
tickspeed%=2
nmax%=250
pattern%(nmax%) :
pattern
height%(9) :
height of throw
ticks%(9) :
current position of throw
hands%(9) :
starting hand
pos%(9) :
position in pattern ball was thrown
trackx%(9,rtick%*9)
tracky%(9,rtick%*9)
handx%(1,2*rtick%)
handy%(1,2*rtick%)
r2%=2*rtick%
SpriteAreaSize=64*1024
SpriteArea SpriteAreaSize
sprite%(9)
SpriteArea!0=SpriteAreaSize
SpriteArea!8=16
SpriteOp=&2E
SpriteOp,9+256,SpriteArea
SpriteOp,10+256,SpriteArea,"JugSprites"
i%=1
SpriteOp,24+256,SpriteArea,"ball"+
(i%)
,,sprite%(i%-1)
possible attributes
getpattern
"Computing throws ... ";
track
juggle
getpattern
0,1);
"Whilst the program is juggling"
" + speeds it up"
" - slows it down"
"and SPACE enters another pattern"
O8 prompt$="Enter Pattern (Q to Quit E for Examples)"
prompt$
ok=
U7
p$>nmax%
"Pattern too big": ok=
: p$="3"
plen%=0
i%=1
a$=
p$,i%,1)
Z6
"0","1","2","3","4","5","6","7","8","9":
[& pattern%(plen%)=
plen%+=1
"Q","q"
"E","e"
showexamples
prompt$
ok=
d+
"Unrecognised command: ";a$
ok=
plen%=0
pattern%(0)=3
plen%=1
l
(plen%
2*plen%>nmax%
"Pattern too big"
ok=
i%=0
plen%-1
t- pattern%(plen%+i%)=pattern%(i%)
plen%=2*plen%
x
func=0
func<>-1
func+=1
func
1: ok=
getsum
2: ok=
getav
3: ok=
validpat
: func=-1
max%>1
0 yscale=heighty%/0.25/((max%-1)*(max%-1))
yscale=heighty%
showexamples
"Example patterns"
"0 - 9 cascade 0 - 9 balls"
"31,51,71,91 shower 2,3,4,5 balls"
"How to learn to juggle 3 balls"
"300, 3302, 2330, 330, 333"
"How to learn to juggle 4 balls"
"423, 40, 04, 4440, 441, 4"
"How to learn to juggle 5 balls"
"51, 15, 55500, 50505, 552, 55550, 5"
"Some other interesting patterns"
"423, 55500, 51, 531, 504, 612"
"71, 53444, 53, 633, 552, 55550, 5551"
"3333333334515151515141"
"Fun, but impossible"
"123456789, 97531, 678, 747"
getsum
ok=
sum=0: max%=-1
i%=0
plen%-1
a%=pattern%(i%)
sum+=a%
a%>max%
max%=a%
getav
ok=
nb=sum/plen%
(nb)<>0
)
"Pattern was for ";nb;" balls!"
ok=
nball%=
validpat
ok=
plen%>1
i%=0
plen%-2
j%=i%+1
plen%-1
4
pattern%(i%)+i%=pattern%(j%)+j%
B
"Pattern involved catching more than one ball at a time"
juggle
height%()=-1
ticks%()=0
p%=-1
hand%=0
dtick=1/rtick%
tickjuggle
hand%=1-hand%
a$=
a$<>""
mego=
# tickspeed%=2*tickspeed%
3
tickspeed%>rtick%
tickspeed%=rtick%
# tickspeed%=tickspeed%/2
)
tickspeed%<1
tickspeed%=1
" ": mego=
"Q","q":
a$=
a$=""
mego
mego
tickjuggle
p%=(p%+1)
plen%
h%=pattern%(p%)
ticks%()=ticks%()+rtick%
h%>0
E
find out which ball has landed, and throw a new one if nec.
b%=-1: c%=-1
i%=0
nball%-1
,
ticks%(i%)>=rtick%*height%(i%)
,
height%(i%)>=0
b%=i%
c%=i%
b%=-1
b%=c%
b%<>-1
height%(b%)=h%
ticks%(b%)=0
pos%(b%)=p%
hands%(b%)=hand%
ptick%=0
rtick%-1
tickspeed%
startupdate
128+0
d%=rhand%/2
t%=ptick%+rtick%*hand%
?
midx%-elbowx%,elbowy%, handx%(1,t%),handy%(1,t%)-d%/2
?
midx%+elbowx%,elbowy%, handx%(0,t%),handy%(0,t%)-d%/2
<
midx%-elbowx%,elbowy%, midx%-shoulderx%,shouldery%
<
midx%+elbowx%,elbowy%, midx%+shoulderx%,shouldery%
4
midx%-shoulderx%,shouldery%, midx%,chesty%
4
midx%+shoulderx%,shouldery%, midx%,chesty%
-
midx%,heady%-headd%, midx%,bottomy%
midx%,heady%,headd%
i%=0
nball%-1
height%(i%)>=0
t%=ticks%(i%)+ptick%
h%=height%(i%)
x%=trackx%(h%,t%)
y%=tracky%(h%,t%)
)
hands%(i%)
x%=screenx%-x%
C
SpriteOp,34+512,SpriteArea,sprite%(i%),x%-48,y%-24,8
endupdate
ptick%
This makes the tracks for the hands and the balls
track
first track the hands
ptick%=0
r2%-1
t=
*ptick%/rtick%
)( handx%(0,ptick%)=rx%-rhand%*
*+ handy%(0,ptick%)=basey%-rhand%*
+( handx%(1,ptick%)=lx%-rhand%*
,+ handy%(1,ptick%)=basey%+rhand%*
ptick%
now make each ball track
p%=1
(p%))
;p%;
sh%=0
h%=p%
6(
(h%
fh%=1-sh%
fh%=sh%
8D
This makes the tracks for throw from sh% to fh%, height h%
In position p%
h%>1
k0%=rtick%/2
=( k1%=(h%*rtick%-rtick%/2)
>
k0%=0
k1%=rtick%
A
B0 sx%=handx%(sh%,k0%): sy%=handy%(sh%,k0%)
C0 fx%=handx%(fh%,k1%): fy%=handy%(fh%,k1%)
3,4,5,6,7,8,9:
H"
ptick%=0
h%*rtick%-1
ti=ptick%/rtick%
q%=ptick%
ti<0.5
x%=handx%(sh%,q%)
y%=handy%(sh%,q%)
ti>h%-0.5
P! x%=handx%(fh%,q%)
Q! y%=handy%(fh%,q%)
S! t=(ti-0.5)/(h%-1)
T? y%=(fy%-sy%)*t+sy%+yscale*t*(1-t)*(h%-1)*(h%-1)
U" x%=(fx%-sx%)*t+sx%
X! trackx%(p%,ptick%)=x%
Y! tracky%(p%,ptick%)=y%
ptick%
]"
ptick%=0
h%*rtick%-1
^1 trackx%(p%,ptick%)=handx%(sh%,ptick%)
_1 tracky%(p%,ptick%)=handy%(sh%,ptick%)
ptick%
ptick%=0
rtick%-1
t=ptick%/rtick%
e. trackx%(p%,ptick%)=(fx%-sx%)*t+sx%
f? tracky%(p%,ptick%)=(fy%-sy%)*t+sy%+2*yscale*t*(1-t)
ptick%
i
error
resetbanks
"*** Error ***"
" at ";
resetbanks
"OS_Byte",19 :
wait for Vsync
"OS_Byte",112,0 :
reset logical bank
"OS_Byte",113,0 :
reset physical bank
bank%=1
startupdate
bank%=3-bank%
"OS_Byte",112,bank% :
change logical bank
endupdate
"OS_Byte",19 :
wait for Vsync
"OS_Byte",113,bank% :
change physical bank