need to open a door

Blitz3D Forums/Blitz3D Beginners Area/need to open a door

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Does this work??

Graphics3D 800,600,0,1

SetBuffer BackBuffer()

Global campivot
Global cam_col=1
Global room_col=2
Global door_col=3
Global door
Global door_open = False
Global door_y
Global door_opened = False
Global firsttime = 0
Collisions Cam_col,room_col,2,2
Collisions cam_col,door_col,2,2

light=CreateLight()

room=LoadMesh ("cube1.b3d")
PositionEntity room,0,-100,0
EntityType room,room_col

door=LoadMesh ("door.b3d")
PositionEntity door,0,-100,200
ScaleEntity door,1,1,.3
EntityType door,door_col

campivot=CreatePivot()
EntityType campivot,cam_col
EntityRadius campivot,4

camera=CreateCamera(campivot)
PositionEntity camera,EntityX(campivot),50,EntityZ(campivot)
EntityType camera,cam_col

Function opendoor()
If door_open=False dy=0
If EntityCollided (campivot,door_col)
	door_open=True
	firsttime = firsttime + 1
	
	If Firsttime = 1 Then timer=MilliSecs()
EndIf
dy=1
If door_open=True And door_opened = False Then
	MoveEntity door,0,dy,0
	If MilliSecs() => Timer +2000 Then
		door_open = False
		door_opened = True
	EndIf
EndIf
End Function 


While Not KeyDown (1)

TranslateEntity campivot,0,-.5,0

If KeyDown (203)
TurnEntity campivot,0,1,0
ElseIf KeyDown (205)
TurnEntity campivot,0,-1,0
End If
If KeyDown (208)
TurnEntity camera,1,0,0 
ElseIf KeyDown (200)
TurnEntity camera,-1,0,0
EndIf
If KeyDown (30)
MoveEntity campivot,0,0,1
ElseIf KeyDown (44)
MoveEntity campivot,0,0,-1
EndIf
opendoor()

UpdateWorld

RenderWorld
Flip

Wend

End