forked from interstellar_development/freeftf
Milestone 3: Freezer
The freezer is now implemented, just as it worked in the original. There are also a few fixes here and there in preparation for Milestonr 4.
This commit is contained in:
parent
d40c3ce1ab
commit
a92202b536
14 changed files with 199 additions and 114 deletions
|
|
@ -9,8 +9,8 @@
|
|||
extends CharacterBody3D
|
||||
|
||||
|
||||
const SPEED = 5.0
|
||||
const JUMP_VELOCITY = 4.5
|
||||
var jump_velocity = 6
|
||||
var speed = 10.0
|
||||
var zoom = 0
|
||||
var player_no
|
||||
var npc = false
|
||||
|
|
@ -19,6 +19,11 @@ var caught = false
|
|||
var captured_by
|
||||
var position_pre
|
||||
var got_person = false
|
||||
var caught_body
|
||||
var beast = false
|
||||
var mouse_locked = true
|
||||
var is_frozen = false
|
||||
var hp = 100
|
||||
|
||||
|
||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
||||
|
|
@ -33,17 +38,6 @@ func _ready():
|
|||
npc = true
|
||||
|
||||
func _physics_process(delta):
|
||||
if $cam_y/Camera3D.position.z == 0:
|
||||
$cam_y.position.y = 1
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
$cam_y.position.y = 0
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().change_scene_to_file("res://menus/main_menu.tscn")
|
||||
Game.reset()
|
||||
Server.reset()
|
||||
|
||||
if enabled:
|
||||
|
||||
if not is_on_floor():
|
||||
|
|
@ -52,22 +46,41 @@ func _physics_process(delta):
|
|||
|
||||
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
if beast:
|
||||
speed -= 6
|
||||
$jump_timeout.start()
|
||||
velocity.y = jump_velocity
|
||||
|
||||
var input_dir = Input.get_vector("left", "right", "forwards", "backwards")
|
||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
||||
if direction:
|
||||
velocity.x = direction.x * SPEED
|
||||
velocity.z = direction.z * SPEED
|
||||
velocity.x = direction.x * speed
|
||||
velocity.z = direction.z * speed
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
||||
velocity.x = move_toward(velocity.x, 0, speed)
|
||||
velocity.z = move_toward(velocity.z, 0, speed)
|
||||
|
||||
move_and_slide()
|
||||
Server.sync_player.rpc(name, position, rotation)
|
||||
|
||||
if caught and !npc:
|
||||
if !npc:
|
||||
print(hp)
|
||||
Server.sync_player.rpc(name, position, rotation)
|
||||
if $cam_y/Camera3D.position.z == 0:
|
||||
$cam_y.position.y = 1
|
||||
if mouse_locked:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
$cam_y.position.y = 0
|
||||
if Input.is_action_just_pressed("escape"):
|
||||
get_tree().change_scene_to_file("res://menus/main_menu.tscn")
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
Game.reset()
|
||||
Server.reset()
|
||||
if Input.is_action_just_pressed("mouse_lock"):
|
||||
mouse_locked = !mouse_locked
|
||||
|
||||
|
||||
func _input(event):
|
||||
|
|
@ -86,7 +99,7 @@ func _input(event):
|
|||
rotate(Vector3.DOWN, camera_rotation.x)
|
||||
|
||||
func _unhandled_input(event):
|
||||
if !npc:
|
||||
if !npc and !beast:
|
||||
if event.is_action_pressed("zoom_in") && $cam_y/Camera3D.position.z > 0:
|
||||
zoom = -1
|
||||
$cam_y/Camera3D.position.z += zoom
|
||||
|
|
@ -97,7 +110,10 @@ func _unhandled_input(event):
|
|||
zoom = 0
|
||||
|
||||
func beast_init():
|
||||
beast = true
|
||||
speed += 1
|
||||
position.y += 10
|
||||
$cam_y/Camera3D.position.z = 0
|
||||
$detect_hit.monitoring = true
|
||||
$detect_hit.monitorable = true
|
||||
$detect_hit/CollisionShape3D.disabled = false
|
||||
|
|
@ -120,6 +136,7 @@ func captured(beast):
|
|||
|
||||
|
||||
func got_one(target):
|
||||
caught_body = target
|
||||
got_person = true
|
||||
$hammer_bag/CSGCylinder3D/CSGSphere3D.visible = true
|
||||
|
||||
|
|
@ -127,6 +144,13 @@ func lost_one():
|
|||
got_person = false
|
||||
$hammer_bag/CSGCylinder3D/CSGSphere3D.visible = false
|
||||
|
||||
func frozen():
|
||||
$in_bag.visible = false
|
||||
is_frozen = true
|
||||
|
||||
|
||||
func unfreeze():
|
||||
is_frozen = false
|
||||
|
||||
func _on_time_in_bag_timeout():
|
||||
visible = true
|
||||
|
|
@ -139,4 +163,8 @@ func _on_time_in_bag_timeout():
|
|||
|
||||
|
||||
func _on_show_fps_timeout():
|
||||
print(Engine.get_frames_per_second())
|
||||
print("FPS: "+str(Engine.get_frames_per_second()))
|
||||
|
||||
|
||||
func _on_jump_timeout_timeout():
|
||||
speed += 6
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue