]> Untitled Git - star-foxy.git/commitdiff
Initial flight mechanics
authorClifton Palmer <clifton.james.palmer@protonmail.com>
Sun, 14 Nov 2021 18:03:31 +0000 (12:03 -0600)
committerClifton Palmer <clifton.james.palmer@protonmail.com>
Sun, 14 Nov 2021 18:03:31 +0000 (12:03 -0600)
main.tscn [new file with mode: 0644]
player/player.gd [new file with mode: 0644]
player/player.tscn
project.godot

diff --git a/main.tscn b/main.tscn
new file mode 100644 (file)
index 0000000..9ab4da0
--- /dev/null
+++ b/main.tscn
@@ -0,0 +1,19 @@
+[gd_scene load_steps=2 format=2]
+
+[ext_resource path="res://player/player.tscn" type="PackedScene" id=1]
+
+[node name="world" type="Spatial"]
+
+[node name="boxes" type="Spatial" parent="."]
+
+[node name="CSGBox" type="CSGBox" parent="boxes"]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 8 )
+
+[node name="CSGBox2" type="CSGBox" parent="boxes"]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 10.6742, 0, 0 )
+
+[node name="CSGBox3" type="CSGBox" parent="boxes"]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -11.353, 0, 0 )
+
+[node name="arwing" parent="." instance=ExtResource( 1 )]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0547695, 0, 35.9027 )
diff --git a/player/player.gd b/player/player.gd
new file mode 100644 (file)
index 0000000..0dbb6d9
--- /dev/null
@@ -0,0 +1,36 @@
+extends KinematicBody
+
+const SPEED = 20
+
+var velocity = Vector3()
+
+# Called when the node enters the scene tree for the first time.
+func _ready():
+       pass # Replace with function body.
+
+func get_player_input(delta):
+       var cam_vec_lateral = $Camera.transform.basis.x
+       var cam_vec_vertical = $Camera.transform.basis.y
+       
+       
+       if Input.is_action_pressed("player_left"):
+               velocity += SPEED * cam_vec_lateral * delta
+       elif Input.is_action_pressed("player_right"):
+               velocity += SPEED * -cam_vec_lateral * delta
+               
+       if Input.is_action_pressed("player_up"):
+               velocity += SPEED * cam_vec_vertical * delta
+       elif Input.is_action_pressed("player_down"):
+               velocity += SPEED * -cam_vec_vertical * delta
+               
+               
+func _process(delta):
+       # move foward according to the camera's POV
+       var cam_vec_forward = $Camera.transform.basis.z
+       velocity += SPEED * -cam_vec_forward * delta
+       
+       # get velocity changes player asks for
+       get_player_input(delta)
+       
+func _physics_process(_delta):
+       velocity = move_and_slide(velocity, Vector3.UP)
index 60631c215cdf4cef97effe58b4c534e9fa8a89cf..7ef0343196ce27e87a38c7aab99ef6378595cf2c 100644 (file)
@@ -1,7 +1,8 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=9 format=2]
 
 [ext_resource path="res://model/arwing_wings.material" type="Material" id=1]
 [ext_resource path="res://model/arwing_body.material" type="Material" id=2]
 
 [ext_resource path="res://model/arwing_wings.material" type="Material" id=1]
 [ext_resource path="res://model/arwing_body.material" type="Material" id=2]
+[ext_resource path="res://player/player.gd" type="Script" id=3]
 
 [sub_resource type="SpatialMaterial" id=1]
 vertex_color_use_as_albedo = true
 
 [sub_resource type="SpatialMaterial" id=1]
 vertex_color_use_as_albedo = true
@@ -52,22 +53,29 @@ surfaces/0 = {
 }
 
 [sub_resource type="BoxShape" id=5]
 }
 
 [sub_resource type="BoxShape" id=5]
-extents = Vector3( 3.72203, 0.878147, 2.99408 )
+extents = Vector3( 3.72203, 0.878147, 3.13957 )
 
 [node name="arwing" type="KinematicBody"]
 
 [node name="arwing" type="KinematicBody"]
+script = ExtResource( 3 )
 
 
-[node name="body" type="MeshInstance" parent="."]
+[node name="mesh" type="Spatial" parent="."]
+transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0 )
+
+[node name="body" type="MeshInstance" parent="mesh"]
 mesh = SubResource( 2 )
 material/0 = null
 
 mesh = SubResource( 2 )
 material/0 = null
 
-[node name="thrust" type="MeshInstance" parent="."]
+[node name="thrust" type="MeshInstance" parent="mesh"]
 mesh = SubResource( 3 )
 material/0 = null
 
 mesh = SubResource( 3 )
 material/0 = null
 
-[node name="wings" type="MeshInstance" parent="."]
+[node name="wings" type="MeshInstance" parent="mesh"]
 mesh = SubResource( 4 )
 material/0 = null
 
 [node name="CollisionShape" type="CollisionShape" parent="."]
 mesh = SubResource( 4 )
 material/0 = null
 
 [node name="CollisionShape" type="CollisionShape" parent="."]
-transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.371765, 0.63321 )
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.371765, -0.470031 )
 shape = SubResource( 5 )
 shape = SubResource( 5 )
+
+[node name="Camera" type="Camera" parent="."]
+transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 13.3084 )
index 9f02eae9a4576cd1d673a884ba2c5b0f907782c2..9fb6ae29589a8be3fd6d8b4f4340dcc70d489bac 100644 (file)
@@ -11,8 +11,42 @@ config_version=4
 [application]
 
 config/name="star-foxy"
 [application]
 
 config/name="star-foxy"
+run/main_scene="res://main.tscn"
 config/icon="res://icon.png"
 
 config/icon="res://icon.png"
 
+[input]
+
+player_up={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
+ ]
+}
+player_down={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
+ ]
+}
+player_left={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
+ ]
+}
+player_right={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
+ ]
+}
+player_boost={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
+ ]
+}
+player_fire={
+"deadzone": 0.5,
+"events": [ Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":7,"pressure":0.0,"pressed":false,"script":null)
+ ]
+}
+
 [physics]
 
 common/enable_pause_aware_picking=true
 [physics]
 
 common/enable_pause_aware_picking=true