I have built a game using matrixes created with matedit. So I am using the matedit loadmatrix code to load the level. I can load a level and walk around the matrix with no issues. But when the end level condition is met, I want to load the next level. I cleanup all the objects, images and delete the existing matrix. Then load the new matrix. But now when I try to walk the world the camera simple gains altitude instead of moving as normal. If i start with this new level first, it works fine. I just don't get what possibly can be happening, if the player movement routine was workign why when laoding a new level would simply do something else? Are there any tips, areas I should look into to figure out the problem? As a thought I decided maybe the loadmtrix arrays had unwated info in them so before I laod the new level I undim them and then dim again, but that didn;t help. Any best pratices, insights, or comment will be greatly appreciated.
pseudo code:
main:
gosub initialize variables
gosub loadlevel
do
AmtToMove=0
CX#=Camera Angle X(): CY#=Camera Angle Y(): CZ#=Camera Angle Z()
CY# = WrapValue(CY#+MousemoveX()):`controls turning movement of player
Rotate Camera CX#,CY#,CZ#
Gh#=Get Ground Height(1,Camera Position x(),Camera Position z())+HeightOffset(0):`place the camera a reasonable height above the ground
gosub task1
gosub task2
gosub controlplayer
if level win condition is met
recordscore
clean up old objects, bitmaps, lights, arrays
cls
goto main
endif
if level loose condition is met
endgame
endif
loop
Control_Player:
Rem Use left mouse button to move forwards
If MouseClick()=1 then AmtToMove=5
Rem Use right mouse button to move backwards
if MouseClick()=2 then AmtToMove=-1*5
mm=MouseMoveX()
if mm<>0 then yrotate Object Player(0), Wrapvalue(Object angle y(Player(0))+mm)
`save current values and calculate new ones
oldX#=object position X(Player(0))
oldY#=object position Y(Player(0))
oldZ#=object position Z(Player(0))
if AmtToMove<>0 and gameactive=1
move object Player(0), AmtToMove :`move the hidden player obejct
X#=object position X(Player(0))
Y#=object position Y(Player(0))
Z#=object position Z(Player(0))
Y#=Get ground Height(1,X#,Z#)+HeightOffset(0)
Position Object Player(0), X#,Y#,Z#
If Collision(Player(0))=1
Position Camera oldX#,oldY#,oldZ#
Position Object Player(0),Camera Position X(),Gh#+3.0+bob#,Camera Position z()
endif
`did player hit something at this new postition?
i=object collision(Player(0),0)
if i<>0
`yes - player hit something so handle it
ObjCollision=HandleFruit(i,Obj$(i))
`a 0 means a game or fruit object was hit
If ObjCollision = 1 :`player hit a static object
Position Camera oldX#,Gh#+3.0+bob#,oldZ#
Position Object Player(0), Camera Position X(),Gh#+3.0+bob#,Camera Position z()
else :`move the player and camera and delete object hit
gosub _new_message :`report which fruit or game object player hit
gosub position_player
Delete Object i :`delete the fruit or gameobject we collide with
endif
else
`no - just move the player and camera
gosub position_player
Endif
return