Update source layout
This commit is contained in:
parent
a3b7a3a0f9
commit
3706fa6774
10 changed files with 14 additions and 12 deletions
8
scenes/Goal.gd
Normal file
8
scenes/Goal.gd
Normal file
|
@ -0,0 +1,8 @@
|
|||
extends Spatial
|
||||
|
||||
func _ready():
|
||||
get_node("Area").connect("body_entered", self, "collided")
|
||||
|
||||
func collided(body):
|
||||
if body.has_method("reach_goal"):
|
||||
body.reach_goal()
|
63
scenes/Goal.tscn
Normal file
63
scenes/Goal.tscn
Normal file
|
@ -0,0 +1,63 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://models/flag.glb" type="PackedScene" id=1]
|
||||
[ext_resource path="res://scenes/Goal.gd" type="Script" id=2]
|
||||
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
|
||||
extents = Vector3( 0.584547, 2.22627, 0.659734 )
|
||||
|
||||
[node name="Scene Root" index="0" instance=ExtResource( 1 )]
|
||||
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="Flag" parent="Pole" index="0"]
|
||||
|
||||
transform = Transform( 5, 0, 0, 0, -4.37114e-08, -0.5, 0, 1, -2.18557e-08, 4.02201, 0.453122, 0 )
|
||||
_sections_unfolded = [ "Transform" ]
|
||||
|
||||
[node name="Flag.001" parent="Pole" index="1"]
|
||||
|
||||
transform = Transform( 5, 0, 0, 0, -4.37114e-08, -0.5, 0, 1, -2.18557e-08, 5.99137, 0.443566, -0.191931 )
|
||||
_sections_unfolded = [ "Transform" ]
|
||||
|
||||
[node name="Lamp" parent="." index="1"]
|
||||
|
||||
visible = false
|
||||
|
||||
[node name="Camera" parent="." index="2"]
|
||||
|
||||
editor/display_folded = true
|
||||
visible = false
|
||||
|
||||
[node name="Area" type="Area" parent="." index="3"]
|
||||
|
||||
input_ray_pickable = false
|
||||
input_capture_on_drag = false
|
||||
space_override = 0
|
||||
gravity_point = false
|
||||
gravity_distance_scale = 0.0
|
||||
gravity_vec = Vector3( 0, -1, 0 )
|
||||
gravity = 9.8
|
||||
linear_damp = 0.1
|
||||
angular_damp = 1.0
|
||||
priority = 0.0
|
||||
monitoring = true
|
||||
monitorable = true
|
||||
collision_layer = 1
|
||||
collision_mask = 1
|
||||
audio_bus_override = false
|
||||
audio_bus_name = "Master"
|
||||
reverb_bus_enable = false
|
||||
reverb_bus_name = "Master"
|
||||
reverb_bus_amount = 0.0
|
||||
reverb_bus_uniformity = 0.0
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="Area" index="0"]
|
||||
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2251, 0 )
|
||||
shape = SubResource( 1 )
|
||||
disabled = false
|
||||
|
||||
|
19
scenes/Hedgehog.tscn
Normal file
19
scenes/Hedgehog.tscn
Normal file
|
@ -0,0 +1,19 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://models/hedgehog.glb" type="PackedScene" id=1]
|
||||
|
||||
[node name="Hedgehog" index="0" instance=ExtResource( 1 )]
|
||||
|
||||
[node name="Hedgehog" parent="." index="0"]
|
||||
|
||||
_sections_unfolded = [ "material" ]
|
||||
|
||||
[node name="Lamp" parent="." index="1"]
|
||||
|
||||
visible = false
|
||||
|
||||
[node name="Camera" parent="." index="2"]
|
||||
|
||||
visible = false
|
||||
|
||||
|
44
scenes/Player.gd
Normal file
44
scenes/Player.gd
Normal file
|
@ -0,0 +1,44 @@
|
|||
extends KinematicBody
|
||||
|
||||
const norm_gravity = -100
|
||||
var velocity = Vector3()
|
||||
const MAX_SLOPE_ANGLE = 60
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
|
||||
func _physics_process(delta):
|
||||
# Keyboard input
|
||||
var direction = Vector3()
|
||||
|
||||
if Input.is_action_pressed("ui_up"):
|
||||
direction += Vector3(0, 0, -1)
|
||||
if Input.is_action_pressed("ui_down"):
|
||||
direction += Vector3(0, 0, 1)
|
||||
if Input.is_action_pressed("ui_left"):
|
||||
direction += Vector3(-1, 0, 0)
|
||||
if Input.is_action_pressed("ui_right"):
|
||||
direction += Vector3(1, 0, 0)
|
||||
|
||||
direction.y = 0
|
||||
direction = direction.normalized()
|
||||
|
||||
# Speed
|
||||
var speed = 3.0
|
||||
direction *= speed
|
||||
|
||||
# Gravity
|
||||
direction.y = norm_gravity * delta
|
||||
|
||||
# Collision
|
||||
var floor_normal = Vector3(0, 1, 0)
|
||||
velocity = move_and_slide(direction, floor_normal, 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# Called every frame. Delta is time since last frame.
|
||||
# Update game logic here.
|
||||
pass
|
||||
|
||||
func reach_goal():
|
||||
print("Reached goal")
|
37
scenes/Player.tscn
Normal file
37
scenes/Player.tscn
Normal file
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scenes/Hedgehog.tscn" type="PackedScene" id=2]
|
||||
|
||||
|
||||
|
||||
[sub_resource type="BoxShape" id=1]
|
||||
|
||||
extents = Vector3( 1, 1, 1 )
|
||||
|
||||
[node name="Player" type="KinematicBody"]
|
||||
|
||||
input_ray_pickable = true
|
||||
input_capture_on_drag = false
|
||||
collision_layer = 1
|
||||
collision_mask = 1
|
||||
axis_lock_linear_x = false
|
||||
axis_lock_linear_y = false
|
||||
axis_lock_linear_z = false
|
||||
axis_lock_angular_x = false
|
||||
axis_lock_angular_y = false
|
||||
axis_lock_angular_z = false
|
||||
collision/safe_margin = 0.001
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="." index="0"]
|
||||
|
||||
shape = SubResource( 1 )
|
||||
disabled = false
|
||||
|
||||
[node name="Hedgehog" parent="." index="1" instance=ExtResource( 2 )]
|
||||
|
||||
transform = Transform( 0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0 )
|
||||
_sections_unfolded = [ "Transform" ]
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue