Initial Commit

This commit is contained in:
patrick_pluto 2024-08-02 00:55:56 +02:00
parent 6d0191e863
commit beb2b93613
10 changed files with 516 additions and 0 deletions

58
scripts/computer.gd Normal file
View file

@ -0,0 +1,58 @@
extends StaticBody3D
const TARGET = 100
var current = 0
var pc_occupied = [0, 0, 0,]
var pc_body = [0, 0, 0]
func _ready():
Game.computers += 1
func _on_computer_tick_timeout():
current += (pc_occupied[0] + pc_occupied[1] + pc_occupied[2])
if current >= TARGET:
current = "Complete"
$computer_tick.stop()
Game.computers -= 1
$pc_1/Label3D.text = str(current)
$pc_2/Label3D.text = str(current)
$pc_3/Label3D.text = str(current)
func _on_pc_1_area_body_entered(body):
if pc_occupied[0] == 0:
body.has_method("_input")
pc_occupied[0] = 1
pc_body[0] = body
func _on_pc_2_area_body_entered(body):
if pc_occupied[1] == 0:
pc_occupied[1] = 1
pc_body[1] = body
func _on_pc_3_area_body_entered(body):
if pc_occupied[2] == 0:
pc_occupied[2] = 1
pc_body[2] = body
func _on_pc_1_area_body_exited(body):
if pc_occupied[0] == 1 and body == pc_body[0]:
pc_occupied[0] = 0
pc_body[0] = 0
func _on_pc_2_area_body_exited(body):
if pc_occupied[1] == 1 and body == pc_body[1]:
pc_occupied[1] = 0
pc_body[1] = 0
func _on_pc_3_area_body_exited(body):
if pc_occupied[2] == 1 and body == pc_body[2]:
pc_occupied[2] = 0
pc_body[2] = 0

6
scripts/game.gd Normal file
View file

@ -0,0 +1,6 @@
extends Node
var computers = 0
func _process(delta):
print(computers)

53
scripts/movement.gd Normal file
View file

@ -0,0 +1,53 @@
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
var zoom = 0
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _physics_process(delta):
if not is_on_floor():
velocity.y -= gravity * delta
if Input.is_action_just_pressed("jump") and is_on_floor():
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
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
move_and_slide()
func _input(event):
if event is InputEventMouseMotion and (Input.is_action_pressed("cam_look") or $cam_y/Camera3D.position.z == 0):
var camera_rotation = event.relative * 0.01
if $cam_y.rotation.x <= 1.6 && camera_rotation.y <= 0:
$cam_y.rotate(Vector3.RIGHT, -camera_rotation.y)
elif $cam_y.rotation.x >= -1.6 && camera_rotation.y >= 0:
$cam_y.rotate(Vector3.RIGHT, -camera_rotation.y)
if $cam_y.rotation.x >= 1.6:
$cam_y.rotation.x = 1.6
elif $cam_y.rotation.x <= -1.6:
$cam_y.rotation.x = -1.6
rotate(Vector3.DOWN, camera_rotation.x)
func _unhandled_input(event):
if event.is_action_pressed("zoom_in") && $cam_y/Camera3D.position.z > 0:
zoom = -1
$cam_y/Camera3D.position.z += zoom
elif event.is_action_pressed("zoom_out") && $cam_y/Camera3D.position.z <= 20:
zoom = 1
$cam_y/Camera3D.position.z += zoom
else:
zoom = 0