Global ly as integer
xp# = 150
Do
cls
ang# = wrapvalue(ang#+0.1)
Boxd(100,200,200,300,ang#)
Print screen fps()
yp = boxheight(100,200,200,300,ang#,int(xp#))
If yp <> 0
Box xp#-15,yp-30,xp#+15,yp
Else
xp# = xp#-0.1
Endif
If Leftkey()
xp# = xp#-0.1
Endif
If Rightkey()
xp# = xp#+0.1
Endif
Loop
End
Function Boxd(left,top,right,bottom,angle#)
avx = (left+right)/2
avy = (top+bottom)/2
tlang = atanfull(left-avx,top-avy)
tldist = sqrt(((left-avx)^2)+((top-avy)^2))
trang = atanfull(right-avx,top-avy)
trdist = sqrt(((right-avx)^2)+((top-avy)^2))
blang = atanfull(left-avx,bottom-avy)
bldist = sqrt(((left-avx)^2)+((bottom-avy)^2))
brang = atanfull(right-avx,bottom-avy)
brdist = sqrt(((right-avx)^2)+((bottom-avy)^2))
ntlx = sin(tlang+angle#)*tldist
ntly = cos(tlang+angle#)*tldist
ntrx = sin(trang+angle#)*trdist
ntry = cos(trang+angle#)*trdist
nblx = sin(blang+angle#)*bldist
nbly = cos(blang+angle#)*bldist
nbrx = sin(brang+angle#)*brdist
nbry = cos(brang+angle#)*brdist
Line ntlx+avx,ntly+avy,ntrx+avx,ntry+avy
Line ntrx+avx,ntry+avy,nbrx+avx,nbry+avy
Line nbrx+avx,nbry+avy,nblx+avx,nbly+avy
Line nblx+avx,nbly+avy,ntlx+avx,ntly+avy
EndFunction
Function Boxheight(left,top,right,bottom,angle#,posx)
avx = (left+right)/2
avy = (top+bottom)/2
tlang = atanfull(left-avx,top-avy)
tldist = sqrt(((left-avx)^2)+((top-avy)^2))
trang = atanfull(right-avx,top-avy)
trdist = sqrt(((right-avx)^2)+((top-avy)^2))
blang = atanfull(left-avx,bottom-avy)
bldist = sqrt(((left-avx)^2)+((bottom-avy)^2))
brang = atanfull(right-avx,bottom-avy)
brdist = sqrt(((right-avx)^2)+((bottom-avy)^2))
ntlx = sin(tlang+angle#)*tldist
ntly = cos(tlang+angle#)*tldist
ntrx = sin(trang+angle#)*trdist
ntry = cos(trang+angle#)*trdist
nblx = sin(blang+angle#)*bldist
nbly = cos(blang+angle#)*bldist
nbrx = sin(brang+angle#)*brdist
nbry = cos(brang+angle#)*brdist
offang1# = atanfull(-(posx-left),(bottom-top)/2)+360
offang2# = atanfull(posx-left,(bottom-top)/2)
offang3# = atanfull(posx-left,-(bottom-top)/2)
offang4# = atanfull(-(posx-left),-(bottom-top)/2)+360
ly = Lesser(Lesser(Lesser(ntly,ntry),nbly),nbry)
gy = Greater(Greater(Greater(ntly,ntry),nbly),nbry)
dx# = ntrx-ntlx
dy# = ntry-ntly
If dx#<>0
m# = dy#/dx#
Endif
rx = posx-(ntlx+avx)
addy = m#*rx
py1 = (ntly+avy)+addy
rem If angle# >= offang1# or angle# < offang2#
rem Box posx-15,py1-15,posx+15,py1+15,RGB(255,0,0),RGB(255,0,0),RGB(255,0,0),RGB(255,0,0)
rem Endif
dx# = nbrx-ntrx
dy# = nbry-ntry
If dx#<>0
m# = dy#/dx#
Endif
rx = posx-(ntrx+avx)
addy = m#*rx
py2 = (ntry+avy)+addy
rem If angle# >= offang2# and angle# < offang3#
rem Box posx-15,py2-15,posx+15,py2+15,RGB(255,255,0),RGB(255,255,0),RGB(255,255,0),RGB(255,255,0)
rem Endif
dx# = nblx-nbrx
dy# = nbly-nbry
If dx#<>0
m# = dy#/dx#
Endif
rx = posx-(nbrx+avx)
addy = m#*rx
py3 = (nbry+avy)+addy
rem If angle# >= offang3# and angle# < offang4#
rem Box posx-15,py3-15,posx+15,py3+15,RGB(0,255,0),RGB(0,255,0),RGB(0,255,0),RGB(0,255,0)
rem Endif
dx# = ntlx-nblx
dy# = ntly-nbly
If dx#<>0
m# = dy#/dx#
Endif
rx = posx-(nblx+avx)
addy = m#*rx
py4 = (nbly+avy)+addy
rem If angle# >= offang4# and angle# < offang1#
rem Box posx-15,py4-15,posx+15,py4+15,RGB(0,0,255),RGB(0,0,255),RGB(0,0,255),RGB(0,0,255)
rem Endif
pyf = SecondLeastofFour(py1,py2,py3,py4)
yheight = pyf
EndFunction yheight
Function Lesser(n1,n2)
If n1 <= n2
less = n1
Else
less = n2
Endif
EndFunction less
Function Greater(n1,n2)
If n1 <= n2
great = n1
Else
great = n2
Endif
EndFunction great
Function SecondLeastofFour(n1,n2,n3,n4)
Dim ns(3) as integer
ns(0) = n1
ns(1) = n2
ns(2) = n3
ns(3) = n4
ls = Lesser(Lesser(Lesser(ns(0),ns(1)),ns(2)),ns(3))
For i = 0 to 3
If ns(i) = ls
temp = i
Endif
Next i
Dim nn(2) as integer
r = 0
For i = 0 to 3
If i <> temp
nn(r) = ns(i)
r = r+1
Endif
Next i
secleast = Lesser(Lesser(nn(0),nn(1)),nn(2))
EndFunction secleast
Ok, so what this does is takes the x position of the box, and translates that into the y position of the rotated box (depending on the rotated boxes parameters.
It still has bugs, such as the fact that getting to close to the edge cause a strange glitch, but it should work ok.
alus.portbb.com go there.
Quote: A book. I hate books. book is stupid. I know that I need codes but I dont know the codes -zenicanin14 the stupidest user in the world