'CONTROLS:
'Left Mouse Button: Fire a blue portal
'Right Mouse Button: Fire an orange portal
'Mouse Movement: Look around
'W,A,S,D: Move forward, left, back and right
'Space: Jump
'Note: Unplayable at higher resolutions! (Try it at 160x120 for realtime speed)
ScreenX = 320
ScreenY = 240
'indexes to currently open portals (if any!)
'[8](256) standard textures in standard orientations
'[10](1024) special references/modifiers
'"this" box
'"this" side/vector
'"reference" box
'"reference" side/vector
DIM SHARED ElapsedTime
'how many seconds have elapsed since the last main loop
Plr.X = 50
Plr.Y = 50
Plr.Z = 50
Plr.Height = 0.85
UMaxDepth = 8
MapLimit = 100
GET (0, 0)-(ScreenX
- 1, ScreenY
- 1), ScrBuf
()
UTexX& = TexX
UTexY& = TexY
Tex
(x
, y
, i
) = POINT(x
, y
)
UTexX& = TexX
UTexY& = TexY
UTexX& = TexX
UTexY& = TexY
Tex3
(x
, y
, i
) = POINT(x
, y
)
FovX = 75
FovY = ScreenY / ScreenX * FovX
deg2rad = 3.151592654 / 180
ay = -FovY / 2
ayi = FovY / ScreenY
a2 = ay * deg2rad
ay = ay + ayi
ax = -FovX / 2
axi = FovX / ScreenX
FOR sx
= 0 TO ScreenX
- 1 a1 = ax * deg2rad
ax = ax + axi
FOR sx
= 0 TO ScreenX
- 1 x = PixSinX(sx)
y = PixSinY(sy)
z = 1
l
= SQR(x
* x
+ y
* y
+ z
* z
) x = x / l
y = y / l
z = z / l
PixX(sy * ScreenX + sx) = x * 16384#
PixY(sy * ScreenX + sx) = y * 16384#
PixZ(sy * ScreenX + sx) = z * 16384#
'lets try a 2d test to see if we are getting anywhere with this, then a proper 3d test
'to test anything we need a map
'FOR x = -10 TO 10
'Map(x + 50, 50, -10 + 50) = 1
'Map(x + 50, 50, 10 + 50) = 1
'NEXT
'FOR z = -10 TO 10
'Map(-10 + 50, 50, z + 50) = 1
'Map(10 + 50, 50, z + 50) = 1
'NEXT
'floor n roof
'FOR x = 0 TO MapLimit
'FOR z = 0 TO MapLimit
' Map(x, 49, z) = 1
'Map(x, 60, z) = 1
'NEXT
'NEXT
Map(x, y, z) = 1
'IF y = 49 AND RND * 10 < 1 THEN Map(x, y, z) = 3
' IF RND * 20 < 1 THEN Map(x, y, z) = 4
Map(x, 49, z) = 10
Map(x, 50, z) = 11
Map(x, 51, z) = 12
Map(x, 52, z) = 11
Map(x, 53, z) = 12
Map(x, 54, z) = 13
Map(50 + x, 50 + y, 50 + z) = 0
Map(50 - 6, 50, 50) = 2
'Map(50, 50 + 0, 50 - 6) = 2 + 1024
'Special(1).dX = 0
'Special(1).dY = 0
'Special(1).dZ = 1
'Special(1).X = 50
'Special(1).Y = 52
'Special(1).Z = 50 - 4
'FOR i = 1 TO 250
' xx = RND * 10
'yy = RND * 10
'zz = RND * 10
'Map(46 + xx, 50 + yy, 48 + zz) = 1
'NEXT
xx = rnd2(4)
zz = rnd2(4)
IF Map
(50 + xx
, 50 + yy
- 1, 50 + zz
) THEN Map
(50 + xx
, 50 + yy
, 50 + zz
) = 2
'Map(46, 50, 48) = 4
'Map(46, 50, 52) = 4
vax = 0
vay = 0
Uvaxs&
= SIN(vax
* deg2rad
) * 16384&: Uvaxc&
= COS(vax
* deg2rad
) * 16384&
Uvays&
= SIN(vay
* deg2rad
) * 16384&: Uvayc&
= COS(vay
* deg2rad
) * 16384&
ay = -FovY / 2
ayi = FovY / ScreenY
Upx1& = Plr.X * 16384#
Upy1& = (Plr.Y + Plr.Height) * 16384#
Upz1& = Plr.Z * 16384#
'$CHECKING:OFF
siny = PixSinY(sY)
PixOff = sY * ScreenX
FOR sX
= 0 TO ScreenX
- 1
x& = PixX(PixOff)
y& = PixY(PixOff)
z& = PixZ(PixOff)
UdY& = (Uvays& * z&) \ 16384 + (Uvayc& * y&) \ 16384
z& = (Uvayc& * z&) \ 16384 - (Uvays& * y&) \ 16384
UdX& = (Uvaxs& * z&) \ 16384 + (Uvaxc& * x&) \ 16384
UdZ& = (Uvaxc& * z&) \ 16384 - (Uvaxs& * x&) \ 16384
UX& = Upx1&
UY& = Upy1&
UZ& = Upz1&
'copy from here
UDis& = 0
URayDepth = 0
main_1: 'remove this line when possible
'calculate x,y,z distance to next 'cube'
UDistx&
= 16384 - (UX&
AND 16383) IF UDistx&
= 0 THEN UDistx&
= 16384 UDistx&
= (UX&
AND 16383) + 1 UDisty&
= 16384 - (UY&
AND 16383) IF UDisty&
= 0 THEN UDisty&
= 16384 UDisty&
= (UY&
AND 16383) + 1 UDistz&
= 16384 - (UZ&
AND 16383) IF UDistz&
= 0 THEN UDistz&
= 16384 UDistz&
= (UZ&
AND 16383) + 1
IF UABSdX&
<> 0 THEN USpeedX&
= (UDistx&
* 16384) \ UABSdX&
ELSE USpeedX&
= 2147483647 IF UABSdY&
<> 0 THEN USpeedY&
= (UDisty&
* 16384) \ UABSdY&
ELSE USpeedY&
= 2147483647 IF UABSdZ&
<> 0 THEN USpeedZ&
= (UDistz&
* 16384) \ UABSdZ&
ELSE USpeedZ&
= 2147483647
'advance minimal speed + microstep(to cater for floating point errors only)
UCrossed& = 1
UMinSpeed& = USpeedX&
IF USpeedY&
< UMinSpeed&
THEN UMinSpeed&
= USpeedY&: UCrossed&
= 2 IF USpeedZ&
< UMinSpeed&
THEN UMinSpeed&
= USpeedZ&: UCrossed&
= 3 UMinSpeed& = UMinSpeed& + 1
UDis& = UDis& + UMinSpeed&
UX& = UX& + (UdX& * UMinSpeed&) \ 16384
UY& = UY& + (UdY& * UMinSpeed&) \ 16384
UZ& = UZ& + (UdZ& * UMinSpeed&) \ 16384
UBoxType& = Map(UX& \ 16384, UY& \ 16384, UZ& \ 16384)
URayDepth = URayDepth + 1
ScrBuf(PixOff) = 0
Ui = UBoxType \ 256
Ulr
= 16383 - (UZ&
AND 16383): Udu
= UY&
AND 16383 UdX2 = -UdZ: UdY2 = UdY: UdZ2 = UdX
Ulr
= UZ&
AND 16383: Udu
= UY&
AND 16383 UdX2 = UdZ: UdY2 = UdY: UdZ2 = -UdX
Ulr
= UX&
AND 16383: Udu
= 16383 - (UZ&
AND 16383) UdX2 = UdX: UdY2 = -UdZ: UdZ2 = UdY
Ulr
= UX&
AND 16383: Udu
= UZ&
AND 16383 UdX2 = UdX: UdY2 = UdZ: UdZ2 = -UdY
Ulr
= UX&
AND 16383: Udu
= UY&
AND 16383 UdX2 = UdX: UdY2 = UdY: UdZ2 = UdZ
Ulr
= 16383 - (UX&
AND 16383): Udu
= UY&
AND 16383 UdX2 = -UdX: UdY2 = UdY: UdZ2 = -UdZ
x = (Ulr / 16384) - 0.5
y = (Udu / 16384) - 0.5
ll = x * x + y * y
' LOCATE 1, 1
' PRINT UdX, UdY, UdZ
' PRINT UdX2, UdY2, UdZ2
' UDisPLAY
' SLEEP
'assume top down vantage
' UDisPLAY
' SLEEP
UX = Special(Ui).X
UZ = Special(Ui).Z
UY = Special(Ui).Y
UdX3 = Special(Ui).dX
UdY3 = Special(Ui).dY
UdZ3 = Special(Ui).dZ
UX = UX + 16383
UZ = UZ + 16383 - Ulr
UY = UY + Udu
UdX = UdZ2
UdY = UdY2
UdZ = -UdX2
UX = UX
UZ = UZ + Ulr
UY = UY + Udu
UdX = -UdZ2
UdY = UdY2
UdZ = UdX2
UX = UX + Ulr
UZ = UZ + 16383
UY = UY + Udu
UdX = UdX2
UdY = UdY2
UdZ = UdZ2
UX = UX + 16383 - Ulr
UZ = UZ
UY = UY + Udu
UdX = -UdX2
UdY = UdY2
UdZ = -UdZ2
' UX& = Special(Ui).X * 16384# + Ulr
' UZ& = Special(Ui).Z * 16384# + Udu
' UY& = Special(Ui).Y * 16384#
' UdX = UdX2
' UdZ = UdY2
' UdY = -UdZ2
UX = UX + Ulr
UZ = UZ + 16383 - Udu
UY = UY + 16383
UdX = UdX2
UdY = UdZ2
UdZ = -UdY2
UX = UX + Ulr
UZ = UZ + Udu
UY = UY
UdX = UdX2
UdY = -UdZ2
UdZ = UdY2
UDis& = 0
'renderer specific code follows
77
URayDepth = URayDepth + 1
ScrBuf(PixOff) = 0
UdY& = -UdY&
UDis& = 0
UdX& = -UdX&
UDis& = 0
UdZ& = -UdZ&
UDis& = 0
'hit lhs
disz2
= 16384 - (UZ&
AND 16383) tx = disz2
ty = disy1
'hit rhs
tx = disz1
ty = disy1
'hit bottom
tx = disx1
ty = disy1
'hit top
disx2
= 16384 - (UX&
AND 16383) tx = disx2
ty = disy1
tx = disx1
ty = disz1
' tx = 16384
' ty = 16384
' IF USGNdY THEN
' tx = px - INT(px)
' ty = pz - INT(pz)
' ELSE
' tx = px - INT(px)
' ty = pz - INT(pz)
' END IF
m& = (UDis& \ 16384) + 1 '(for low res)
''''m& = (UDis& \ 65536) + 1 '(for high res)
' c& = Tex(tx * TexX, ty * Texy, m&)
' PRINT ty
' SLEEP
IF UBoxType&
= 2 THEN c&
= Tex
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, m&
) IF UBoxType&
= 1 THEN c&
= Tex2
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, m&
) IF UBoxType&
= 3 THEN c&
= Tex3
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, m&
)
IF UBoxType&
= 10 THEN c&
= t_floor
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, 1) IF UBoxType&
= 11 THEN c&
= t_walla
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, 1) IF UBoxType&
= 12 THEN c&
= t_wallb
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, 1) IF UBoxType&
= 13 THEN c&
= t_roof
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, 1) c& = t_buta((tx * UTexX&) \ 16384, (ty * UTexY&) \ 16384, 1)
c& = t_butb((tx * UTexX&) \ 16384, (ty * UTexY&) \ 16384, 1)
IF UBoxType&
= 15 THEN c&
= t_s_box
((tx
* UTexX&
) \
16384, (ty
* UTexY&
) \
16384, 1)
'lighting algorithm under development
r&
= (c& \
65536) AND 255
' IF URayDepth <> 0 THEN b& = b& + URayDepth * 32: IF b& > 255 THEN b& = 255
l& = 16383 - (UDis& \ 30)
' IF l& < 0 THEN l& = 0
' ' l = 1 - (UDis& / 16384) / 10
c& = ((r& * l&) \ 16384) * 65536 + ((g& * l&) \ 16384) * 256 + ((b& * l&) \ 16384) + &HFF000000
' c& = _RGB32(r& * l& \ 16384, g& * l& \ 16384, b& * l& \ 16384)
770
ScrBuf(PixOff) = c&
3
PixOff = PixOff + 1
'$CHECKING:ON
' PSET (_MOUSEX, _MOUSEY), _RGB(255, 255, 255)
'LOCATE 1, 1
'PRINT CINT(frames / (TIMER(0.001) - starttime))
PSET (ScreenX \
2, ScreenY \
2), _RGB(255, 255, 255)
'PRINT i&
'PRINT vax
ElapsedTime = v - LastTime
LastTime = v
mouseMovementX = mx - oldMX
oldMX = mx
mouseMovementY = my - oldMY
oldMY = my
vax
= vax
+ (ABS(mouseMovementX
/ 4) ^ 1.2) * SGN(mouseMovementX
) vay
= vay
- (ABS(mouseMovementY
/ 4) ^ 1.2) * SGN(mouseMovementY
)
UX = Plr.X * 16384#
UY = (Plr.Y + Plr.Height) * 16384#
UZ = Plr.Z * 16384#
x& = 0
y& = 0
z& = 1 * 16384#
Uvaxs&
= SIN(vax
* deg2rad
) * 16384&: Uvaxc&
= COS(vax
* deg2rad
) * 16384&
Uvays&
= SIN(vay
* deg2rad
) * 16384&: Uvayc&
= COS(vay
* deg2rad
) * 16384&
UdY& = (Uvays& * z&) \ 16384 + (Uvayc& * y&) \ 16384
z& = (Uvayc& * z&) \ 16384 - (Uvays& * y&) \ 16384
UdX& = (Uvaxs& * z&) \ 16384 + (Uvaxc& * x&) \ 16384
UdZ& = (Uvaxc& * z&) \ 16384 - (Uvaxs& * x&) \ 16384
RayCheck
'remove previous portal?
Ui = portal(p)
UX2 = Special(Ui).X \ 16384: UY2 = Special(Ui).Y \ 16384: UZ2 = Special(Ui).Z \ 16384
Map
(UX2
, UY2
, UZ2
) = Map
(UX2
, UY2
, UZ2
) AND 255
Ui = p
Map(UX \ 16384, UY \ 16384, UZ \ 16384) = UBoxType + Ui * 256
Special(Ui).Effect = Ui
'store box position
Special(Ui).X = (UX \ 16384) * 16384
Special(Ui).Y = (UY \ 16384) * 16384
Special(Ui).Z = (UZ \ 16384) * 16384
'store side vector containing effect
dx = 0: dy = 0: dz = 0
Special(Ui).dX = dx: Special(Ui).dY = dy: Special(Ui).dZ = dz
portal(p) = Ui
' vay = vay - (_MOUSEY - ScreenY \ 2) \ 20
' IF vay > 90 THEN vay = 90
' IF vay < -90 THEN vay = -90
' vax = vax + (_MOUSEX - ScreenX \ 2) \ 10
'x = _MOUSEX - ScreenX \ 2
'vax = x * 2
'y = (_MOUSEY - ScreenY \ 2) / (ScreenY / 2)
'y = y * 90
'vay = -y
'DO: LOOP UNTIL INKEY$ = ""
et
= TIMER(0.001) - LastTime
' CLS
IF k$
= "6" THEN vax
= vax
+ 20 IF k$
= "4" THEN vax
= vax
- 20
' DEF SEG = 0
' sh& = PEEK(&H417)
x = Plr.X: y = Plr.Y: z = Plr.Z
dx = 0: dy = -1: dz = 0
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#: UX = x * 16384#: UY = y * 16384#: UZ = z * 16384#
RayCheck
height = UDis / 16384#
move = 0
x = 0: y = 0: z = 0
IF KeyDown
(17) OR KeyDown
(72) THEN move
= 1: z
= 1 IF KeyDown
(31) OR KeyDown
(80) THEN move
= 1: z
= -1 IF KeyDown
(30) OR KeyDown
(75) THEN move
= 1: x
= -1 IF KeyDown
(32) OR KeyDown
(77) THEN move
= 1: x
= 1
' x = 0: y = 0: z = 1 'forward vector
' IF k$ = "s" THEN z = -1
a1 = vax * deg2rad: a2 = vay * deg2rad
x1
= SIN(a1
) * z
+ COS(a1
) * x
z1
= COS(a1
) * z
- SIN(a1
) * x
x = x1: z = z1
x = x * ElapsedTime * 15 'est 0.1 * ???
z = z * ElapsedTime * 15
cs
= SQR(Plr.dX
* Plr.dX
+ Plr.dZ
* Plr.dZ
) '1. add new vector
Plr.dX = Plr.dX + x
Plr.dZ = Plr.dZ + z
ns
= SQR(Plr.dX
* Plr.dX
+ Plr.dZ
* Plr.dZ
)
'2. limit as necessary
Plr.dX = (Plr.dX / ns) * 3
Plr.dZ = (Plr.dZ / ns) * 3
' odx = Plr.dX
' odz = Plr.dZ
' cs = SQR(Plr.dX * Plr.dX + Plr.dZ * Plr.dZ)
' Plr.dX = Plr.dX + x
' Plr.dZ = Plr.dZ + z
'' ns = SQR(Plr.dX * Plr.dX + Plr.dZ * Plr.dZ)
' IF ns > cs AND ns > 3 THEN 'still doesn;t work (try qtr turn)
' Plr.dX = odx
' Plr.dZ = odz
' END IF
'trying to stop friction
Plr.dX = Plr.dX / (1 + ElapsedTime * 10)
Plr.dZ = Plr.dZ / (1 + ElapsedTime * 10)
'move player
'add gravity to player vector
Plr.dY = 1.75
' IF height > 0.01 THEN
y = Plr.dY
ApplyGravity y
Plr.dY = y
' END IF
'portal transition checking
ElapsedTimeold = ElapsedTime
ElapsedTime = ElapsedTime / 100
x = Plr.X: y = Plr.Y: z = Plr.Z
l
= SQR(Plr.dX
* Plr.dX
+ Plr.dY
* Plr.dY
+ Plr.dZ
* Plr.dZ
) dx = Plr.dX / l: dy = Plr.dY / l: dz = Plr.dZ / l
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
UX = x * 16384#: UY = y * 16384#: UZ = z * 16384#
RayCheck
IF UBoxType
> 255 THEN 'portal length = UDis / 16384#
l = l * ElapsedTime
'replace plane isolated vector with real movement vector
l
= SQR(Plr.dX
* Plr.dX
+ Plr.dY
* Plr.dY
+ Plr.dZ
* Plr.dZ
) dx = Plr.dX / l: dy = Plr.dY / l: dz = Plr.dZ / l
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
x = UX / 16384#: y = UY / 16384#: z = UZ / 16384#
dx = UdX / 16384#: dy = UdY / 16384#: dz = UdZ / 16384#
Plr.X = x: Plr.Y = y: Plr.Z = z
Plr.dX = dx * l: Plr.dY = dy * l: Plr.dZ = dz * l
x = Plr.X: y = Plr.Y: z = Plr.Z
dx
= SGN(Plr.dX
): dy
= 0: dz
= 0 UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
UX = x * 16384#: UY = y * 16384#: UZ = z * 16384#
RayCheck
length = UDis / 16384#
x
= ABS(Plr.dX
* ElapsedTime
)
IF UBoxType
> 255 THEN 'portal 'replace plane isolated vector with real movement vector
l
= SQR(Plr.dX
* Plr.dX
+ Plr.dY
* Plr.dY
+ Plr.dZ
* Plr.dZ
) dx = Plr.dX / l: dy = Plr.dY / l: dz = Plr.dZ / l
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
x = UX / 16384#: y = UY / 16384#: z = UZ / 16384#
dx = UdX / 16384#: dy = UdY / 16384#: dz = UdZ / 16384#
Plr.X = x: Plr.Y = y: Plr.Z = z
Plr.dX = dx * l: Plr.dY = dy * l: Plr.dZ = dz * l
x = length - 0.01
Plr.X
= Plr.X
+ x
* SGN(Plr.dX
)
x = Plr.X: y = Plr.Y: z = Plr.Z
dx
= 0: dy
= 0: dz
= SGN(Plr.dZ
) UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
UX = x * 16384#: UY = y * 16384#: UZ = z * 16384#
RayCheck
length = UDis / 16384#
z
= ABS(Plr.dZ
* ElapsedTime
)
IF UBoxType
> 255 THEN 'portal 'replace plane isolated vector with real movement vector
l
= SQR(Plr.dX
* Plr.dX
+ Plr.dY
* Plr.dY
+ Plr.dZ
* Plr.dZ
) dx = Plr.dX / l: dy = Plr.dY / l: dz = Plr.dZ / l
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
x = UX / 16384#: y = UY / 16384#: z = UZ / 16384#
dx = UdX / 16384#: dy = UdY / 16384#: dz = UdZ / 16384#
Plr.X = x: Plr.Y = y: Plr.Z = z
Plr.dX = dx * l: Plr.dY = dy * l: Plr.dZ = dz * l
z = length - 0.01
Plr.Z
= Plr.Z
+ z
* SGN(Plr.dZ
)
x = Plr.X: y = Plr.Y: z = Plr.Z
dx
= 0: dy
= SGN(Plr.dY
): dz
= 0 UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
UX = x * 16384#: UY = y * 16384#: UZ = z * 16384#
RayCheck
length = UDis / 16384#
y
= ABS(Plr.dY
* ElapsedTime
)
IF UBoxType
> 255 THEN 'portal 'replace plane isolated vector with real movement vector
l
= SQR(Plr.dX
* Plr.dX
+ Plr.dY
* Plr.dY
+ Plr.dZ
* Plr.dZ
) dx = Plr.dX / l: dy = Plr.dY / l: dz = Plr.dZ / l
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
x = UX / 16384#: y = UY / 16384#: z = UZ / 16384#
dx = UdX / 16384#: dy = UdY / 16384#: dz = UdZ / 16384#
Plr.X = x: Plr.Y = y: Plr.Z = z
Plr.dX = dx * l: Plr.dY = dy * l: Plr.dZ = dz * l
y = length - 0.01
Plr.Y
= Plr.Y
+ y
* SGN(Plr.dY
)
skip_movement:
ElapsedTime = ElapsedTime * 100
11112
l
= SQR(Plr.dX
* Plr.dX
+ Plr.dY
* Plr.dY
+ Plr.dZ
* Plr.dZ
) dx = Plr.dX / l: dy = Plr.dY / l: dz = Plr.dZ / l
x = Plr.X: y = Plr.Y: z = Plr.Z
UdX = dx * 16384#: UdY = dy * 16384#: UdZ = dz * 16384#
UX = x * 16384#: UY = y * 16384#: UZ = z * 16384#
RayCheck
l2 = UDis / 16384#
l = l * ElapsedTime
l2 = l2 - 0.1
' x = x * l2
' y = y * l2
' z = z * l2
' Plr.X = Plr.X + x
' Plr.Y = Plr.Y + y
' Plr.Z = Plr.Z + z
8
Plr.X = Plr.X + Plr.dX * ElapsedTime
Plr.Y = Plr.Y + Plr.dY * ElapsedTime
Plr.Z = Plr.Z + Plr.dZ * ElapsedTime
'IF k$ = " " THEN
' PlrY = PlrY + 1.3
'END IF
' GOTO 11
'freefall
' x = 0: y = -1: z = 0 'fall vector
' 'cast a test ray
' Upx1& = PlrX * 16384#
' Upy1& = PlrY * 16384#
' Upz1& = PlrZ * 16384#
' UdX& = x * 16384#
' UdY& = y * 16384#
' UdZ& = z * 16384#
' testray& = 1
' GOSUB testray_entry
' s = 3
' mydis& = s * et * 16384#
' IF UDis& > mydis& THEN
' PlrX = PlrX + x * s * et
' PlrY = PlrY + y * s * et
' PlrZ = PlrZ + z * s * et
' END IF
' 11
shit:
' PosZ = PosZ - 0.1
frames = frames + 1
frames = 0
rnd2&
= INT(RND * (limit&
* 2 + 1)) - limit&
'quote:
'http://en.wikipedia.org/wiki/Gravitation
'The strength of the gravitational field is numerically equal to the acceleration of objects under its influence, and its value at the Earth's surface, denoted g, is approximately expressed below as the standard average.
'g = 9.81 m/s2 = 32.2 ft/s2
'This means that, ignoring air resistance, an object falling freely near the Earth's surface increases its velocity with 9.81 m/s (32.2 ft/s or 22 mph) for each second of its descent.
y = y - (9.81 / 2) * ElapsedTime
'With air resistance acting upon an object that has been dropped,
'the object will eventually reach a terminal velocity,
'around 56 m/s (200 km/h or 120 mph) for a human body.
IF y
< -(56 / 2) THEN y
= -(56 / 2)
SUB MoveObject
(o
AS ObjectType
) o.X = o.X + o.dX
o.Y = o.Y + o.dY
o.Z = o.Z + o.dZ
UDis& = 0
URayDepth = 0
'main_1: 'remove this line when possible
'calculate x,y,z distance to next 'cube'
UDistx&
= 16384 - (UX&
AND 16383) IF UDistx&
= 0 THEN UDistx&
= 16384 UDistx&
= (UX&
AND 16383) + 1 UDisty&
= 16384 - (UY&
AND 16383) IF UDisty&
= 0 THEN UDisty&
= 16384 UDisty&
= (UY&
AND 16383) + 1 UDistz&
= 16384 - (UZ&
AND 16383) IF UDistz&
= 0 THEN UDistz&
= 16384 UDistz&
= (UZ&
AND 16383) + 1
IF UABSdX&
<> 0 THEN USpeedX&
= (UDistx&
* 16384) \ UABSdX&
ELSE USpeedX&
= 2147483647 IF UABSdY&
<> 0 THEN USpeedY&
= (UDisty&
* 16384) \ UABSdY&
ELSE USpeedY&
= 2147483647 IF UABSdZ&
<> 0 THEN USpeedZ&
= (UDistz&
* 16384) \ UABSdZ&
ELSE USpeedZ&
= 2147483647
'advance minimal speed + microstep(to cater for floating point errors only)
UCrossed& = 1
UMinSpeed& = USpeedX&
IF USpeedY&
< UMinSpeed&
THEN UMinSpeed&
= USpeedY&: UCrossed&
= 2 IF USpeedZ&
< UMinSpeed&
THEN UMinSpeed&
= USpeedZ&: UCrossed&
= 3 UMinSpeed& = UMinSpeed& + 1
UDis& = UDis& + UMinSpeed&
UX& = UX& + (UdX& * UMinSpeed&) \ 16384
UY& = UY& + (UdY& * UMinSpeed&) \ 16384
UZ& = UZ& + (UdZ& * UMinSpeed&) \ 16384
UBoxType& = Map(UX& \ 16384, UY& \ 16384, UZ& \ 16384)
scankey% = keyflags%(scancode%)
Ui = UBoxType \ 256
vax2 = vax
vay2 = vay
Ulr
= 16383 - (UZ&
AND 16383): Udu
= UY&
AND 16383 UdX2 = -UdZ: UdY2 = UdY: UdZ2 = UdX
vax2 = vax2 - 90
Ulr
= UZ&
AND 16383: Udu
= UY&
AND 16383 UdX2 = UdZ: UdY2 = UdY: UdZ2 = -UdX
vax2 = vax2 + 90
Ulr
= UX&
AND 16383: Udu
= 16383 - (UZ&
AND 16383) UdX2 = UdX: UdY2 = -UdZ: UdZ2 = UdY
Ulr
= UX&
AND 16383: Udu
= UZ&
AND 16383 UdX2 = UdX: UdY2 = UdZ: UdZ2 = -UdY
Ulr
= UX&
AND 16383: Udu
= UY&
AND 16383 UdX2 = UdX: UdY2 = UdY: UdZ2 = UdZ
vax2 = vax2
Ulr
= 16383 - (UX&
AND 16383): Udu
= UY&
AND 16383 UdX2 = -UdX: UdY2 = UdY: UdZ2 = -UdZ
vax2 = vax2 - 180
UX = Special(Ui).X
UZ = Special(Ui).Z
UY = Special(Ui).Y
UdX3 = Special(Ui).dX
UdY3 = Special(Ui).dY
UdZ3 = Special(Ui).dZ
UX = UX + 16384
UZ = UZ + 16383 - Ulr
UY = UY + Udu
UdX = UdZ2
UdY = UdY2
UdZ = -UdX2
vax = vax2 + 90
UX = UX - 1
UZ = UZ + Ulr
UY = UY + Udu
UdX = -UdZ2
UdY = UdY2
UdZ = UdX2
vax = vax2 - 90
IF UCrossed
= 2 THEN vax
= -90 UX = UX + Ulr
UZ = UZ + 16384
UY = UY + Udu
UdX = UdX2
UdY = UdY2
UdZ = UdZ2
vax = vax2
UX = UX + 16383 - Ulr
UZ = UZ - 1
UY = UY + Udu
UdX = -UdX2
UdY = UdY2
UdZ = -UdZ2
vax = vax2 + 180
IF UCrossed
= 2 THEN vax
= 180 UX = UX + Ulr
UZ = UZ + 16383 - Udu
UY = UY + 16384
UdX = UdX2
UdY = UdZ2
UdZ = -UdY2
UX = UX + Ulr
UZ = UZ + Udu
UY = UY - 1
UdX = UdX2
UdY = -UdZ2
UdZ = UdY2
RayFunnel = 1