I'm playing around with blitzmax again and doing the tutorials. I'm stuck with collisions now though as I am trying to use my own mesh with a PHY file. I want a box created with code to collide with my sbx scene I have loaded. Here is the code: (I have left in the lines where I have tried to use my level variable to create collision)
'Load the leadwerks game engine framework
Framework leadwerks.engine
'Specify the app title
AppTitle$ = "Test App"
'Create a graphics window
Graphics 1280,900
'Register the abstract path
registerabstractpath AppDir
'Create world with error message if world fails to load
If Not CreateWorld() RuntimeError "Failed to load the world."
'Create a camera and position it
camera:Tcamera = CreateCamera()
PositionEntity camera,vec3(0,2,-6)
RotateEntity camera,vec3(0,-30,0)
'Create a light, position and rotate it
sun:TLight = CreateDirectionalLight()
PositionEntity sun,vec3(2,2,-2)
RotateEntity sun,vec3(45,45,0)
'Create the player
player:TMesh = CreateCube()
EntityParent camera,player
'Load level 1
level1 = LoadScene("abstract::level1.sbx")
positionentity level1,vec3(0,-2,0)
'--------Create physics bodies--------
playerbody:TBody = createbodybox()
setbodymass playerbody,1
EntityParent player,playerbody
entitytype playerbody,1
entitytype level1,1
collisions 1,1,True
'Create a buffer
buffer:TBuffer = CreateBuffer(1280,900,BUFFER_COLOR0|BUFFER_DEPTH|BUFFER_NORMAL)
'Debug lights and physics
debuglights(0)
debugphysics(1)
'Main loop
While Not KeyHit(KEY_ESCAPE)
'Move the player left and right
If KeyDown(KEY_A) moveentity player,vec3(-0.06,0,0)
If KeyDown(KEY_D) moveentity player,vec3(0.06,0,0)
'Zoom camera in and out, reset camera position
If KeyHit(KEY_NUM1) moveentity camera,vec3(0,0,1)
If KeyHit(KEY_NUM2) moveentity camera,vec3(0,0,-1)
If KeyHit(KEY_NUM0) positionentity camera,vec3(0,0,-6)
'Update, render and flip the world
updateworld()
setbuffer buffer
renderworld()
setbuffer backbuffer()
renderlights(buffer)
Flip
Wend
Thanks!