backdrop on
Autocam off
Hide mouse
sync rate 40
`fog
Fog on
Fog distance 3000
Fog color RGB(128,128,128)
Color Backdrop RGB(128,128,128)
Rem make matrix
Make matrix 1,2000,2000,20,20
Rem texture matrix
Load image "grass09.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1
randomize matrix 1,50
UPDATE MATRIX 1
`make a temporary player object
make object cube 1,5
position object 1,250,5,250
`make a temporary player object
make object cube 3,5
position object 3,350,5,350
gosub health_bar
`---------
`MAIN LOOP
`---------
sync on
do
set cursor 0,0:print xpos#
set cursor 0,10:print ypos#
set cursor 0,20:print zpos#
gosub health_bars
yAng=object angle y(1)
`the following is temporary. There will be more but it will made later
`get keyboard input for movement
if upkey()=1 then move object 1,4
if downkey()=1 then move object 1,-4
if leftkey()=1 then yrotate object 1,wrapvalue(yAng-4)
if rightkey()=1 then yrotate object 1,wrapvalue(yAng+4)
`work out the height of the character
xPos#=object position x(1)
zPos#=object position z(1)
yPos#=get ground height(1,xPos#,zPos#)
gosub _arena_collision:
`work out the height of the character
xPos2#=object position x(3)
zPos2#=object position z(3)
yPos2#=get ground height(1,xPos2#,zPos2#)
`update the objects position
position object 1,xPos#,yPos#,zPos#
position object 3,xPos2#,yPos2#,zPos2#
`update the camera
chase_cam(1)
`update the screen
sync
loop
`---------
`chase cam
`---------
function chase_cam(id)
`work out the angle of the object being chased
yAng#=wrapvalue(object angle y(id)+180)
`grab the objects current position
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
`other variables
camDist=25
camHeight=10
`work out new position
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newzvalue(zPos#,yAng#,camDist)
`camera collision
if xCamPos#>1999 then xCamPos#=1998
if zCamPos#>1999 then zCamPos#=1998
if xCamPos#<1 then XCamPos#=2
if zCamPos#<1 then zCamPos#=2
`work out camera height
yCamPos#=get ground height(1,xCamPos#,zCamPos#)+camHeight
if yCamPos# < yPos#+camHeight then yCamPos#=yPos#+camHeight
`update camera position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camHeight,zPos#
endfunction
health_bar:
Make object box 200,1,.05,.01
position object 200,0,-2,4
Lock object on 200
color object 200,rgb(128,0,0)
return
health_bars:
set text font "Sydnie"
set text transparent
set text size 26
set text to bold
center text 320,450, "Health"
return
_arena_collision:
if xPos#=>2000 then xPos#=2000
if zPos#=>2000 then zPos#=2000
if xPos#=<1 then xPos#=1
if zPos#=<1 then zPos#=1
return
Have fun
We need help! Email us! join@eternaldestinyonline.com