Hello,
I am trying to make some "borders" for my level. I am using infinite planes to make them. I had to rotate them to put them in a way that they form a square around the area I want the player to be in. Everything was working fine until I added these infinite planes. Now, whenever I turn the ship around the screen goes black and values for the player's X and Z position become NaNs. Has anyone experienced a similar problem? Here's the code:
Function CreateBoundingBox()
border_left = CreatePlane()
RotateEntity border_left,0,180,90
PositionEntity border_left,-1200,0,-1200
EntityType border_left,2
EntityAlpha border_left,0.5
border_right = CreatePlane()
RotateEntity border_right,0,180,90
PositionEntity border_right,1200,0,1200
EntityType border_right,2
EntityAlpha border_right,0.5
border_north = CreatePlane()
RotateEntity border_north,90,180,0
PositionEntity border_north,-1200,0,1200
EntityType border_north,2
EntityAlpha border_north,0.5
border_south = CreatePlane()
RotateEntity border_south,90,180,0
PositionEntity border_south,1200,0,-1200
EntityType border_south,2
EntityAlpha border_south,0.5
End Function
And this is the player control code:
Collisions 1,2,2,1 ;player to border
While Not KeyDown(1)
If KeyDown(203) ;left
TurnEntity pivot,0,1,0
player_angle# = player_angle#+1
If player_angle#>30 Then player_angle# = 30
RotateEntity player, 0,player_angle#,0
;rotación de la cámara
roll#=roll# -1
If roll# <-30 Then roll# =-30
EndIf
If KeyDown(205) ;right
TurnEntity pivot, 0,(-1),0
;rotación de la nave
player_angle# = player_angle#-1
If player_angle#<-30 Then player_angle# =-30
RotateEntity player, 0,player_angle#,0
;rotación de la cámara
roll#=roll#+1
If roll# >30 Then roll# =30
EndIf
;wireframe!
If KeyHit(17) ; "W" pressed
wire = Not wire
WireFrame wire
EndIf
If Not KeyDown(205)
If Not KeyDown(203)
If roll# > 0 Then roll# = roll#-1
If roll# < 0 Then roll# = roll#+1
If player_angle# > 0 Then player_angle#=player_angle# -1
If player_angle# < 0 Then player_angle#=player_angle# +1
EndIf
EndIf
RotateEntity player,0,player_angle#,0
If KeyDown(30) ;"a" is pressed
player_speed# = player_speed# +0.01
If player_speed# >= 3 Then player_speed# =3
EndIf
If KeyDown(44) ; "Z" is pressed
player_speed# = player_speed# -0.01
If player_speed# <= 0.40 Then player_speed# =0.40
EndIf
;forward movement
MoveEntity pivot ,0,0,player_speed#
;make the camera point to the player
PointEntity camera,player,roll#
UpdateWorld
RenderWorld
Text 0,0,Str(player_speed#)
Text 0,25,Str(player_angle#)
Text 0,50,"X: " + Str(EntityX(pivot))
Text 50,0,"Z: " + Str(EntityZ(pivot))
Flip
Wend
Any suggestions on what might be wrong?
I am trying to make some "borders" for my level. I am using infinite planes to make them. I had to rotate them to put them in a way that they form a square around the area I want the player to be in. Everything was working fine until I added these infinite planes. Now, whenever I turn the ship around the screen goes black and values for the player's X and Z position become NaNs. Has anyone experienced a similar problem? Here's the code:
Function CreateBoundingBox()
border_left = CreatePlane()
RotateEntity border_left,0,180,90
PositionEntity border_left,-1200,0,-1200
EntityType border_left,2
EntityAlpha border_left,0.5
border_right = CreatePlane()
RotateEntity border_right,0,180,90
PositionEntity border_right,1200,0,1200
EntityType border_right,2
EntityAlpha border_right,0.5
border_north = CreatePlane()
RotateEntity border_north,90,180,0
PositionEntity border_north,-1200,0,1200
EntityType border_north,2
EntityAlpha border_north,0.5
border_south = CreatePlane()
RotateEntity border_south,90,180,0
PositionEntity border_south,1200,0,-1200
EntityType border_south,2
EntityAlpha border_south,0.5
End Function
And this is the player control code:
Collisions 1,2,2,1 ;player to border
While Not KeyDown(1)
If KeyDown(203) ;left
TurnEntity pivot,0,1,0
player_angle# = player_angle#+1
If player_angle#>30 Then player_angle# = 30
RotateEntity player, 0,player_angle#,0
;rotación de la cámara
roll#=roll# -1
If roll# <-30 Then roll# =-30
EndIf
If KeyDown(205) ;right
TurnEntity pivot, 0,(-1),0
;rotación de la nave
player_angle# = player_angle#-1
If player_angle#<-30 Then player_angle# =-30
RotateEntity player, 0,player_angle#,0
;rotación de la cámara
roll#=roll#+1
If roll# >30 Then roll# =30
EndIf
;wireframe!
If KeyHit(17) ; "W" pressed
wire = Not wire
WireFrame wire
EndIf
If Not KeyDown(205)
If Not KeyDown(203)
If roll# > 0 Then roll# = roll#-1
If roll# < 0 Then roll# = roll#+1
If player_angle# > 0 Then player_angle#=player_angle# -1
If player_angle# < 0 Then player_angle#=player_angle# +1
EndIf
EndIf
RotateEntity player,0,player_angle#,0
If KeyDown(30) ;"a" is pressed
player_speed# = player_speed# +0.01
If player_speed# >= 3 Then player_speed# =3
EndIf
If KeyDown(44) ; "Z" is pressed
player_speed# = player_speed# -0.01
If player_speed# <= 0.40 Then player_speed# =0.40
EndIf
;forward movement
MoveEntity pivot ,0,0,player_speed#
;make the camera point to the player
PointEntity camera,player,roll#
UpdateWorld
RenderWorld
Text 0,0,Str(player_speed#)
Text 0,25,Str(player_angle#)
Text 0,50,"X: " + Str(EntityX(pivot))
Text 50,0,"Z: " + Str(EntityZ(pivot))
Flip
Wend
Any suggestions on what might be wrong?