Merge branch 'master' of https://gitlab.hexaquo.at/ggjg20/bodypartfighter
This commit is contained in:
commit
44a5f84f9f
BIN
3D Input/Bein_Mensch2.blend
Normal file
BIN
3D Input/Bein_Mensch2.blend
Normal file
Binary file not shown.
BIN
3D Input/Bein_Mensch2.blend1
Normal file
BIN
3D Input/Bein_Mensch2.blend1
Normal file
Binary file not shown.
BIN
3D Input/Bein_Pferd.blend
Normal file
BIN
3D Input/Bein_Pferd.blend
Normal file
Binary file not shown.
BIN
3D Input/Bein_Pferd.blend1
Normal file
BIN
3D Input/Bein_Pferd.blend1
Normal file
Binary file not shown.
BIN
3D Input/Kopf_Stier.blend
Normal file
BIN
3D Input/Kopf_Stier.blend
Normal file
Binary file not shown.
BIN
3D Input/Kopf_Stier.blend1
Normal file
BIN
3D Input/Kopf_Stier.blend1
Normal file
Binary file not shown.
BIN
3D Input/Kopf_Vogel.blend
Normal file
BIN
3D Input/Kopf_Vogel.blend
Normal file
Binary file not shown.
BIN
3D Input/Kopf_Vogel.blend1
Normal file
BIN
3D Input/Kopf_Vogel.blend1
Normal file
Binary file not shown.
BIN
3D Input/Mensch_vogelarm_img.jpg
Normal file
BIN
3D Input/Mensch_vogelarm_img.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
BIN
3D Input/Stierbg.jpg
Normal file
BIN
3D Input/Stierbg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 71 KiB |
34
3D Input/Stierbg.jpg.import
Normal file
34
3D Input/Stierbg.jpg.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Stierbg.jpg-b439c056e778b8fb16ae62aa15547147.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://3D Input/Stierbg.jpg"
|
||||||
|
dest_files=[ "res://.import/Stierbg.jpg-b439c056e778b8fb16ae62aa15547147.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
BIN
3D Input/horselegimg.jpg
Normal file
BIN
3D Input/horselegimg.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 79 KiB |
34
3D Input/horselegimg.jpg.import
Normal file
34
3D Input/horselegimg.jpg.import
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/horselegimg.jpg-8935d9a9effef767d66fb9866f38d2c4.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://3D Input/horselegimg.jpg"
|
||||||
|
dest_files=[ "res://.import/horselegimg.jpg-8935d9a9effef767d66fb9866f38d2c4.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=true
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
1062
3D Input/untitled.glb.import
Normal file
1062
3D Input/untitled.glb.import
Normal file
File diff suppressed because it is too large
Load Diff
14
BodyConfig/LoadBodyParts.gd
Normal file
14
BodyConfig/LoadBodyParts.gd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
extends VBoxContainer
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
for entry in BodyPartLoader.bodyparts:
|
||||||
|
#var button = Button.new()
|
||||||
|
#button.text = entry.key
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
57
BodyConfig/bodyBuilderMenu.tscn
Normal file
57
BodyConfig/bodyBuilderMenu.tscn
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://BodyParts/BodyBase/BodyBase.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://BodyConfig/bodyBuildingScript.gd" type="Script" id=2]
|
||||||
|
[ext_resource path="res://BodyConfig/LoadBodyParts.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
[node name="Body Builder Menu" type="Spatial"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
torsoPath = NodePath("Torso")
|
||||||
|
cameraPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport/Camera")
|
||||||
|
rayCastPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport/MouseLook")
|
||||||
|
viewPortPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport")
|
||||||
|
|
||||||
|
[node name="GUI" type="MarginContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HBoxC" type="HBoxContainer" parent="GUI"]
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 600.0
|
||||||
|
rect_min_size = Vector2( 550, 500 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="VBoxC" type="VBoxContainer" parent="GUI/HBoxC"]
|
||||||
|
margin_right = 300.0
|
||||||
|
margin_bottom = 600.0
|
||||||
|
rect_min_size = Vector2( 300, 500 )
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="ViewportContainer" type="ViewportContainer" parent="GUI/HBoxC"]
|
||||||
|
margin_left = 304.0
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 600.0
|
||||||
|
rect_min_size = Vector2( 500, 500 )
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
stretch = true
|
||||||
|
|
||||||
|
[node name="Viewport" type="Viewport" parent="GUI/HBoxC/ViewportContainer"]
|
||||||
|
size = Vector2( 720, 600 )
|
||||||
|
handle_input_locally = false
|
||||||
|
render_target_update_mode = 3
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="GUI/HBoxC/ViewportContainer/Viewport"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 3 )
|
||||||
|
|
||||||
|
[node name="MouseLook" type="RayCast" parent="GUI/HBoxC/ViewportContainer/Viewport"]
|
||||||
|
enabled = true
|
||||||
|
collide_with_areas = true
|
||||||
|
collide_with_bodies = false
|
||||||
|
|
||||||
|
[node name="Torso" parent="." instance=ExtResource( 1 )]
|
80
BodyConfig/bodyBuildingScript.gd
Normal file
80
BodyConfig/bodyBuildingScript.gd
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
export(NodePath) var torsoPath
|
||||||
|
export(NodePath) var cameraPath
|
||||||
|
export(NodePath) var rayCastPath
|
||||||
|
export(NodePath) var viewPortPath
|
||||||
|
|
||||||
|
const ROT_MOD = 500
|
||||||
|
const ROT_DECLINE = 0.1
|
||||||
|
|
||||||
|
var _viewRot = false
|
||||||
|
var _prev_mouse_pos
|
||||||
|
var _camera : Camera
|
||||||
|
var _rayCast : RayCast
|
||||||
|
var _torso : RigidBody
|
||||||
|
var _viewport : Viewport
|
||||||
|
|
||||||
|
var _velx = 0
|
||||||
|
var _vely = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 0)
|
||||||
|
_torso = get_node(torsoPath) as RigidBody
|
||||||
|
_camera = get_node(cameraPath) as Camera
|
||||||
|
_rayCast = get_node(rayCastPath) as RayCast
|
||||||
|
_viewport = get_node(viewPortPath) as Viewport
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
if _viewRot:
|
||||||
|
var mouse_pos = get_viewport().get_mouse_position()
|
||||||
|
|
||||||
|
_velx = (mouse_pos.x - _prev_mouse_pos.x) * delta
|
||||||
|
_vely = (mouse_pos.y - _prev_mouse_pos.y) * delta
|
||||||
|
|
||||||
|
_prev_mouse_pos = mouse_pos
|
||||||
|
|
||||||
|
if not(_velx < 0.001 and _velx > -0.001) or not(_vely < 0.001 and _vely > -0.001) or _viewRot:
|
||||||
|
_torso.rotate_x(_vely * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().x)
|
||||||
|
_torso.rotate_y(_velx * ROT_MOD * delta * PI/180 - global_transform.basis.get_euler().y)
|
||||||
|
|
||||||
|
var decline = (1 - ROT_DECLINE * (delta*100))
|
||||||
|
|
||||||
|
if decline > 1:
|
||||||
|
decline = 1
|
||||||
|
elif decline < 0:
|
||||||
|
decline = 0
|
||||||
|
|
||||||
|
_velx *= decline
|
||||||
|
_vely *= decline
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if _viewRot:
|
||||||
|
var mouse_pos = _viewport.get_viewport().get_mouse_position()
|
||||||
|
|
||||||
|
#set origin of rayCast
|
||||||
|
var orig = _camera.project_ray_origin(mouse_pos)
|
||||||
|
|
||||||
|
#set cast_to of rayCast
|
||||||
|
_rayCast.translation = orig
|
||||||
|
_rayCast.cast_to = orig + _camera.project_ray_normal(mouse_pos) * 1000.0
|
||||||
|
|
||||||
|
if _rayCast.is_colliding():
|
||||||
|
# collider will be the node hit
|
||||||
|
print(_rayCast.get_collider())
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event):
|
||||||
|
if event is InputEventMouseButton:
|
||||||
|
if event.pressed and _viewport.get_viewport().get_mouse_position().x >= 0:
|
||||||
|
print("Mouse Click at: ", event.position)
|
||||||
|
_prev_mouse_pos = event.position
|
||||||
|
_viewRot = true
|
||||||
|
else:
|
||||||
|
print("mouse unpressed at: ", event.position)
|
||||||
|
_viewRot = false
|
22
BodyParts/Arm.gd
Normal file
22
BodyParts/Arm.gd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
extends PushingBodyPart
|
||||||
|
|
||||||
|
|
||||||
|
onready var anim = get_node("Mesh/AnimationPlayer")
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
func action():
|
||||||
|
anim.play("ArmatureAction001")
|
||||||
|
|
||||||
|
|
||||||
|
func push(body):
|
||||||
|
# We multiply by 0.1 because we only want it to spin slightly, it should mostly go up
|
||||||
|
base.apply_impulse(transform.basis.xform(touch_area.global_transform.origin) * 0.1, base.transform.basis.y * 5.0)
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta: float) -> void:
|
||||||
|
# pass
|
40
BodyParts/Arm.tscn
Normal file
40
BodyParts/Arm.tscn
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://BodyParts/PushingBodyPart.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://3D Input/untitled.glb" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://BodyParts/Arm.gd" type="Script" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=3]
|
||||||
|
radius = 0.724339
|
||||||
|
height = 5.27855
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape" id=2]
|
||||||
|
radius = 0.591769
|
||||||
|
|
||||||
|
[node name="Arm" instance=ExtResource( 1 )]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="PartCollider" parent="." index="0"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -5.34203 )
|
||||||
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
|
[node name="Mesh" parent="." index="1" instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[node name="Sphere" parent="Mesh" index="0"]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="BoneAttachment" type="BoneAttachment" parent="Mesh/Armature/Skeleton" index="1"]
|
||||||
|
transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -5.05441 )
|
||||||
|
bone_name = "bone_2"
|
||||||
|
|
||||||
|
[node name="RemoteTransform" type="RemoteTransform" parent="Mesh/Armature/Skeleton/BoneAttachment" index="0"]
|
||||||
|
remote_path = NodePath("../../../../../TouchArea")
|
||||||
|
|
||||||
|
[node name="TouchArea" parent="." index="2"]
|
||||||
|
transform = Transform( 1, -1.98247e-23, -2.98292e-24, 6.50669e-24, -9.49949e-08, 1, -2.07684e-23, -1, -9.49949e-08, -2.23781e-16, -0.0078205, -7.60024 )
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="TouchArea" index="0"]
|
||||||
|
transform = Transform( 1, 2.98291e-24, -1.98247e-23, -2.07684e-23, -9.49949e-08, -1, -6.50669e-24, 1, -9.49949e-08, 2.23781e-16, 0.399765, 0.00782054 )
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[editable path="Mesh"]
|
14
BodyParts/BodyBase/BodyBase.gd
Normal file
14
BodyParts/BodyBase/BodyBase.gd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
extends Spatial
|
||||||
|
class_name BodyBase
|
||||||
|
|
||||||
|
|
||||||
|
export(int) var player_id
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
53
BodyParts/BodyBase/BodyBase.tscn
Normal file
53
BodyParts/BodyBase/BodyBase.tscn
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://BodyParts/BodyBase/BodyBase.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleMesh" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="SphereMesh" id=3]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape" id=5]
|
||||||
|
|
||||||
|
[node name="Torso" type="RigidBody" groups=[
|
||||||
|
"Player",
|
||||||
|
]]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="TorsoMesh" type="MeshInstance" parent="."]
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="TorsoCollider" type="CollisionShape" parent="."]
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="FrontLeft" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 0.5, -1.62921e-07, -0.866025, -3.25841e-07, -1, 0, -0.866025, 2.82187e-07, -0.5, 0.6, 0, 1 )
|
||||||
|
|
||||||
|
[node name="FrontLeftAttachMent" type="MeshInstance" parent="FrontLeft"]
|
||||||
|
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 0, 0.3, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="Area" type="Area" parent="FrontLeft"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="FrontLeft/Area"]
|
||||||
|
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||||
|
shape = SubResource( 4 )
|
||||||
|
|
||||||
|
[node name="FrontRight" type="Spatial" parent="."]
|
||||||
|
transform = Transform( 0.5, -1.62921e-07, 0.866025, -3.25841e-07, -1, 0, 0.866025, -2.82187e-07, -0.5, -0.6, 0, 1 )
|
||||||
|
|
||||||
|
[node name="FrontRightAttachMent" type="MeshInstance" parent="FrontRight"]
|
||||||
|
transform = Transform( 0.3, 0, 0, 0, 0.3, 0, 0, 5.0822e-21, 0.3, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 3 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="Area" type="Area" parent="FrontRight"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="FrontRight/Area"]
|
||||||
|
transform = Transform( 0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0 )
|
||||||
|
shape = SubResource( 5 )
|
44
BodyParts/BodyPart.gd
Normal file
44
BodyParts/BodyPart.gd
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
extends Spatial
|
||||||
|
class_name BodyPart
|
||||||
|
|
||||||
|
# Must be the direct child of an AttachmentPoint of the BodyBase
|
||||||
|
|
||||||
|
|
||||||
|
onready var base = get_parent().get_parent()
|
||||||
|
onready var physics_shape = get_node("PartCollider")
|
||||||
|
|
||||||
|
export(int) var key
|
||||||
|
|
||||||
|
var setup_done = false
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
assert(base is BodyBase)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
# We do this here because we want the whole tree to really be done instancing
|
||||||
|
if not setup_done:
|
||||||
|
var translation = physics_shape.global_transform
|
||||||
|
print(translation)
|
||||||
|
|
||||||
|
remove_child(physics_shape)
|
||||||
|
base.add_child(physics_shape)
|
||||||
|
|
||||||
|
physics_shape.global_transform = translation
|
||||||
|
|
||||||
|
setup_done = true
|
||||||
|
|
||||||
|
|
||||||
|
func _unhandled_input(event):
|
||||||
|
if event is InputEventKey:
|
||||||
|
if event.pressed and event.scancode == key:
|
||||||
|
action()
|
||||||
|
|
||||||
|
|
||||||
|
# Do something with the base
|
||||||
|
func action():
|
||||||
|
pass
|
9
BodyParts/BodyPart.tscn
Normal file
9
BodyParts/BodyPart.tscn
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://BodyParts/BodyPart.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="BodyPart" type="Spatial"]
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="PartCollider" type="CollisionShape" parent="."]
|
23
BodyParts/PushingBodyPart.gd
Normal file
23
BodyParts/PushingBodyPart.gd
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
extends BodyPart
|
||||||
|
class_name PushingBodyPart
|
||||||
|
|
||||||
|
onready var touch_area = get_node("TouchArea")
|
||||||
|
|
||||||
|
export(float) var damage = 10.0
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
touch_area.connect("body_entered", self, "_on_touch_area_entered")
|
||||||
|
|
||||||
|
|
||||||
|
func _on_touch_area_entered(body):
|
||||||
|
if body.name != base.name:
|
||||||
|
if body.is_in_group("Terrain"):
|
||||||
|
push(body)
|
||||||
|
elif body.is_in_group("Player"):
|
||||||
|
InGameState.subtract_player_health(body.player_id, damage)
|
||||||
|
|
||||||
|
|
||||||
|
func push(body):
|
||||||
|
pass
|
10
BodyParts/PushingBodyPart.tscn
Normal file
10
BodyParts/PushingBodyPart.tscn
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://BodyParts/BodyPart.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://BodyParts/PushingBodyPart.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="PushingBodyPart" index="0" instance=ExtResource( 1 )]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="TouchArea" type="Area" parent="." index="1"]
|
14
BodyParts/Tesso.tscn
Normal file
14
BodyParts/Tesso.tscn
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[sub_resource type="CubeMesh" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=2]
|
||||||
|
|
||||||
|
[node name="Torso" type="RigidBody"]
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
|
shape = SubResource( 2 )
|
7
Global/BodyPartLoader.gd
Normal file
7
Global/BodyPartLoader.gd
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
var bodyparts : Dictionary
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
bodyparts["Arm"] = load("res://BodyParts/Arm.tscn")
|
39
Global/InGameState.gd
Normal file
39
Global/InGameState.gd
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
var max_health = 100.0
|
||||||
|
var player_healths = []
|
||||||
|
var player_count: int
|
||||||
|
|
||||||
|
signal player_win(player_id)
|
||||||
|
signal player_count_updated(new_player_count)
|
||||||
|
signal player_health_updated(player_id, new_player_health)
|
||||||
|
|
||||||
|
|
||||||
|
func set_player_count(new_player_count: int):
|
||||||
|
assert(new_player_count <= 4)
|
||||||
|
|
||||||
|
player_count = new_player_count
|
||||||
|
player_healths = []
|
||||||
|
|
||||||
|
for i in range(0, player_count):
|
||||||
|
player_healths.append(0.0)
|
||||||
|
set_player_health(i, max_health)
|
||||||
|
|
||||||
|
emit_signal("player_count_updated", new_player_count)
|
||||||
|
|
||||||
|
|
||||||
|
func subtract_player_health(player_id, subtractor):
|
||||||
|
set_player_health(player_id, player_healths[player_id] - subtractor)
|
||||||
|
|
||||||
|
|
||||||
|
func set_player_health(player_id, new_value):
|
||||||
|
assert(player_id < player_count)
|
||||||
|
assert(player_id >= 0)
|
||||||
|
|
||||||
|
player_healths[player_id] = new_value
|
||||||
|
|
||||||
|
if player_healths[player_id] < 0.0:
|
||||||
|
emit_signal("player_win", player_id)
|
||||||
|
else:
|
||||||
|
emit_signal("player_health_updated", player_id, player_healths[player_id])
|
16
Ingame/Ingame.gd
Normal file
16
Ingame/Ingame.gd
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a: int = 2
|
||||||
|
# var b: String = "text"
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
InGameState.set_player_count(2)
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta: float) -> void:
|
||||||
|
# pass
|
60
Ingame/Testing.tscn
Normal file
60
Ingame/Testing.tscn
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
[gd_scene load_steps=7 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://BodyParts/Arm.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://UI/UI.tscn" type="PackedScene" id=2]
|
||||||
|
[ext_resource path="res://BodyParts/BodyBase/BodyBase.tscn" type="PackedScene" id=3]
|
||||||
|
[ext_resource path="res://Ingame/Ingame.gd" type="Script" id=4]
|
||||||
|
|
||||||
|
[sub_resource type="PlaneMesh" id=1]
|
||||||
|
size = Vector2( 10, 10 )
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape" id=2]
|
||||||
|
extents = Vector3( 5, 1, 5 )
|
||||||
|
|
||||||
|
[node name="InGame" type="Spatial"]
|
||||||
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
|
transform = Transform( 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0 )
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="MeshInstance" groups=[
|
||||||
|
"Terrain",
|
||||||
|
]]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="Camera" type="Camera" parent="."]
|
||||||
|
transform = Transform( -4.37114e-08, -0.5, 0.866025, 0, 0.866025, 0.5, -1, 2.18557e-08, -3.78552e-08, 17, 9, -2 )
|
||||||
|
|
||||||
|
[node name="DirectionalLight" type="DirectionalLight" parent="."]
|
||||||
|
transform = Transform( 0.999532, 0.0126075, 0.027872, -0.0305909, 0.411942, 0.910697, 0, -0.911123, 0.412135, 0, 0, 0 )
|
||||||
|
shadow_enabled = true
|
||||||
|
|
||||||
|
[node name="Torso" parent="." instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.02111, 0 )
|
||||||
|
|
||||||
|
[node name="Arm" parent="Torso/FrontLeft" index="1" instance=ExtResource( 1 )]
|
||||||
|
key = 83
|
||||||
|
|
||||||
|
[node name="Arm" parent="Torso/FrontRight" index="1" instance=ExtResource( 1 )]
|
||||||
|
key = 65
|
||||||
|
|
||||||
|
[node name="Torso2" parent="." instance=ExtResource( 3 )]
|
||||||
|
transform = Transform( -0.866025, -0.353553, -0.353553, -6.18172e-08, -0.707107, 0.707107, -0.5, 0.612372, 0.612372, 0, 3.02111, -9 )
|
||||||
|
player_id = 1
|
||||||
|
|
||||||
|
[node name="Arm" parent="Torso2/FrontLeft" index="1" instance=ExtResource( 1 )]
|
||||||
|
key = 81
|
||||||
|
|
||||||
|
[node name="Arm" parent="Torso2/FrontRight" index="1" instance=ExtResource( 1 )]
|
||||||
|
key = 87
|
||||||
|
|
||||||
|
[node name="UI" parent="." instance=ExtResource( 2 )]
|
||||||
|
|
||||||
|
[editable path="Torso"]
|
||||||
|
|
||||||
|
[editable path="Torso2"]
|
21
UI/PlayerHealth.gd
Normal file
21
UI/PlayerHealth.gd
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
extends ProgressBar
|
||||||
|
|
||||||
|
|
||||||
|
export(int) var player_id
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
InGameState.connect("player_health_updated", self, "_on_player_health_updated")
|
||||||
|
|
||||||
|
max_value = InGameState.max_health
|
||||||
|
|
||||||
|
|
||||||
|
func _on_player_health_updated(updated_id, updated_health):
|
||||||
|
if player_id == updated_id:
|
||||||
|
value = updated_health
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta: float) -> void:
|
||||||
|
# pass
|
81
UI/UI.tscn
Normal file
81
UI/UI.tscn
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://UI/PlayerHealth.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="UI" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_left = 20.0
|
||||||
|
margin_top = 20.0
|
||||||
|
margin_right = -20.0
|
||||||
|
margin_bottom = -20.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="PlayerHealthController" type="Control" parent="MarginContainer"]
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 560.0
|
||||||
|
|
||||||
|
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer/PlayerHealthController"]
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 560.0
|
||||||
|
split_offset = 902
|
||||||
|
dragger_visibility = 2
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="HSplitContainer" type="HSplitContainer" parent="MarginContainer/PlayerHealthController/VSplitContainer"]
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 560.0
|
||||||
|
split_offset = 492
|
||||||
|
dragger_visibility = 1
|
||||||
|
|
||||||
|
[node name="Player1Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer"]
|
||||||
|
margin_right = 496.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player2Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer"]
|
||||||
|
margin_left = 508.0
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
player_id = 1
|
||||||
|
|
||||||
|
[node name="HSplitContainer2" type="HSplitContainer" parent="MarginContainer/PlayerHealthController/VSplitContainer"]
|
||||||
|
visible = false
|
||||||
|
margin_top = 546.0
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 560.0
|
||||||
|
split_offset = 492
|
||||||
|
dragger_visibility = 1
|
||||||
|
|
||||||
|
[node name="Player3Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer2"]
|
||||||
|
margin_right = 496.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[node name="Player4Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer2"]
|
||||||
|
margin_left = 508.0
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 14.0
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
37
UI/WinScreen.tscn
Normal file
37
UI/WinScreen.tscn
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://UI/WinScreenScript.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[node name="Spatial" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
labelPath = NodePath("MarginContainer/VBoxContainer/PlayerWon")
|
||||||
|
|
||||||
|
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 600.0
|
||||||
|
|
||||||
|
[node name="Congratz" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||||
|
margin_top = -1.0
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 249.0
|
||||||
|
rect_min_size = Vector2( 0, 250 )
|
||||||
|
text = "CONGRATULATIONS!"
|
||||||
|
align = 1
|
||||||
|
valign = 2
|
||||||
|
|
||||||
|
[node name="PlayerWon" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||||
|
margin_top = 254.0
|
||||||
|
margin_right = 1024.0
|
||||||
|
margin_bottom = 404.0
|
||||||
|
rect_min_size = Vector2( 0, 150 )
|
||||||
|
align = 1
|
||||||
|
valign = 1
|
22
UI/WinScreenScript.gd
Normal file
22
UI/WinScreenScript.gd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
export(NodePath) var labelPath
|
||||||
|
|
||||||
|
#signal player_win(player_id)
|
||||||
|
|
||||||
|
var _playerWonLabel
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
_playerWonLabel = get_node(labelPath) as Label
|
||||||
|
|
||||||
|
#connect("player_win", self, "_win_message")
|
||||||
|
|
||||||
|
#emit_signal("player_win", 1)
|
||||||
|
|
||||||
|
|
||||||
|
func _win_message(player_id):
|
||||||
|
_playerWonLabel.text = "test"
|
||||||
|
|
||||||
|
#print("game won!")
|
||||||
|
#print(player_id)
|
@ -1,5 +1,7 @@
|
|||||||
[gd_resource type="Environment" load_steps=2 format=2]
|
[gd_resource type="Environment" load_steps=2 format=2]
|
||||||
|
|
||||||
[sub_resource type="ProceduralSky" id=1]
|
[sub_resource type="ProceduralSky" id=1]
|
||||||
|
|
||||||
[resource]
|
[resource]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
background_sky = SubResource( 1 )
|
background_sky = SubResource( 1 )
|
||||||
|
@ -8,16 +8,39 @@
|
|||||||
|
|
||||||
config_version=4
|
config_version=4
|
||||||
|
|
||||||
_global_script_classes=[ ]
|
_global_script_classes=[ {
|
||||||
|
"base": "Spatial",
|
||||||
|
"class": "BodyBase",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://BodyParts/BodyBase/BodyBase.gd"
|
||||||
|
}, {
|
||||||
|
"base": "Spatial",
|
||||||
|
"class": "BodyPart",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://BodyParts/BodyPart.gd"
|
||||||
|
}, {
|
||||||
|
"base": "BodyPart",
|
||||||
|
"class": "PushingBodyPart",
|
||||||
|
"language": "GDScript",
|
||||||
|
"path": "res://BodyParts/PushingBodyPart.gd"
|
||||||
|
} ]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
|
"BodyBase": "",
|
||||||
|
"BodyPart": "",
|
||||||
|
"PushingBodyPart": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="New Game Project"
|
config/name="BodyPartFighter"
|
||||||
|
run/main_scene="res://Ingame/Testing.tscn"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
InGameState="*res://Global/InGameState.gd"
|
||||||
|
BodyPartLoader="*res://Global/BodyPartLoader.gd"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
environment/default_environment="res://default_env.tres"
|
environment/default_environment="res://default_env.tres"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user