collector singleton for collectibles

This commit is contained in:
SyntaX 2019-11-23 14:23:09 +01:00
parent bdbb1c7e32
commit 44100b2b0d
5 changed files with 24 additions and 12 deletions

View File

@ -2,12 +2,12 @@
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
[sub_resource type="NavigationMesh" id=1] [sub_resource type="NavigationMesh" id=3]
[sub_resource type="BoxShape" id=2] [sub_resource type="BoxShape" id=2]
extents = Vector3( 10, 1, 10 ) extents = Vector3( 10, 1, 10 )
[sub_resource type="PlaneMesh" id=3] [sub_resource type="PlaneMesh" id=4]
size = Vector2( 20, 20 ) size = Vector2( 20, 20 )
[node name="Level" type="Spatial"] [node name="Level" type="Spatial"]
@ -18,7 +18,7 @@ size = Vector2( 20, 20 )
editor/display_folded = true editor/display_folded = true
[node name="NavigationMeshInstance" type="NavigationMeshInstance" parent="Navigation"] [node name="NavigationMeshInstance" type="NavigationMeshInstance" parent="Navigation"]
navmesh = SubResource( 1 ) navmesh = SubResource( 3 )
[node name="StaticBody" type="StaticBody" parent="Navigation/NavigationMeshInstance"] [node name="StaticBody" type="StaticBody" parent="Navigation/NavigationMeshInstance"]
@ -27,6 +27,6 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="Navigation/NavigationMeshInstance"] [node name="MeshInstance" type="MeshInstance" parent="Navigation/NavigationMeshInstance"]
mesh = SubResource( 3 ) mesh = SubResource( 4 )
skeleton = NodePath("") skeleton = NodePath("")
material/0 = null material/0 = null

View File

@ -7,5 +7,5 @@ onready var steps = [
func play_footstep(): func play_footstep():
#Logger.trace("Footstep") Logger.trace("Footstep")
steps[0].play() steps[0].play()

View File

@ -49,13 +49,13 @@ func _ready():
func _physics_process(delta): func _physics_process(delta):
process_input() _process_input()
process_movement(delta) _process_movement(delta)
func _process(_delta): func _process(_delta):
process_animations() _process_animations()
func process_input(): func _process_input():
# Walking # Walking
var input_movement_vector = Vector2() var input_movement_vector = Vector2()
if Input.is_action_pressed("move_fwrd"): if Input.is_action_pressed("move_fwrd"):
@ -81,7 +81,7 @@ func process_input():
_is_sprinting = Input.is_action_pressed("move_sprint") _is_sprinting = Input.is_action_pressed("move_sprint")
func process_movement(delta): func _process_movement(delta):
_vel.y += delta * GRAVITY _vel.y += delta * GRAVITY
# set movement speed # set movement speed
@ -94,7 +94,7 @@ func process_movement(delta):
_vel = move_and_slide(_vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE)) _vel = move_and_slide(_vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
func process_animations(): func _process_animations():
_animation.playback_speed = _vel.length() / MOVE_SPEED _animation.playback_speed = _vel.length() / MOVE_SPEED

11
WikiJam/Util/Collector.gd Normal file
View File

@ -0,0 +1,11 @@
extends Node
var _collectibles: Array
func addCollectible (coll):
_collectibles.append(coll)
func getCount ():
return _collectibles.size()

View File

@ -57,12 +57,13 @@ _global_script_class_icons={
[application] [application]
config/name="WikiJam" config/name="WikiJam"
run/main_scene="res://Level/Fortaleza.tscn" run/main_scene="res://Level/Level.tscn"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload] [autoload]
Logger="*res://Util/gs_logger/logger.gd" Logger="*res://Util/gs_logger/logger.gd"
Collector="*res://Util/Collector.gd"
[input] [input]