hi there. Juzt wana ask ur help because i can't get my character to load after i selected them in my menu.
here's the code:
`--------
`INCLUDES
`--------
`include the MatEdit LoadMatrix files
#include "LoadMatrix.dba"
`------
`ARRAYS
`------
`declare the MatEdit variables
Dim BigMatrix(600,600,1)
Dim StartLoc_X(1): Dim StartLoc_Z(1):Dim Info(2)
Dim TArrayX(1): Dim TArrayZ(1): Dim FKey(10,1)
Dim ColData(100): Dim ZoneData(100): Dim Tiles(500,500)
Dim OverTexture$(100): Dim OverName$(20): Dim ReplaceTex(100)
Dim MOffsetX(25): Dim MOffsetY(25)
Dim MWire(20): Dim MGhost(20): Dim Lock(20)
Dim MatX#(20): Dim MatY#(20): Dim MatZ#(20)
Dim MatWidth#(20): Dim MatHeight#(20)
Dim TilesX(20): Dim TilesZ(20)
Dim MatHi#(20): Dim MatLo#(20)
`player arrays
dim xSpeed#(4)
dim ySpeed#(4)
dim zSpeed#(4)
dim friction#(4)
dim movedist#(4)
dim targetCount(4)
`gravity
dim gravity#(0) : gravity#(0)=0.1
`hotspot data
dim hotspot(0)
dim oldHotspot(0)
`set up the program
sync on
sync rate 40
hide mouse
autocam off
play:
do
main_menu()
gosub load
`new_target()
gosub main
text 1,20,str$(play)
sync
loop
function main_menu()
`load menu image
load image "media/menu.jpg",1000
set text size 12
red=RGB(255,0,0)
black=RGB(0,0,0)
set camera view 0,0,1,1
selectedItem=1
hold=1
paste image 1000,0,290
do
` cls
`print menu items
if selectedItem=1 then ink red,0 else ink black,0
text 50,348,"I'll destroy YOU"
if selectedItem=2 then ink red,0 else ink black,0
text 190,348,"Wanna Ride?"
if selectedItem=3 then ink red,0 else ink black,0
text 315,348,"This is one hot mama..."
if selectedItem=4 then ink red,0 else ink black,0
text 600,348,"Exit"
`select menu items
if leftkey()=1 and hold=0 then dec selectedItem : hold=1
if rightkey()=1 and hold=0 then inc selectedItem : hold=1
if scancode()=0 then hold=0
if selectedItem>4 then selectedItem=1
if selectedItem<1 then selectedITem=4
`choose what to do when an item is selected
if returnkey()=1 and hold=0
hold=1
` play sound 1
`play game
if selectedItem=1
player$="media/tank.3ds"
delete image 1000
cls
delete object 11
load object "media/tank.3ds",11
play=1
exitfunction
endif
`display instructions
if selectedItem=2
delete image 1000
cls
delete object 11
load object "media/tank.3ds",11
exitfunction
endif
`display information about the game
if selectedItem=3
delete image 1000
cls
delete object 11
load object "media/tank.3ds",11
player$="media/83camaro.x"
exitfunction
endif
`quit the game
if selectedItem=4
end
endif
endif
sync
loop
endfunction play
`---------
`MAIN LOOP
`---------
main:
do
`get keyboard input for movement
if upkey()=1 then forward=1 else forward=0
if downkey()=1 then backward=1 else backward=0
if leftkey()=1 then left=1 else left=0
if rightkey()=1 then right=1 else right=0
`update the player
move_player(1,forward,backward,left,right)
`update the camera
chase_cam(1)
text 10,10,str$(screen fps())
if checkHotspot(1)=hotSpot(0)
new_target()
targetCount(1)=targetCount(1)+1
if targetCount(1)=10 then end_game()
endif
gosub update_target
`update the screen
sync
loop
return
load:
`-------------
`level loading
`-------------
`load the matrix
LoadMatrix("chvz-1",1)
load object "media/edge-a.x",100
load image "media/edge-a.jpg",100
texture object 100,100
position object 100,500,6,1.5
scale object 100,212,80,10
xrotate object 100,180
`----------------borders
load object "media/edge-a.x",101
texture object 101,100
position object 101,1.5,6,500
scale object 101,212,80,10
xrotate object 101,180
yrotate object 101,90
load object "media/edge-a.x",102
texture object 102,100
position object 102,500,6,1000
scale object 102,212,80,10
xrotate object 102,180
yrotate object 102,180
load object "media/edge-a.x",103
texture object 103,100
position object 103,1000,6,500
scale object 103,212,80,10
xrotate object 103,180
yrotate object 103,270
`----------borders
`skybox
load object "media/skybox.x",104
load image "media/skybox.jpg",104
texture object 104,104
set object 104,1,1,0
position object 104,500,-20.5,500
scale object 104,506,200,506
`xrotate object 100,180
`----------
`add mip-mapping
set matrix texture 1,2,1
set object texture 100,2,1
set object texture 101,2,1
set object texture 102,2,1
set object texture 103,2,1
`set fog properties
fog on
fog distance 2000
fog color RGB(128,0,0)
`set amobient light amount
set ambient light 40
`colour main light
color light 0,RGB(0,0,160)
`make a light
make light 1
set point light 1,250,200,250
color light 1,RGB(255,255,100)
`--------------------
`load a target object
`--------------------
load object "media/coin.x",200
scale object 200,15,15,15
load image "media/coin.jpg",200
texture object 200,200
load object "media/light_beam2.3ds",201
scale object 201,15,15,15
make object plain 202,150,150
load image "media/light_3.bmp",1
texture object 202,1
set object rotation zyx 202
`ghost object on 200
ghost object on 201
ghost object on 202
`set object 200,1,1,0,1,0,0,1
set object 201,1,0,0,1,0,0,1
set object 202,1,1,0,1,0,0,1
`target light
make light 3
set point light 3,0,0,0
color light 3,RGB(0,128,255)
set light range 3,1000
`gosub main_menu
`--------------
`player loading
`--------------
`make a temporary player object
make object cube 1,1
hide limb 1,0
if play=1 then player$="media/tank.3ds"
if play=2 then player$="media/tank.3ds"
load object player$,11
load image "media/Taxi.bmp",11
texture object 11,11
scale object 11,75,75,75
set object texture 11,2,1
glue object to limb 11,1,0
position object 1,250,3,250
friction#(1)=0.97
moveDist#(1)=0.065
xSpeed#(1)=0
zSpeed#(1)=0
new_target()
`goto main
`endfunction
return
update_target:
yrotate object 200,wrapvalue(object angle y(200)+2)
yrotate object 201,wrapvalue(object angle y(201)-2)
point object 202,camera position x(),camera position y(),camera position z()
return
`-------------
`End game loop
`-------------
function end_game()
repeat
text 10,30,"Congratulations"
text 10,50,"Press Space Key to end"
sync
until spacekey()=1
end
endfunction
`------------------------------
`custom suspend for key command
`------------------------------
function suspend()
hold=1
repeat
if scancode()=0 then hold=0
until scancode()<>0 and hold=0
endfunction
`--------------------------
`pick a new target location
`--------------------------
function new_target()
repeat
hotSpot(0)=rnd(8)+1
until hotspot(0)<>oldHotspot(0)
oldHotspot(0)=hotspot(0)
xPos=(FKey(hotspot(0),0)*info(0))-(info(0)/2)
zPos=(Fkey(hotspot(0),1)*info(1))-(info(1)/2)
yPos=get ground height(1,xPos,zPos)
position object 200,xPos,yPos+10,zPos
position object 201,xPos,yPos,zPos
position object 202,xPos,yPos,zPos
position light 3,xPos,yPos+5,zPos
endfunction
`---------
`chase cam
`---------
function chase_cam(id)
`work out the angle of the object being chased
yAng#=wrapvalue(object angle y(id)+180)
`grab the cameras current position
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
`other variables
camDist=10
camHeight=2
`work out new position
xCamPos#=newxvalue(xPos#,yAng#,camDist)
zCamPos#=newZvalue(zPos#,yAng#,camDist)
`camera collision
if xCamPos#>996 then xCamPos#=996
if zCamPos#>996 then zCamPos#=996
if xCamPos#<4 then XCamPos#=4
if zCamPos#<4 then zCamPos#=4
`work out camera height
yCamPos#=get ground height(1,xCamPos#,zCamPos#)+camHeight
if yCamPos#<yPos#+camHeight then yCamPos#=yPos#+camHeight
xCamPos#=curvevalue(xCamPos#,camera position x(),4)
yCamPos#=curvevalue(yCamPos#,camera position y(),4)
zCamPos#=curvevalue(zCamPos#,camera position z(),4)
`update camera position
position camera xCamPos#,yCamPos#,zCamPos#
point camera xPos#,yPos#+camHeight,zPos#
endfunction
`-------------------------
`move the specified player
`-------------------------
function move_player(id,forward, backward, left, right)
`----------------------------------
`get the required object properties
`----------------------------------
xPos#=object position x(id)
yPos#=object position y(id)
zPos#=object position z(id)
yAng#=object angle y(id)
`-----------------------
`sort out basic movement
`-----------------------
`apply forward movement
if forward=1
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,moveDist#(id))
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,moveDist#(id))
endif
`apply backward movement
if backward=1
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,moveDist#(id)*-1)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,moveDist#(id)*-1)
endif
`apply left rotation
if left=1
yrotate object id,wrapvalue(yAng#-4)
endif
`apply right rotation
if right=1
yrotate object id,wrapvalue(yAng#+4)
endif
`--------------------------------------------------
`sort out friction and other physics related things
`--------------------------------------------------
`work out value with friction
xSpeed#(id)=xSpeed#(id)*friction#(id)
zSpeed#(id)=zSpeed#(id)*friction#(id)
`add gravity value
ySpeed#(id)=ySpeed#(id)+gravity#(0)
`work out the new position
xPos#=xPos#+xSpeed#(id)
zPos#=zPos#+zSpeed#(id)
yPos#=yPos#-ySpeed#(id)
`collision
if xPos#>995 then xPos#=995
if zPos#>995 then zPos#=995
if xPos#<5 then XPos#=5
if zPos#<5 then zPos#=5
`work out the height of the character
if yPos#<get ground height(1,xPos#,zPos#)
ySpeed#(id)=ySpeed#(id)+(yPos#-get ground height(1,xPos#,zPos#))
yPos#=get ground height(1,xPos#,zPos#)
`-----------------
`slide down slopes
`-----------------
xMoveDist#=(backHeight#-frontHeight#)/30
zMoveDist#=(leftHeight#-rightHeight#)/30
`adjust forward/ backward momentum
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#,xMoveDist#)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#,xMoveDist#)
`adjust left/ right momentum
xSpeed#(id)=xSpeed#(id)+newxvalue(0,yAng#-90,zMoveDist#)
zSpeed#(id)=zSpeed#(id)+newzvalue(0,yAng#-90,zMoveDist#)
endif
`reposition the player object
position object id,xPos#,yPos#+2,zPos#
text 1,40,str$(xPos#)
text 1,50,str$(zPos#)
endfunction
`-------------------------------------------------------
`work out what hotspot the current object is on (if any)
`-------------------------------------------------------
function CheckHotspot(id)
`reset current hotspot
currentHotspot=0
`work out curret tile position
tileX=int(object position x(id)/Info(0))+1
tileZ=int(object position z(id)/Info(1))+1
`find current hotspot
For hotSpot=1 to 10
if tileX=FKey(hotSpot,0) and tileZ=FKey(hotSpot,1) then currentHotspot=hotSpot : Exit
Next hotSpot
endfunction currentHotspot
please help me!!!
phukol