mirror of
https://github.com/Steffo99/cinnos.git
synced 2024-11-25 17:44:21 +00:00
Merge branch 'main' of https://github.com/Steffo99/jam
This commit is contained in:
commit
c005ba4e8a
5 changed files with 128 additions and 26 deletions
12
GameTimer.gd
Normal file
12
GameTimer.gd
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
extends Node
|
||||||
|
class_name GameTimer
|
||||||
|
|
||||||
|
|
||||||
|
var current_time := 0.0
|
||||||
|
|
||||||
|
@onready var parent: Label = get_parent()
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
current_time += delta
|
||||||
|
parent.text = "%0.2f" % current_time
|
63
Player.gd
63
Player.gd
|
@ -1,31 +1,54 @@
|
||||||
extends CharacterBody3D
|
extends CharacterBody3D
|
||||||
|
class_name Player
|
||||||
|
|
||||||
|
|
||||||
const SPEED = 5.0
|
@export var input_accel: float = 1.0
|
||||||
const JUMP_VELOCITY = 4.5
|
@onready var current_input_accel = input_accel
|
||||||
|
|
||||||
|
@onready var gravity_accel: Vector3 = ProjectSettings.get_setting("physics/3d/default_gravity") * ProjectSettings.get_setting("physics/3d/default_gravity_vector")
|
||||||
|
@export var jump_impulse: Vector3 = Vector3.UP * 5;
|
||||||
|
|
||||||
|
|
||||||
|
@export var max_jumps = 1
|
||||||
|
@onready var current_jumps = max_jumps
|
||||||
|
|
||||||
|
@export var collision_normal_max_y_for_floor: float = 0.9
|
||||||
|
|
||||||
|
|
||||||
|
func refill_jumps():
|
||||||
|
current_jumps = max_jumps
|
||||||
|
|
||||||
|
|
||||||
|
func do_jump():
|
||||||
|
current_jumps -= 1
|
||||||
|
velocity += jump_impulse
|
||||||
|
|
||||||
# Get the gravity from the project settings to be synced with RigidBody nodes.
|
|
||||||
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
|
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
# Add the gravity.
|
# Refilla salto
|
||||||
if not is_on_floor():
|
if is_on_floor():
|
||||||
velocity.y -= gravity * delta
|
refill_jumps()
|
||||||
|
|
||||||
# Handle Jump.
|
# Rileva salto
|
||||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
if Input.is_action_just_pressed("jump") and current_jumps > 0:
|
||||||
velocity.y = JUMP_VELOCITY
|
do_jump()
|
||||||
|
|
||||||
# Get the input direction and handle the movement/deceleration.
|
# Applica gravità
|
||||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
velocity += gravity_accel * delta
|
||||||
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
|
||||||
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
|
# Applica input
|
||||||
if direction:
|
var input_dir = Input.get_vector("move_left", "move_right", "move_up", "move_down")
|
||||||
velocity.x = direction.x * SPEED
|
var input_change = input_dir * input_accel
|
||||||
velocity.z = direction.z * SPEED
|
velocity.x += input_change.x * delta
|
||||||
else:
|
velocity.z += input_change.y * delta
|
||||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
|
||||||
velocity.z = move_toward(velocity.z, 0, SPEED)
|
|
||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
# Gestisci collisioni
|
||||||
|
for collision_idx in range(get_slide_collision_count()):
|
||||||
|
var collision = get_slide_collision(collision_idx)
|
||||||
|
if collision.get_normal().y > collision_normal_max_y_for_floor:
|
||||||
|
continue
|
||||||
|
print("bonk")
|
||||||
|
|
||||||
|
|
45
Root.tscn
45
Root.tscn
|
@ -1,24 +1,36 @@
|
||||||
[gd_scene load_steps=8 format=3 uid="uid://4whij2hmts0t"]
|
[gd_scene load_steps=11 format=3 uid="uid://4whij2hmts0t"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Player.gd" id="1_wt4gx"]
|
[ext_resource type="Script" path="res://Player.gd" id="1_wt4gx"]
|
||||||
|
[ext_resource type="Material" uid="uid://dondfiavgo2ws" path="res://Unshaded.material" id="2_upp15"]
|
||||||
|
[ext_resource type="Script" path="res://GameTimer.gd" id="3_y362g"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_castg"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_castg"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_pnmjt"]
|
[sub_resource type="CapsuleMesh" id="CapsuleMesh_pnmjt"]
|
||||||
|
material = ExtResource("2_upp15")
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_kpyw3"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_kpyw3"]
|
||||||
size = Vector3(1, 0.1, 3)
|
size = Vector3(1, 0.1, 3)
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_4tnse"]
|
[sub_resource type="BoxMesh" id="BoxMesh_4tnse"]
|
||||||
|
material = ExtResource("2_upp15")
|
||||||
size = Vector3(1, 0.1, 3)
|
size = Vector3(1, 0.1, 3)
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_opk07"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1au4d"]
|
||||||
|
shading_mode = 0
|
||||||
|
albedo_color = Color(0, 0.541176, 0, 1)
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_tpbxa"]
|
[sub_resource type="PlaneMesh" id="PlaneMesh_opk07"]
|
||||||
|
material = SubResource("StandardMaterial3D_1au4d")
|
||||||
|
size = Vector2(200, 200)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_2bm1d"]
|
||||||
|
size = Vector3(200, 4, 200)
|
||||||
|
|
||||||
[node name="Root" type="Node3D"]
|
[node name="Root" type="Node3D"]
|
||||||
|
|
||||||
[node name="Player" type="CharacterBody3D" parent="."]
|
[node name="Player" type="CharacterBody3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.927202, 0)
|
||||||
script = ExtResource("1_wt4gx")
|
script = ExtResource("1_wt4gx")
|
||||||
|
|
||||||
[node name="Man" type="CollisionShape3D" parent="Player"]
|
[node name="Man" type="CollisionShape3D" parent="Player"]
|
||||||
|
@ -40,11 +52,34 @@ skeleton = NodePath("../..")
|
||||||
[node name="Plane" type="StaticBody3D" parent="."]
|
[node name="Plane" type="StaticBody3D" parent="."]
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Plane"]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Plane"]
|
||||||
transform = Transform3D(100, 0, 0, 0, 1, 0, 0, 0, 100, 0, 0, 0)
|
|
||||||
mesh = SubResource("PlaneMesh_opk07")
|
mesh = SubResource("PlaneMesh_opk07")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Plane"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Plane"]
|
||||||
shape = SubResource("WorldBoundaryShape3D_tpbxa")
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, 0)
|
||||||
|
shape = SubResource("BoxShape3D_2bm1d")
|
||||||
|
|
||||||
[node name="Camera3D" type="Camera3D" parent="."]
|
[node name="Camera3D" type="Camera3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.955149, 0.296125, 0, -0.296125, 0.955149, 0, 2.66196, 3.33182)
|
transform = Transform3D(1, 0, 0, 0, 0.955149, 0.296125, 0, -0.296125, 0.955149, 0, 2.66196, 3.33182)
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="."]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -40.0
|
||||||
|
offset_bottom = 40.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Control"]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_left = -81.0
|
||||||
|
offset_bottom = 26.0
|
||||||
|
grow_horizontal = 0
|
||||||
|
text = "Garasauto"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
|
[node name="GameTimer" type="Node" parent="Control/Label"]
|
||||||
|
script = ExtResource("3_y362g")
|
||||||
|
|
BIN
Unshaded.material
Normal file
BIN
Unshaded.material
Normal file
Binary file not shown.
|
@ -14,3 +14,35 @@ config/name="cisio"
|
||||||
run/main_scene="res://Root.tscn"
|
run/main_scene="res://Root.tscn"
|
||||||
config/features=PackedStringArray("4.1", "Forward Plus")
|
config/features=PackedStringArray("4.1", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
jump={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue