set display mode 800,600,16
hide mouse
sync on
sync rate = 30
autocam off
print "Loading picture..."
sync
load image "TreeBark1.jpg",1
load image "GrassTex.jpg",2
load image "fire.jpg", 10
load image "sprites\HealthBarSymbol.bmp",100
load image "sprites\RedBar.bmp", 101
load image "sprites\ArmorSymbol.bmp", 102
load image "sprites\GreenBar.jpg", 103
load image "sprites\ManaSymbol.bmp", 104
load image "sprites\BlueBar.jpg", 105
print "Loading music..."
sync
load music "Helm.mp3",1
playerx#=400
playery#=10
playerz#=100
print "Loading object..."
sync
`Load tree trunk
load object "trunk.x",1
`Load my player model (no animation)
load object "manstanding.x",10
`Load my test building (no collision)
load object "testbuilding.x", 1000
`Load my sword object, with swinging animation in first person mode
load object "FPHandAnim.x", 10000
` Set up swinging sword
lock object on 10000
disable object zdepth 10000
scale object 10000, 400, 400, 600
position object 10000, 1, -1, 0
set object speed 10000, 100
'Particle test
MAKE PARTICLES 1, 10, 100, 50
position particles 1, 300, 0, 300
color particles 1, 255,20,0
`Scale my player model
scale object 10, 660, 660, 660
'Hide original tree, and make clones (because clone did not work)
hide object 1
make mesh from object 1,1
'Setup building
scale object 1000, 2000,2300,2000
rotate object 1000, 0, 120, 0
set object collision off 1000
'Setup matrices for terrain simulation
make matrix 1, 300, 300, 10, 10
make matrix 2, 300, 300, 10, 10
matX#=object size x(1000)
matZ#=object size z(1000)
position matrix 2, 300, 0, 0
randomize matrix 1, 5
prepare matrix texture 1,2,1,1
prepare matrix texture 2,2,1,1
'Set player collision on and to spheres
set object collision on 10
set object collision to spheres 10
`Create alllll those trees randomly placed and give collision boxes
for trees=11 to 500
make object trees,1,1
position object trees, rnd(200), 1, rnd(200)
treeY#=get ground height (1, object position x(trees), object position z(trees))
position object trees, object position x(trees), treeY#, object position z(trees)
scale object trees, 100, rnd(15)+100,100
rotate object trees, 0,rnd(300), 0
sx#=object size x(trees)*2
sy#=object size y(trees)
sz#=object size z(trees)*2
set object collision on trees
make object collision box trees,-1*sx#,-1*sy#,-1*sz#,sx#,sy#,sz#,0
next trees
'Foggy until I can setup skybox
fog on
fog distance 250
fog color RGB(200,200,200)
backdrop on
color backdrop RGB(200,200,200)
set camera range 1,250
set ambient light 100
`loop through matrix tiles
for xTile=0 to 9
for zTile=0 to 9
`set the matrix tile texture
set matrix tile 1,xTile,zTile,1
next zTile
next xTile
update matrix 1
randomize matrix 2, 5
if matrix position x(2) >= 300 and matrix position z(2) = 0
position matrix 2, 300, 0, 0
for points = 0 to 10
terrainY# = get matrix height (1, 10, points)
set matrix height 2, 0, points, terrainY#
next points
endif
for xTile2=0 to 9
for zTile2=0 to 9
`set the matrix tile texture
set matrix tile 2,xTile2,zTile2,1
next zTile2
next xTile2
update matrix 2
`Place player's start
position object 10, playerx#,playery#,playerz#
'Texture my trees
texture object 1,1
`Store player object info
xPos#=10
yPos#=5
zPos#=10
xAng#=0
yAng#=0
zAng#=0
playerXang#=0
playerYang#=0
playerZang#=0
`Camera Mode - First Person
CameraMode=0
hold = 0
loop music 1
`Gravity variables
yVel#=0
g#=1
`Floor collision test that isn't working right now
floorcoll#=0
`Getting worldheight and setting up building
cY# = worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+4
buildingY# = worldheight(object position x(1000), object position y(1000), object position z(1000), 1, 2, 300, 300)+.5
position object 1000, 390, buildingY#, 150
`Set player collision radius to 1.5
set object radius 10, 1.5
`Set up HUD
sprite 1, 5, 5, 100
sprite 2, 40, 17, 101
sprite 3, 5, 35, 102
sprite 4, 40, 47, 103
sprite 5, 6, 65, 104
sprite 6, 40, 77, 105
`Store HUD variables
HealthPercent# = 100.0
ManaPercent# = 100.0
ArmorPercent# = 50.0
`Make floor matrix for building (worthless right now)
make matrix 5, object size x(1000), object size z(1000), 2,2
position matrix 5, object position x(1000), buildingY#, object position z(1000)
Rem ****************Camera Loop************
do
`Take care of HUD
if HealthPercent# <= 0
HealthPercent# = 0
endif
if ManaPercent# <= 0
ManaPercent# = 0
endif
if ArmorPercent# <= 0
ArmorPercent# = 0
endif
stretch sprite 2, HealthPercent#, 100
stretch sprite 6, ManaPercent#, 100
stretch sprite 4, ArmorPercent#, 100
`Take care of camera modes
if CameraMode=0 then gosub CameraFirst else gosub CameraThird
grnd# = worldheight(X#, object position y(10), Z#, 1, 2, 300, 300)
`if Activated(1,1)=1 then text 0,0, "Tree selected"
if mouseclick()=2 and y#<=grnd#+6 and Jumping# =0
yvel#=3.5
Jumping# = 1
endif
REM if you click the mouse and the object is on the ground,
REM make it jump
yvel#=yvel#-g#
REM make gravity affect the motion
if y# <= grnd#+6 and yvel#<=0
y#=grnd#+6
REM If player jumping ... (used later to speed up travel with UP arrow)
Jumping# = 0
REM if the player goes beneath the terrain, put it on top
yvel#=-1
endif
if floorcoll#=0
y#=y#+yvel#
REM move the object by the velocity
else
y# = 6.1
if jumping# = 1
y#=y#+yvel#
endif
endif
if y#<= grnd#+5
y#=grnd#+5
endif
position object 10, X#, Y#, Z#
`Take care of first person mode
if CameraMode=0
hide object 10
Position Camera X#,Y#+2,Z#
else
show object 10
cY# = cY#+(MouseMoveY()*.1)
if cY# <= worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+2
cY# = worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+2
endif
if cY# >= worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+25
cY# = worldheight(camera position x(), camera position y(), camera position z(), 1, 2, 300, 300)+25
endif
Position Camera cX#,cY#,cZ#
Point camera SphereX#,Y#,SphereZ#
endif
sync
loop
`First person camera commands
CameraFirst:
show object 10000
if object frame (10000) = 20
set object frame 10000, 1
endif
PlayerXAng# = Object Angle X (10)
PlayerYAng# = Object Angle Y (10)
PlayerZAng# = Object Angle Z (10)
CameraXAng# = Camera Angle x()
if Jumping# = 1
if upkey()=1 then Move Object 10,1
else
if upkey()=1 then Move Object 10,.5
endif
if downkey()=1 then Move Object 10,-.5
if rightkey()=1 then Move Object Right 10, .5
if leftkey()=1 then Move Object Left 10, .5
if mouseclick()=1
`Swing sword
PLAY OBJECT 10000, 1, 20
endif
if scancode()=15 and hold=0
CameraMode=1
hold=1
endif
if keystate(15)=0
hold = 0
else
hold = 1
endif
X# = Object position X(10)
Z# = Object position Z(10)
`Check for collision with tree trunks, slide accordingly
for a=11 to 500
if object collision(10,a)=1
dec x#,get object collision x()
dec y#,get object collision y()
dec z#,get object collision z()
endif
next a
`Restrict camera angles
if cameraXang#<=359.0 and cameraXang#>=200.0
if cameraXang#<=290.0 then cameraXang#=290.0
endif
if cameraXang#>=0.0 and cameraXang#<=100.0
if cameraXang#>=70.0 then cameraXang#=70.0
endif
`Rotate object and camera
`Xrotate object 10, Wrapvalue(playerXang#+MouseMoveY()*.2)
Xrotate camera WrapValue(CameraXAng#+MouseMoveY()*.2)
Yrotate object 10, Wrapvalue(playerYang#+MouseMoveX()*.2)
Yrotate camera WrapValue(playerYang#+MouseMoveX()*.2)
return
`Third person camera commands
CameraThird:
hide object 10000
playerthirdY# = Object angle Y(10)
cameraYang# = camera angle y()
if Jumping# = 1
if Upkey()=1 then Move object 10,1
else
If Upkey()=1 then Move object 10,.5
endif
If Downkey()=1 then Move object 10,-.5
If LeftKey() = 1 then Move object left 10, .3
If RightKey() = 1 then Move object right 10, .3
Yrotate object 10, Wrapvalue(playerthirdY#+MouseMoveX()*.2)
if scancode()=15 and hold=0
CameraMode=0
hold=1
endif
if keystate(15)=0
hold = 0
else
hold = 1
endif
SphereX# = Object position x(10)
SphereZ# = Object position z(10)
cZ# = Newzvalue(SphereZ#,playerthirdY#+180,20)
cX# = Newxvalue(SphereX#,playerthirdY#+180,20)
X# = Object position X(10)
Z# = Object position Z(10)
`Y# = Get ground height(1,X#,Z#)
for a=11 to 500
if object collision(10,a)=1
dec x#,get object collision x()
dec y#,get object collision y()
dec z#,get object collision z()
endif
next a
return
```GET WORLD HEIGHT
```This will find the current matrix y# ground height position
```based on the Number of matrix used in variable mat#
```and the Matrix x,z tile size in variables matx# and matz#
```these can be set from an array if required.
function worldheight(ox#,oy#,oz#,firstmatrix,mat,matx#,matz#)
for a=firstmatrix to (firstmatrix+mat)-1
xx#=matrix position x(a)
zz#=matrix position z(a)
if ox# > xx# and ox# < xx#+matx#
if oz# > zz# and oz# < zz#+matz#
yy#=get ground height(a,ox#-xx#,oz#-zz#)
grnd#=yy#
endif
endif
next a
endfunction grnd#
It's a lot, and it's badly documented, but it worked fine before the patch 4. Thanks
P.S. This is what the alphabet would look like if Q and R were eliminated.