mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-07-12 18:43:49 +00:00
feat(*): Add basic 2 player splitscreen
This commit is contained in:
@@ -15,6 +15,11 @@ run/main_scene="res://scenes/match.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"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1920
|
||||||
|
window/size/viewport_height=1080
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
move_forward={
|
move_forward={
|
||||||
@@ -47,6 +52,34 @@ move_down={
|
|||||||
"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":69,"key_label":0,"unicode":101,"echo":false,"script":null)
|
"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":69,"key_label":0,"unicode":101,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
move_forward2={
|
||||||
|
"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":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_backward2={
|
||||||
|
"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":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left2={
|
||||||
|
"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":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_right2={
|
||||||
|
"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":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_up2={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": []
|
||||||
|
}
|
||||||
|
move_down2={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": []
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
|
|||||||
+38
-6
@@ -1,10 +1,11 @@
|
|||||||
[gd_scene load_steps=13 format=3 uid="uid://djlfte5nx8sel"]
|
[gd_scene load_steps=14 format=3 uid="uid://djlfte5nx8sel"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dnra1buk328d" path="res://objects/vehicle.tscn" id="2_2d4ji"]
|
[ext_resource type="PackedScene" uid="uid://dnra1buk328d" path="res://objects/vehicle.tscn" id="2_2d4ji"]
|
||||||
[ext_resource type="ArrayMesh" uid="uid://ucw1lyo43yi4" path="res://assets/models/gold_ball.res" id="2_4bpxj"]
|
[ext_resource type="ArrayMesh" uid="uid://ucw1lyo43yi4" path="res://assets/models/gold_ball.res" id="2_4bpxj"]
|
||||||
[ext_resource type="Script" path="res://scripts/MatchCamera3D.gd" id="2_n3g6s"]
|
[ext_resource type="Script" path="res://scripts/MatchCamera3D.gd" id="2_n3g6s"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cofdcxo5170rs" path="res://objects/goal.tscn" id="3_xk008"]
|
[ext_resource type="PackedScene" uid="uid://cofdcxo5170rs" path="res://objects/goal.tscn" id="3_xk008"]
|
||||||
[ext_resource type="Script" path="res://scripts/goal2.gd" id="4_ukkeh"]
|
[ext_resource type="Script" path="res://scripts/player1.gd" id="4_keuru"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/player2.gd" id="4_vutck"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xmumy"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_xmumy"]
|
||||||
albedo_color = Color(0.0196078, 0.34902, 0.156863, 1)
|
albedo_color = Color(0.0196078, 0.34902, 0.156863, 1)
|
||||||
@@ -35,7 +36,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1.33585, 3.3972)
|
|||||||
current = true
|
current = true
|
||||||
fov = 114.877
|
fov = 114.877
|
||||||
script = ExtResource("2_n3g6s")
|
script = ExtResource("2_n3g6s")
|
||||||
vehicle = NodePath("../Players/Player1")
|
vehicle = NodePath("../Players/GridContainer/SubViewportContainer/SubViewport/Player1")
|
||||||
ball = NodePath("../Ball")
|
ball = NodePath("../Ball")
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
@@ -66,15 +67,46 @@ mesh = ExtResource("2_4bpxj")
|
|||||||
|
|
||||||
[node name="Players" type="Node3D" parent="."]
|
[node name="Players" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Player1" parent="Players" instance=ExtResource("2_2d4ji")]
|
[node name="GridContainer" type="GridContainer" parent="Players"]
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
columns = 2
|
||||||
|
|
||||||
|
[node name="SubViewportContainer" type="SubViewportContainer" parent="Players/GridContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="SubViewport" type="SubViewport" parent="Players/GridContainer/SubViewportContainer"]
|
||||||
|
handle_input_locally = false
|
||||||
|
size = Vector2i(1080, 960)
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="Player1" parent="Players/GridContainer/SubViewportContainer/SubViewport" instance=ExtResource("2_2d4ji")]
|
||||||
|
script = ExtResource("4_keuru")
|
||||||
|
|
||||||
|
[node name="SubViewportContainer2" type="SubViewportContainer" parent="Players/GridContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
|
[node name="SubViewport2" type="SubViewport" parent="Players/GridContainer/SubViewportContainer2"]
|
||||||
|
handle_input_locally = false
|
||||||
|
size = Vector2i(1080, 960)
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="Player2" parent="Players/GridContainer/SubViewportContainer2/SubViewport2" instance=ExtResource("2_2d4ji")]
|
||||||
|
script = ExtResource("4_vutck")
|
||||||
|
|
||||||
[node name="Goals" type="Node3D" parent="."]
|
[node name="Goals" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Goal2" parent="Goals" node_paths=PackedStringArray("ball", "player1") instance=ExtResource("3_xk008")]
|
[node name="Goal2" parent="Goals" node_paths=PackedStringArray("ball", "player1") instance=ExtResource("3_xk008")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1, -5)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.08165e-12, 1, -5)
|
||||||
script = ExtResource("4_ukkeh")
|
|
||||||
ball = NodePath("../../Ball")
|
ball = NodePath("../../Ball")
|
||||||
player1 = NodePath("../../Players/Player1")
|
player1 = NodePath("../../Players/GridContainer/SubViewportContainer/SubViewport/Player1")
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||||
environment = SubResource("Environment_ycxte")
|
environment = SubResource("Environment_ycxte")
|
||||||
|
|||||||
+13
-15
@@ -1,26 +1,24 @@
|
|||||||
extends RigidBody3D
|
extends RigidBody3D
|
||||||
|
|
||||||
var speed = 10.0 # Adjust the speed as necessary
|
# Speed variable can be adjusted by subclasses
|
||||||
|
var speed = 10.0
|
||||||
|
|
||||||
func _integrate_forces(state):
|
func _integrate_forces(state):
|
||||||
# TODO - change these so they are relative to the vehicle, not the world
|
# input_vector represents the movement input relative to the vehicle
|
||||||
var input_vector = Vector3.ZERO
|
var input_vector = get_input_vector()
|
||||||
if Input.is_action_pressed("move_forward"):
|
|
||||||
input_vector.z -= 1
|
|
||||||
if Input.is_action_pressed("move_backward"):
|
|
||||||
input_vector.z += 1
|
|
||||||
if Input.is_action_pressed("move_left"):
|
|
||||||
input_vector.x -= 1
|
|
||||||
if Input.is_action_pressed("move_right"):
|
|
||||||
input_vector.x += 1
|
|
||||||
if Input.is_action_pressed("move_up"):
|
|
||||||
input_vector.y += 1
|
|
||||||
if Input.is_action_pressed("move_down"):
|
|
||||||
input_vector.y -= 1
|
|
||||||
|
|
||||||
|
# Scale the input_vector by speed
|
||||||
input_vector = input_vector.normalized() * speed
|
input_vector = input_vector.normalized() * speed
|
||||||
|
|
||||||
|
# Set the linear velocity based on the input
|
||||||
state.linear_velocity = input_vector
|
state.linear_velocity = input_vector
|
||||||
|
|
||||||
|
# Get the input vector from subclasses
|
||||||
|
func get_input_vector() -> Vector3:
|
||||||
|
var input_vector = Vector3.ZERO
|
||||||
|
|
||||||
|
# Subclasses will implement this function to provide their input mappings
|
||||||
|
return input_vector
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
extends 'res://scripts/Vehicle.gd'
|
||||||
|
|
||||||
|
func get_input_vector() -> Vector3:
|
||||||
|
var input_vector = Vector3.ZERO
|
||||||
|
if Input.is_action_pressed("move_forward"):
|
||||||
|
input_vector.z -= 1
|
||||||
|
if Input.is_action_pressed("move_backward"):
|
||||||
|
input_vector.z += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
input_vector.x -= 1
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
input_vector.x += 1
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
input_vector.y += 1
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
input_vector.y -= 1
|
||||||
|
|
||||||
|
return input_vector
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
extends 'res://scripts/Vehicle.gd'
|
||||||
|
|
||||||
|
func get_input_vector() -> Vector3:
|
||||||
|
var input_vector = Vector3.ZERO
|
||||||
|
if Input.is_action_pressed("move_forward2"):
|
||||||
|
input_vector.z -= 1
|
||||||
|
if Input.is_action_pressed("move_backward2"):
|
||||||
|
input_vector.z += 1
|
||||||
|
if Input.is_action_pressed("move_left2"):
|
||||||
|
input_vector.x -= 1
|
||||||
|
if Input.is_action_pressed("move_right2"):
|
||||||
|
input_vector.x += 1
|
||||||
|
if Input.is_action_pressed("move_up2"):
|
||||||
|
input_vector.y += 1
|
||||||
|
if Input.is_action_pressed("move_down2"):
|
||||||
|
input_vector.y -= 1
|
||||||
|
|
||||||
|
return input_vector
|
||||||
Reference in New Issue
Block a user