Graphics3D 800,600,16,0
Const CollisionType_Camera = 1
Const CollisionType_Level = 999
Collisions CollisionType_Camera,CollisionType_Level,2,2
Collisions ArrowT,CollisionType_Level,2,1
Global Mouse_X_Speed#
Global Mouse_Y_Speed#
Global Camera_VelX#
Global Camera_VelZ#
Global Camera_Pitch
Global Camera_Yaw
Global arrow_in_air = False
Global shottimer = MilliSecs()
Global arrow_speed = 15
Global pum = LoadSound("bowfire2.wav")
SetBuffer BackBuffer()
light = CreateLight()
Global cam=CreateCamera()
CameraRange Cam,0.1,50000
PositionEntity cam,1,0.8,0.5
CameraZoom Cam,0.8
EntityType cam,CollisionType_Camera
EntityRadius cam,0.1
Global weapon2 = LoadMesh("bow.3ds")
weapon_tex2 = LoadTexture("Bow_tex.bmp")
EntityTexture weapon2,weapon_tex2
ScaleEntity weapon2,1,1,1
EntityOrder weapon2,-1
Global arrow = LoadMesh("arrow.b3d")
EntityType arrow,ArrowT
ScaleEntity arrow,1.2,1.2,1.2
RotateEntity arrow,0,180,0
EntityRadius arrow,0.1
EntityOrder arrow,-1
world = LoadMesh("InnerCityHall.b3d")
EntityType world,CollisionType_Level
PositionEntity world,0,0,0
While Not KeyHit(1)
UpdateWorld
RenderWorld
Text 0,10,"X: " + EntityX(cam)
Text 0,25,"Y: " + EntityY(cam)
Text 0,40,"Z: " + EntityZ(cam)
Text 400,0, "Health" + health
Flip
PositionEntity cam,EntityX(cam),0.8,EntityZ(cam)
Proc_UpdateGame()
Wend
Function Proc_Freelook(CamEntity,Velocity#,Speed#)
Mouse_X_Speed#=MouseXSpeed()*0.5
Mouse_Y_Speed#=MouseYSpeed()*0.5
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
Camera_Pitch=Camera_Pitch+Mouse_Y_Speed#
Camera_Yaw=Camera_Yaw+Mouse_X_Speed#
RotateEntity CamEntity,Camera_Pitch,-Camera_Yaw,0
If KeyDown(203) Then
Camera_VelX=Camera_VelX-Speed#/100000
ElseIf KeyDown(205)
Camera_VelX=Camera_VelX+Speed#/100000
EndIf
If KeyDown(208) Then
Camera_VelZ=Camera_VelZ-Speed#/100000
ElseIf KeyDown(200)
Camera_VelZ=Camera_VelZ+Speed#/100000
EndIf
Camera_VelX=Camera_VelX/velocity#
Camera_VelZ=Camera_VelZ/velocity#
MoveEntity CamEntity,Camera_VelX,0,Camera_VelZ
If KeyDown(200) Then
MoveEntity CamEntity,0,0,Speed# / 20
EndIf
If KeyDown(208) Then
MoveEntity CamEntity,0,0,-Speed# / 20
EndIf
If KeyDown(205) Then
MoveEntity CamEntity,Speed# / 20,0,0
EndIf
If KeyDown(203) Then
MoveEntity CamEntity,-Speed# / 20,0,0
EndIf
End Function
Function Proc_UpdateGame()
Proc_Freelook(Cam,1.05,0.5)
RotateEntity weapon2,EntityPitch(cam),EntityYaw(cam)+5,0,EntityRoll(cam)
PositionEntity weapon2,EntityX(cam)+Sin(EntityYaw(cam)),EntityY(cam)-1,EntityZ(cam)-Cos(EntityYaw(cam))
MoveEntity weapon2,-16,0,0
MoveEntity weapon2,0,0,24
If MouseHit(1) Then
If arrow_in_air = False
PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2)
RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2)
PlaySound(pum)
arrow_in_air = True
ShowEntity arrow
ShotTimer = MilliSecs()
arrow_hit = False
End If
End If
If arrow_in_air = False
PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2)
RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2)
End If
MoveEntity arrow,0,0,arrow_speed
;If EntityCollided(arrow,CollisionType_Level)
; PositionEntity arrow,-5000,-5000,-5000
;End If
If MilliSecs() > ShotTimer + 2000
arrow_in_air = False
ShowEntity Arrow
End If
End Function
Const CollisionType_Camera = 1
Const CollisionType_Level = 999
Collisions CollisionType_Camera,CollisionType_Level,2,2
Collisions ArrowT,CollisionType_Level,2,1
Global Mouse_X_Speed#
Global Mouse_Y_Speed#
Global Camera_VelX#
Global Camera_VelZ#
Global Camera_Pitch
Global Camera_Yaw
Global arrow_in_air = False
Global shottimer = MilliSecs()
Global arrow_speed = 15
Global pum = LoadSound("bowfire2.wav")
SetBuffer BackBuffer()
light = CreateLight()
Global cam=CreateCamera()
CameraRange Cam,0.1,50000
PositionEntity cam,1,0.8,0.5
CameraZoom Cam,0.8
EntityType cam,CollisionType_Camera
EntityRadius cam,0.1
Global weapon2 = LoadMesh("bow.3ds")
weapon_tex2 = LoadTexture("Bow_tex.bmp")
EntityTexture weapon2,weapon_tex2
ScaleEntity weapon2,1,1,1
EntityOrder weapon2,-1
Global arrow = LoadMesh("arrow.b3d")
EntityType arrow,ArrowT
ScaleEntity arrow,1.2,1.2,1.2
RotateEntity arrow,0,180,0
EntityRadius arrow,0.1
EntityOrder arrow,-1
world = LoadMesh("InnerCityHall.b3d")
EntityType world,CollisionType_Level
PositionEntity world,0,0,0
While Not KeyHit(1)
UpdateWorld
RenderWorld
Text 0,10,"X: " + EntityX(cam)
Text 0,25,"Y: " + EntityY(cam)
Text 0,40,"Z: " + EntityZ(cam)
Text 400,0, "Health" + health
Flip
PositionEntity cam,EntityX(cam),0.8,EntityZ(cam)
Proc_UpdateGame()
Wend
Function Proc_Freelook(CamEntity,Velocity#,Speed#)
Mouse_X_Speed#=MouseXSpeed()*0.5
Mouse_Y_Speed#=MouseYSpeed()*0.5
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
Camera_Pitch=Camera_Pitch+Mouse_Y_Speed#
Camera_Yaw=Camera_Yaw+Mouse_X_Speed#
RotateEntity CamEntity,Camera_Pitch,-Camera_Yaw,0
If KeyDown(203) Then
Camera_VelX=Camera_VelX-Speed#/100000
ElseIf KeyDown(205)
Camera_VelX=Camera_VelX+Speed#/100000
EndIf
If KeyDown(208) Then
Camera_VelZ=Camera_VelZ-Speed#/100000
ElseIf KeyDown(200)
Camera_VelZ=Camera_VelZ+Speed#/100000
EndIf
Camera_VelX=Camera_VelX/velocity#
Camera_VelZ=Camera_VelZ/velocity#
MoveEntity CamEntity,Camera_VelX,0,Camera_VelZ
If KeyDown(200) Then
MoveEntity CamEntity,0,0,Speed# / 20
EndIf
If KeyDown(208) Then
MoveEntity CamEntity,0,0,-Speed# / 20
EndIf
If KeyDown(205) Then
MoveEntity CamEntity,Speed# / 20,0,0
EndIf
If KeyDown(203) Then
MoveEntity CamEntity,-Speed# / 20,0,0
EndIf
End Function
Function Proc_UpdateGame()
Proc_Freelook(Cam,1.05,0.5)
RotateEntity weapon2,EntityPitch(cam),EntityYaw(cam)+5,0,EntityRoll(cam)
PositionEntity weapon2,EntityX(cam)+Sin(EntityYaw(cam)),EntityY(cam)-1,EntityZ(cam)-Cos(EntityYaw(cam))
MoveEntity weapon2,-16,0,0
MoveEntity weapon2,0,0,24
If MouseHit(1) Then
If arrow_in_air = False
PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2)
RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2)
PlaySound(pum)
arrow_in_air = True
ShowEntity arrow
ShotTimer = MilliSecs()
arrow_hit = False
End If
End If
If arrow_in_air = False
PositionEntity arrow,EntityX(weapon2),EntityY(weapon2),EntityZ(weapon2)
RotateEntity arrow,EntityPitch(weapon2),EntityYaw(weapon2),EntityRoll(weapon2)
End If
MoveEntity arrow,0,0,arrow_speed
;If EntityCollided(arrow,CollisionType_Level)
; PositionEntity arrow,-5000,-5000,-5000
;End If
If MilliSecs() > ShotTimer + 2000
arrow_in_air = False
ShowEntity Arrow
End If
End Function