Post by Rod on Apr 1, 2022 3:16:36 GMT -5
Running LB 353 64bit on Win11
This short boids program fails at the spritexy line. It reports "This exponent character has not been adequately supported"
This short boids program fails at the spritexy line. It reports "This exponent character has not been adequately supported"
pi = acs(-1)
sway = pi/6
b=50
dim b(b,4) 'x,y,dx,dy
x=1
y=2
dx=3
dy=4
for n= 1 to b
b(n,x)=int(rnd(0)*800)
b(n,y)=int(rnd(0)*600)
b(n,dx)=8-rnd(0)*16
b(n,dy)=8-rnd(0)*16
next
'nomainwin
WindowWidth =800
WindowHeight =600
UpperLeftX = int((DisplayWidth-WindowWidth)/2)
UpperLeftY = int((DisplayHeight-WindowHeight)/2)
open "Boids" for graphics_nsb as #1
#1 "down ; fill black ; backcolor cyan ; place 5 14; circlefilled 4 ; backcolor white ; place 5 4 ; circlefilled 4 ; getbmp boid 0 0 10 20"
#1 "down ; fill black ; color white ; trapclose [quit]"
#1 "getbmp bac 0 0 800 600 ; background bac"
for n= 1 to b
#1 "addsprite b";n;" boid"
#1 "spritexy b";n;" ";b(n,x);" ";b(n,y)
next
[draw]
#1 "drawsprites"
for n=1 to b
'find all near boids to be influenced by
for m=n+1 to b
if n<>m and abs(b(n,x)-b(m,x))<25 then
dist=sqr((b(m,x)-b(n,x))*(b(m,x)-b(n,x))+(b(m,y)-b(n,y))*(b(m,y)-b(n,y)))
if dist <20 and dist>5 then 'influence
b(n,dx)=(b(n,dx)+b(m,dx))/2
b(n,dy)=(b(n,dy)+b(m,dy))/2
end if
if dist <5 then 'too close
b(n,dx)=b(n,dx)*-1
b(n,dy)=b(n,dy)*-1
end if
end if
next
'move boid
b(n,dx)=b(n,dx)+sway
b(n,dy)=b(n,dy)-sway
b(n,x)=b(n,x)+b(n,dx)
b(n,y)=b(n,y)+b(n,dy)
if b(n,x)>=800 then b(n,dx)=b(n,dx)*-1
if b(n,y)>=600 then b(n,dy)=b(n,dy)*-1
if b(n,x)<0 then b(n,dx)=b(n,dx)*-1
if b(n,y)<0 then b(n,dy)=b(n,dy)*-1
#1 "spritexy b";n;" ";b(n,x);" ";b(n,y) ' error line highlighted -------------------------
next
scan
goto [draw]
[quit]
close #1
end