mirror of
https://github.com/PfandBoss/SemesterGameJam2022.git
synced 2025-11-12 04:16:12 +01:00
Leo - Player wird hinzugefügt
This commit is contained in:
60
Player.gd
Normal file
60
Player.gd
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
extends CharacterBody3D
|
||||||
|
|
||||||
|
#-----------Parameters--------------#
|
||||||
|
var SPEED = 10
|
||||||
|
var movement = Vector3(0,0,0)
|
||||||
|
var collisionLayer = 3
|
||||||
|
var inventory = 0 #1 - full, 0 - empty inventory
|
||||||
|
var resource = 0
|
||||||
|
|
||||||
|
var is_alive = true
|
||||||
|
@onready var is_player1 : bool
|
||||||
|
|
||||||
|
#---------------Methods--------------#
|
||||||
|
func _init(player_id):
|
||||||
|
is_player1 = player_id
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
|
||||||
|
movement = Vector3(0,0,0)
|
||||||
|
|
||||||
|
check_interaction()
|
||||||
|
check_input()
|
||||||
|
velocity = movement * SPEED
|
||||||
|
move_and_slide()
|
||||||
|
|
||||||
|
func check_input():
|
||||||
|
|
||||||
|
if is_player1:
|
||||||
|
if Input.is_action_pressed("p1_left"):
|
||||||
|
movement.x -= 1
|
||||||
|
if Input.is_action_pressed("p1_right"):
|
||||||
|
movement.x += 1
|
||||||
|
if Input.is_action_pressed("p1_up"):
|
||||||
|
movement.z -= 1
|
||||||
|
if Input.is_action_pressed("p1_down"):
|
||||||
|
movement.z += 1
|
||||||
|
else:
|
||||||
|
if Input.is_action_pressed("p2_left"):
|
||||||
|
movement.x -= 1
|
||||||
|
if Input.is_action_pressed("p2_right"):
|
||||||
|
movement.x += 1
|
||||||
|
if Input.is_action_pressed("p2_up"):
|
||||||
|
movement.z -= 1
|
||||||
|
if Input.is_action_pressed("p2_down"):
|
||||||
|
movement.z += 1
|
||||||
|
|
||||||
|
func check_interaction():
|
||||||
|
var action
|
||||||
|
if is_player1:
|
||||||
|
action = "p1_interaction"
|
||||||
|
else:
|
||||||
|
action = "p2_interaction"
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed(action):
|
||||||
|
for body in $HitBox.get_overlapping_bodies():
|
||||||
|
if body.has_method("interact") and body.name == "Storage":
|
||||||
|
#Storage interaction
|
||||||
|
if not inventory:
|
||||||
|
body.interact()
|
||||||
|
|
||||||
28
Player.tscn
Normal file
28
Player.tscn
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
[gd_scene load_steps=5 format=3 uid="uid://33i0mf37sy3o"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Player.gd" id="1_4xmv0"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cy6x8d3xe8lux" path="res://icon.svg" id="2_yjfj7"]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_p76ml"]
|
||||||
|
radius = 0.500599
|
||||||
|
height = 1.99403
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_ndwdl"]
|
||||||
|
radius = 0.567567
|
||||||
|
|
||||||
|
[node name="CharacterBody3D" type="CharacterBody3D"]
|
||||||
|
script = ExtResource("1_4xmv0")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
visible = false
|
||||||
|
shape = SubResource("CapsuleShape3D_p76ml")
|
||||||
|
|
||||||
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 2, 0)
|
||||||
|
texture = ExtResource("2_yjfj7")
|
||||||
|
|
||||||
|
[node name="HitBox" type="Area3D" parent="."]
|
||||||
|
collision_mask = 5
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="HitBox"]
|
||||||
|
shape = SubResource("CapsuleShape3D_ndwdl")
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://1sr52olklfyy"]
|
[gd_scene load_steps=2 format=3 uid="uid://cet80w4yr8rse"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/Modules/Storage.gd" id="1_guwoh"]
|
[ext_resource type="Script" path="res://scripts/Modules/Storage.gd" id="1_guwoh"]
|
||||||
|
|
||||||
|
|||||||
@@ -3,25 +3,27 @@
|
|||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://cy6x8d3xe8lux"
|
uid="uid://cy6x8d3xe8lux"
|
||||||
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
path.s3tc="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex"
|
||||||
|
path.etc2="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"imported_formats": ["s3tc", "etc2"],
|
||||||
|
"vram_texture": true
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://icon.svg"
|
source_file="res://icon.svg"
|
||||||
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.s3tc.ctex", "res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.etc2.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
||||||
compress/mode=0
|
compress/mode=2
|
||||||
compress/lossy_quality=0.7
|
compress/lossy_quality=0.7
|
||||||
compress/hdr_compression=1
|
compress/hdr_compression=1
|
||||||
compress/bptc_ldr=0
|
compress/bptc_ldr=0
|
||||||
compress/normal_map=0
|
compress/normal_map=0
|
||||||
compress/channel_pack=0
|
compress/channel_pack=0
|
||||||
mipmaps/generate=false
|
mipmaps/generate=true
|
||||||
mipmaps/limit=-1
|
mipmaps/limit=-1
|
||||||
roughness/mode=0
|
roughness/mode=0
|
||||||
roughness/src_normal=""
|
roughness/src_normal=""
|
||||||
@@ -31,7 +33,7 @@ process/normal_map_invert_y=false
|
|||||||
process/hdr_as_srgb=false
|
process/hdr_as_srgb=false
|
||||||
process/hdr_clamp_exposure=false
|
process/hdr_clamp_exposure=false
|
||||||
process/size_limit=0
|
process/size_limit=0
|
||||||
detect_3d/compress_to=1
|
detect_3d/compress_to=0
|
||||||
svg/scale=1.0
|
svg/scale=1.0
|
||||||
editor/scale_with_editor_scale=false
|
editor/scale_with_editor_scale=false
|
||||||
editor/convert_colors_with_editor_theme=false
|
editor/convert_colors_with_editor_theme=false
|
||||||
|
|||||||
@@ -39,13 +39,59 @@ _global_script_class_icons={
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Semester Game Jam 2022"
|
config/name="Semester Game Jam 2022"
|
||||||
|
run/main_scene="res://node_3d.tscn"
|
||||||
config/features=PackedStringArray("4.0", "Forward Plus")
|
config/features=PackedStringArray("4.0", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
test={
|
p1_left={
|
||||||
"deadzone": 0.5,
|
"deadzone": 0.5,
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"unicode":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p1_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p1_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p1_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p1_interact={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":71,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p2_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p2_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p2_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p2_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
p2_interact={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":46,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user