Merge branch 'master' of https://gitlab.hexaquo.at/Light/fhwikijam
This commit is contained in:
commit
ae3a1a6e29
File diff suppressed because one or more lines are too long
@ -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
|
||||||
|
5
WikiJam/Level/Objects/Crystal.gd
Normal file
5
WikiJam/Level/Objects/Crystal.gd
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
Collector.addCollectible(self)
|
20
WikiJam/Level/Objects/Crystal.tscn
Normal file
20
WikiJam/Level/Objects/Crystal.tscn
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Level/Objects/Crystal.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleMesh" id=1]
|
||||||
|
|
||||||
|
[node name="Crystal" type="Spatial"]
|
||||||
|
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 2, 0 )
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="CrystalBody" type="StaticBody" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="CrystalBody"]
|
||||||
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="MeshInstance" type="MeshInstance" parent="CrystalBody"]
|
||||||
|
mesh = SubResource( 1 )
|
||||||
|
material/0 = null
|
@ -2,10 +2,9 @@ extends KinematicBody
|
|||||||
|
|
||||||
# export variables
|
# export variables
|
||||||
export(NodePath) var body_nodepath
|
export(NodePath) var body_nodepath
|
||||||
#export(NodePath) var lookingAt_nodepath
|
export(NodePath) var camera_nodepath
|
||||||
export(NodePath) var animation_nodepath
|
export(NodePath) var animation_nodepath
|
||||||
export(NodePath) var ui_nodepath
|
export(NodePath) var ui_nodepath
|
||||||
export(NodePath) var camera_nodepath
|
|
||||||
|
|
||||||
# const
|
# const
|
||||||
const GRAVITY = -24.8
|
const GRAVITY = -24.8
|
||||||
@ -20,7 +19,6 @@ const INTERACT_DISTANCE = 4
|
|||||||
# private members
|
# private members
|
||||||
var _body: Spatial
|
var _body: Spatial
|
||||||
var _camera: Camera
|
var _camera: Camera
|
||||||
#var _lookCast: RayCast
|
|
||||||
var _animation: AnimationPlayer
|
var _animation: AnimationPlayer
|
||||||
var _interface: Control
|
var _interface: Control
|
||||||
var _dir = Vector3();
|
var _dir = Vector3();
|
||||||
@ -39,23 +37,24 @@ func _ready():
|
|||||||
_animation = get_node(animation_nodepath) as AnimationPlayer
|
_animation = get_node(animation_nodepath) as AnimationPlayer
|
||||||
assert(null != _animation)
|
assert(null != _animation)
|
||||||
|
|
||||||
# Setup mouse look
|
|
||||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
|
||||||
#_lookCast = get_node(lookingAt_nodepath) as RayCast
|
|
||||||
#_lookCast.cast_to = Vector3(0, 0, INTERACT_DISTANCE)
|
|
||||||
|
|
||||||
_interface = get_node(ui_nodepath) as Control
|
_interface = get_node(ui_nodepath) as Control
|
||||||
assert(null != _interface)
|
assert(null != _interface)
|
||||||
|
|
||||||
|
# Setup mouse look
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
process_input()
|
_process_input()
|
||||||
process_movement(delta)
|
_process_movement(delta)
|
||||||
|
_process_collision()
|
||||||
|
|
||||||
|
|
||||||
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 +80,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,10 +93,24 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
func _process_collision():
|
||||||
|
var collCount = get_slide_count()
|
||||||
|
if collCount > 0:
|
||||||
|
#Logger.debug("Collide count: ", collCount)
|
||||||
|
for i in collCount:
|
||||||
|
var collision = get_slide_collision(i)
|
||||||
|
#Logger.debug("Collided with: ", collision.collider.name)
|
||||||
|
#TODO: replace with groups
|
||||||
|
if collision.collider.name == "CrystalBody":
|
||||||
|
#Logger.debug("removing crystal...")
|
||||||
|
collision.collider.queue_free()
|
||||||
|
_interface.increaseScore()
|
||||||
|
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
# capture mouse movement
|
# capture mouse movement
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
|
@ -42,12 +42,12 @@ tracks/1/keys = {
|
|||||||
} ]
|
} ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Spatial" type="KinematicBody"]
|
[node name="Player" type="KinematicBody"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
body_nodepath = NodePath("Body")
|
body_nodepath = NodePath("Body")
|
||||||
|
camera_nodepath = NodePath("Camera")
|
||||||
animation_nodepath = NodePath("WalkAnimationPlayer")
|
animation_nodepath = NodePath("WalkAnimationPlayer")
|
||||||
ui_nodepath = NodePath("HUD")
|
ui_nodepath = NodePath("HUD")
|
||||||
camera_nodepath = NodePath("Camera")
|
|
||||||
|
|
||||||
[node name="Body" type="Spatial" parent="."]
|
[node name="Body" type="Spatial" parent="."]
|
||||||
|
|
||||||
@ -73,6 +73,7 @@ pitch_scale = 1.5
|
|||||||
|
|
||||||
[node name="HUD" parent="." instance=ExtResource( 4 )]
|
[node name="HUD" parent="." instance=ExtResource( 4 )]
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
label_nodepath = NodePath("LabelScore")
|
||||||
|
|
||||||
[node name="LabelScore" type="Label" parent="HUD"]
|
[node name="LabelScore" type="Label" parent="HUD"]
|
||||||
margin_left = 15.0
|
margin_left = 15.0
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
# Declare member variables here. Examples:
|
export(NodePath) var label_nodepath
|
||||||
# var a = 2
|
|
||||||
# var b = "text"
|
const SCORE = 100
|
||||||
|
|
||||||
|
var _labelScore: Label
|
||||||
|
var _score: int = 0
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
func _ready():
|
||||||
pass # Replace with function body.
|
_labelScore = get_node(label_nodepath) as Label
|
||||||
|
assert(null != _labelScore)
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
#func _process(delta):
|
func increaseScore():
|
||||||
# pass
|
_score += SCORE
|
||||||
|
_labelScore.text = "Score: " + String(_score)
|
||||||
|
if (_score / SCORE == Collector.getCount()):
|
||||||
|
Logger.info("YOU WON!")
|
||||||
|
|
13
WikiJam/Util/Collector.gd
Normal file
13
WikiJam/Util/Collector.gd
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
var _collectibles: Array
|
||||||
|
|
||||||
|
|
||||||
|
func addCollectible (coll):
|
||||||
|
Logger.info("appending new collectible: " + String(coll.get_instance_id()))
|
||||||
|
Logger.info("current collection count: " + String(Collector.getCount()))
|
||||||
|
_collectibles.append(coll)
|
||||||
|
|
||||||
|
|
||||||
|
func getCount ():
|
||||||
|
return _collectibles.size()
|
@ -63,6 +63,7 @@ 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]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user