This commit is contained in:
Merlar 2019-11-23 19:00:51 +00:00
commit 718849f5a5
47 changed files with 7075 additions and 1 deletions

30
WikiJam/Enemies/Dino.gd Normal file
View File

@ -0,0 +1,30 @@
extends KinematicBody
export(NodePath) var player_path
export(float) var speed
var _current_nav_path: PoolVector3Array
var _player
onready var _navigation = get_parent()
func _ready():
_player = get_node(player_path)
func _process(delta):
var to = _navigation.get_closest_point(_player.transform.origin)
_current_nav_path = _navigation.get_simple_path(transform.origin, to)
var dir: Vector3
if _current_nav_path.size() > 0:
var index = 0
if (_current_nav_path[0] - transform.origin).length() < 0.1: index = 1
dir = (_current_nav_path[index] - transform.origin).normalized()
else:
dir = (_player.transform.origin - transform.origin).normalized()
move_and_slide(dir * speed)

25
WikiJam/Enemies/Dino.tscn Normal file
View File

@ -0,0 +1,25 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Enemies/Dino.gd" type="Script" id=1]
[sub_resource type="CylinderMesh" id=1]
top_radius = 2.053
bottom_radius = 4.158
height = 13.579
[sub_resource type="CapsuleShape" id=2]
radius = 3.79447
height = 6.59163
[node name="Dino" type="KinematicBody"]
script = ExtResource( 1 )
speed = 10.0
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 7, 0 )
mesh = SubResource( 1 )
material/0 = null
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 7, 0 )
shape = SubResource( 2 )

File diff suppressed because one or more lines are too long

32
WikiJam/Level/Level.tscn Normal file
View File

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

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
extends Spatial
func _ready():
Collector.addCollectible(self)

View 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=1]
[sub_resource type="CapsuleMesh" id=2]
[node name="Crystal" type="Spatial"]
transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 2, 0 )
script = ExtResource( 1 )
[node name="CrystalBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="CrystalBody"]
shape = SubResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="CrystalBody"]
mesh = SubResource( 2 )
material/0 = null

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://Level/Objects/Wall.tscn" type="PackedScene" id=1]
[node name="LargeWall" type="Spatial"]
[node name="Wall" parent="." instance=ExtResource( 1 )]
transform = Transform( 6.70552e-08, 0, -1, 0, 1, 0, 1, 0, 6.70552e-08, -10, 0, 0 )
[node name="Wall7" parent="." instance=ExtResource( 1 )]
transform = Transform( 6.70552e-08, 0, -1, 0, 1, 0, 1, 0, 6.70552e-08, -10, 6, 0 )
[node name="Wall8" parent="." instance=ExtResource( 1 )]
transform = Transform( 6.70552e-08, 0, -1, 0, 1, 0, 1, 0, 6.70552e-08, 0, 6, 0 )
[node name="Wall9" parent="." instance=ExtResource( 1 )]
transform = Transform( 6.70552e-08, 0, -1, 0, 1, 0, 1, 0, 6.70552e-08, 10, 6, 0 )
[node name="Wall2" parent="." instance=ExtResource( 1 )]
transform = Transform( 6.70552e-08, 0, -1, 0, 1, 0, 1, 0, 6.70552e-08, 0, 0, 0 )
[node name="Wall3" parent="." instance=ExtResource( 1 )]
transform = Transform( 6.70552e-08, 0, -1, 0, 1, 0, 1, 0, 6.70552e-08, 10, 0, 0 )

View File

@ -0,0 +1,72 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Level/Objects/LargeWall.tscn" type="PackedScene" id=1]
[ext_resource path="res://Level/Objects/Wall.tscn" type="PackedScene" id=2]
[ext_resource path="res://Level/Objects/Roof.tscn" type="PackedScene" id=3]
[node name="LongBuilding" type="Spatial"]
[node name="Walls" type="Spatial" parent="."]
[node name="LargeWall" parent="Walls" instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21, 0, 49 )
[node name="LargeWall2" parent="Walls" instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -20, 0, 49 )
[node name="LargeWall7" parent="Walls" instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -34, 0, 63 )
[node name="LargeWall4" parent="Walls" instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 35, 0, 63 )
[node name="LargeWall5" parent="Walls" instance=ExtResource( 1 )]
transform = Transform( -0.8, 0, 1.50996e-07, 0, 1, 0, -1.20797e-07, 0, -1, 23.9878, 0, 77.1579 )
[node name="LargeWall6" parent="Walls" instance=ExtResource( 1 )]
transform = Transform( -1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, -3, 0, 77 )
[node name="Wall" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21, 0, 55 )
[node name="Wall10" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -14, 0, 55 )
[node name="Wall12" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -28, 0, 59.4168 )
[node name="Wall13" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -28, 6, 59.4168 )
[node name="Wall14" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -18, 6, 59.4168 )
[node name="Wall11" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -14, 6, 55 )
[node name="Wall2" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21, 6, 55 )
[node name="Wall3" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21, 6, 65 )
[node name="Wall9" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 0.7, 21, 6, 73.528 )
[node name="Wall4" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 21, 0, 65 )
[node name="Wall5" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -1.12, 0, 1, 0, 1, 0, -4.89568e-08, 0.48988, 6, 49 )
[node name="Wall6" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -23, 6, 77 )
[node name="Wall7" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -0.7, 0, 1, 0, 1, 0, -3.0598e-08, -31.5015, 6, 77.0825 )
[node name="Wall8" parent="Walls" instance=ExtResource( 2 )]
transform = Transform( -4.37114e-08, 0, -0.7, 0, 1, 0, 1, 0, -3.0598e-08, -31.5015, 0, 77.0825 )
[node name="Roof" parent="." instance=ExtResource( 3 )]
transform = Transform( 7.5, 0, 0, 0, 4, 0, 0, 0, 3.7, 0, 12, 64 )

View File

@ -0,0 +1,58 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Level/Objects/LargeWall.tscn" type="PackedScene" id=1]
[ext_resource path="res://Level/Objects/Wall.tscn" type="PackedScene" id=2]
[ext_resource path="res://Level/Objects/Roof.tscn" type="PackedScene" id=3]
[node name="RectTower" type="Spatial"]
[node name="LargeWall" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -14.1343, 0, 0 )
[node name="LargeWall7" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -14.1343, 12, 0 )
[node name="LargeWall5" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.134278, 12, 14.2772 )
[node name="LargeWall2" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 14.2347, 0, 0 )
[node name="LargeWall6" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 14.2347, 12, 0 )
[node name="LargeWall8" parent="." instance=ExtResource( 1 )]
transform = Transform( -1, 0, 8.74228e-08, 0, 1, 0, -8.74228e-08, 0, -1, 0, 12, -14.2661 )
[node name="Wall" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 10, 0, -14.1777 )
[node name="Wall10" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 10, 0, 13.8908 )
[node name="Wall2" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 10, 6, -14.1777 )
[node name="Wall9" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 10, 6, 13.8908 )
[node name="Wall3" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, -10, 6, -14.1777 )
[node name="Wall8" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, -10, 6, 13.8908 )
[node name="Wall4" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, -10, 0, -14.1777 )
[node name="Wall7" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, -10, 0, 13.8908 )
[node name="Wall5" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 6, -14.1777 )
[node name="Wall6" parent="." instance=ExtResource( 2 )]
transform = Transform( -2.98023e-08, 0, -1, 0, 1, 0, 1, 0, -2.98023e-08, 0, 6, 13.8908 )
[node name="Roof" parent="." instance=ExtResource( 3 )]
transform = Transform( 3.2, 0, 0, 0, 3.2, 0, 0, 0, 3.2, 0, 24, 0 )

View File

@ -0,0 +1,26 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Models/Material.material" type="Material" id=1]
[ext_resource path="res://Materials/Roof.tres" type="Material" id=2]
[sub_resource type="ArrayMesh" id=1]
resource_name = "Cube"
surfaces/0 = {
"aabb": AABB( -1, -1, -1, 2, 0.60001, 2 ),
"array_data": PoolByteArray( 255, 144, 230, 190, 205, 204, 204, 190, 0, 0, 0, 128, 0, 108, 65, 0, 19, 64, 149, 127, 0, 57, 0, 0, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 0, 108, 65, 0, 54, 59, 158, 127, 0, 54, 0, 0, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 0, 108, 65, 0, 11, 65, 148, 127, 0, 54, 0, 52, 255, 144, 230, 62, 205, 204, 204, 190, 0, 0, 0, 128, 0, 108, 65, 0, 202, 59, 158, 127, 0, 57, 0, 52, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 163, 85, 0, 0, 54, 59, 98, 127, 0, 54, 0, 60, 255, 144, 230, 190, 205, 204, 204, 190, 0, 0, 0, 128, 163, 85, 0, 0, 54, 59, 98, 127, 0, 57, 0, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 163, 85, 0, 0, 54, 59, 98, 127, 0, 54, 0, 58, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 48, 0, 52, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 48, 0, 56, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 0, 129, 0, 0, 127, 0, 0, 127, 0, 54, 0, 56, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 0, 129, 0, 0, 127, 0, 0, 127, 0, 54, 0, 52, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 93, 85, 0, 0, 202, 59, 158, 127, 0, 54, 0, 56, 255, 144, 230, 62, 205, 204, 204, 190, 0, 0, 0, 128, 93, 85, 0, 0, 202, 59, 158, 127, 0, 57, 0, 52, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 63, 93, 85, 0, 0, 202, 59, 158, 127, 0, 54, 0, 52, 255, 144, 230, 62, 205, 204, 204, 190, 0, 0, 0, 128, 0, 108, 191, 0, 237, 64, 107, 127, 0, 57, 0, 56, 0, 0, 128, 63, 0, 0, 128, 191, 0, 0, 128, 191, 0, 108, 191, 0, 202, 59, 98, 127, 0, 54, 0, 56, 0, 0, 128, 191, 0, 0, 128, 191, 0, 0, 128, 191, 0, 108, 191, 0, 245, 65, 108, 127, 0, 54, 0, 58, 255, 144, 230, 190, 205, 204, 204, 190, 0, 0, 0, 128, 0, 108, 191, 0, 54, 59, 98, 127, 0, 57, 0, 58 ),
"array_index_data": PoolByteArray( 0, 0, 2, 0, 1, 0, 0, 0, 3, 0, 2, 0, 4, 0, 6, 0, 5, 0, 7, 0, 9, 0, 8, 0, 7, 0, 10, 0, 9, 0, 11, 0, 13, 0, 12, 0, 14, 0, 16, 0, 15, 0, 14, 0, 17, 0, 16, 0 ),
"blend_shape_data": [ ],
"format": 97559,
"index_count": 24,
"material": ExtResource( 1 ),
"primitive": 4,
"skeleton_aabb": [ ],
"vertex_count": 18
}
[node name="Roof" type="Spatial"]
[node name="Mesh" type="MeshInstance" parent="."]
transform = Transform( 5, 0, 0, 0, 5, 0, 0, 0, 5, 0, 5, 0 )
mesh = SubResource( 1 )
material/0 = ExtResource( 2 )

View File

@ -0,0 +1,25 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Level/Objects/Wall.tscn" type="PackedScene" id=1]
[ext_resource path="res://Level/Objects/Roof.tscn" type="PackedScene" id=2]
[node name="SmallHouse" type="Spatial"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 82, 0, 0 )
[node name="Wall" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -9.33189, 0, -4.69666 )
[node name="Wall3" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -5, 0, 9 )
[node name="Wall6" parent="." instance=ExtResource( 1 )]
transform = Transform( -4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 5, 0, 9 )
[node name="Wall2" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 9.52836, 0, 4.64483 )
[node name="Wall7" parent="." instance=ExtResource( 1 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -1, 0, 4.80324 )
[node name="Roof" parent="." instance=ExtResource( 2 )]
transform = Transform( 2.2, 0, 0, 0, 2, 0, 0, 0, 2.2, 0, 6, 0 )

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=2]
[sub_resource type="PrismMesh" id=1]
[sub_resource type="MultiMesh" id=2]
instance_count = 1
mesh = SubResource( 1 )
transform_array = PoolVector3Array( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
[node name="GrassParticles" type="Spatial"]
[node name="MultiMeshInstance" type="MultiMeshInstance" parent="."]
multimesh = SubResource( 2 )

View File

@ -0,0 +1,4 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
albedo_color = Color( 0.317647, 0.2, 0.113725, 1 )

View File

@ -0,0 +1,6 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
params_cull_mode = 2
albedo_color = Color( 0.384314, 0.623529, 0.388235, 1 )
roughness = 0.9

View File

@ -0,0 +1,4 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
albedo_color = Color( 0.231373, 0.490196, 0, 1 )

View File

@ -0,0 +1,5 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
albedo_color = Color( 0.356863, 0.117647, 0.117647, 1 )
metallic = 0.1

View File

@ -0,0 +1,4 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
albedo_color = Color( 0.941176, 0.72549, 0.533333, 1 )

View File

@ -0,0 +1,6 @@
[gd_resource type="SpatialMaterial" format=2]
[resource]
albedo_color = Color( 0.501961, 0.501961, 0.501961, 1 )
metallic = 0.1
roughness = 0.9

BIN
WikiJam/Models/Grass.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
WikiJam/Models/Roof.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
WikiJam/Models/Tower.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
WikiJam/Models/Tree.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

BIN
WikiJam/Models/Wall.glb Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
extends Spatial
onready var steps = [
get_node("Footstep")
]
func play_footstep():
#Logger.trace("Footstep")
steps[0].play()

141
WikiJam/Player/Player.gd Normal file
View File

@ -0,0 +1,141 @@
extends KinematicBody
# export variables
export(NodePath) var body_nodepath
export(NodePath) var camera_nodepath
export(NodePath) var animation_nodepath
export(NodePath) var ui_nodepath
# const
const GRAVITY = -24.8
const JUMP_SPEED = 8
const MOVE_SPEED = 6
const SPRINT_SPEED = 10
const ACCEL = 15.0
const MAX_SLOPE_ANGLE = 40
const MOUSE_SENSITIVITY = 0.05
const INTERACT_DISTANCE = 4
const SPRINT_DEC = 0.015;
const SPRINT_ACC = 0.0015;
# private members
var _body: Spatial
var _camera: Camera
var _animation: AnimationPlayer
var _interface: Control
var _sprintometer: ProgressBar
var _dir = Vector3()
var _vel = Vector3()
var _is_sprinting
var _sprintVal: float = 100
func _ready():
# Assign child node variables
_body = get_node(body_nodepath) as Spatial
assert(null != _body)
_camera = get_node(camera_nodepath) as Camera
assert(null != _camera)
_animation = get_node(animation_nodepath) as AnimationPlayer
assert(null != _animation)
_interface = get_node(ui_nodepath) as Control
assert(null != _interface)
_sprintometer = _interface.get_node("ProgressBar")
assert(null != _sprintometer)
# Setup mouse look
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _physics_process(delta):
_process_input()
_process_movement(delta)
_process_collision()
#Logger.info("sprintVal: " + String(_sprintVal))
func _process(delta):
_process_animations()
if _is_sprinting and _sprintVal > 0:
_sprintVal -= SPRINT_DEC / delta
elif _sprintVal < 100:
_sprintVal += SPRINT_ACC / delta
func _process_input():
#exit
if Input.is_action_pressed("ui_cancel"):
_interface.gameOver()
# Walking
var input_movement_vector = Vector2()
if Input.is_action_pressed("move_fwrd"):
input_movement_vector.y += 1
if Input.is_action_pressed("move_back"):
input_movement_vector.y -= 1
if Input.is_action_pressed("move_left"):
input_movement_vector.x -= 1
if Input.is_action_pressed("move_right"):
input_movement_vector.x += 1
# look around with mouse
_dir = Vector3()
var camera_transform = _camera.get_global_transform()
_dir += -camera_transform.basis.z * input_movement_vector.y
_dir += camera_transform.basis.x * input_movement_vector.x
# jumping
if Input.is_action_just_pressed("move_jump") and is_on_floor():
_vel.y = JUMP_SPEED
# sprinting
_is_sprinting = Input.is_action_pressed("move_sprint") and _sprintVal > SPRINT_DEC
func _process_movement(delta):
_vel.y += delta * GRAVITY
# set movement speed
var target = _dir * (SPRINT_SPEED if _is_sprinting else MOVE_SPEED)
var hvel = _vel
hvel = hvel.linear_interpolate(target, ACCEL * delta)
_vel.x = hvel.x
_vel.z = hvel.z
_vel = move_and_slide(_vel, Vector3(0, 1, 0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
func _process_animations():
_animation.playback_speed = _vel.length() / MOVE_SPEED
_sprintometer.value = _sprintVal
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()
elif collision.collider.name == "Dino":
_interface.gameOver()
func _input(event):
# capture mouse movement
if event is InputEventMouseMotion:
_camera.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY * -1))
self.rotate_y(deg2rad(event.relative.x * MOUSE_SENSITIVITY * -1))
# Prevent player from doing a purzelbaum
_camera.rotation_degrees.x = clamp(_camera.rotation_degrees.x, -70, 70)

141
WikiJam/Player/Player.tscn Normal file
View File

@ -0,0 +1,141 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Player/Footsteps.gd" type="Script" id=2]
[ext_resource path="res://Resources/Audio/Step.wav" type="AudioStream" id=3]
[ext_resource path="res://Player/UI/HUD.tscn" type="PackedScene" id=4]
[ext_resource path="res://Player/UI/HUD.gd" type="Script" id=5]
[sub_resource type="CylinderShape" id=1]
height = 2.5
[sub_resource type="Animation" id=2]
resource_name = "Walk"
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Camera:translation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.2, 0.4, 0.6 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector3( 0, 2.8, 0 ), Vector3( -0.1, 2.9, 0 ), Vector3( 0, 2.8, 0 ), Vector3( 0.1, 2.9, 0 ) ]
}
tracks/1/type = "method"
tracks/1/path = NodePath("Footsteps")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.5 ),
"transitions": PoolRealArray( 1, 1 ),
"values": [ {
"args": [ ],
"method": "play_footstep"
}, {
"args": [ ],
"method": "play_footstep"
} ]
}
[node name="Player" type="KinematicBody"]
script = ExtResource( 1 )
body_nodepath = NodePath("Body")
camera_nodepath = NodePath("Camera")
animation_nodepath = NodePath("WalkAnimationPlayer")
ui_nodepath = NodePath("HUD")
[node name="Body" type="Spatial" parent="."]
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 0 )
far = 500.0
[node name="Listener" type="Listener" parent="Camera"]
[node name="Collider" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 0 )
shape = SubResource( 1 )
[node name="WalkAnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Walk"
anims/Walk = SubResource( 2 )
[node name="Footsteps" type="Spatial" parent="."]
script = ExtResource( 2 )
[node name="Footstep" type="AudioStreamPlayer3D" parent="Footsteps"]
stream = ExtResource( 3 )
unit_db = -10.0
pitch_scale = 1.5
[node name="HUD" parent="." instance=ExtResource( 4 )]
script = ExtResource( 5 )
label_nodepath = NodePath("LabelScore")
popup_nodepath = NodePath("PopupWon")
[node name="LabelScore" type="Label" parent="HUD"]
margin_left = 15.0
margin_top = 15.0
margin_right = 115.0
margin_bottom = 30.0
text = "Score: 0"
[node name="PopupWon" type="Popup" parent="HUD"]
visible = true
margin_left = 383.0
margin_top = 187.0
margin_right = 530.0
margin_bottom = 289.0
[node name="PanelFail" type="Panel" parent="HUD/PopupWon"]
modulate = Color( 0.996078, 0, 0, 1 )
margin_left = -383.0
margin_top = -187.36
margin_right = 641.0
margin_bottom = 412.64
[node name="PanelWon" type="Panel" parent="HUD/PopupWon"]
modulate = Color( 0.0313726, 0, 0.996078, 1 )
margin_left = -383.0
margin_top = -187.36
margin_right = 641.0
margin_bottom = 412.64
[node name="LabelWon" type="Label" parent="HUD/PopupWon"]
margin_left = 87.064
margin_top = 24.4867
margin_right = 169.064
margin_bottom = 72.4867
text = "Gratulations!
You Won!"
[node name="LabelFail" type="Label" parent="HUD/PopupWon"]
margin_left = 88.9828
margin_top = 28.0094
margin_right = 168.983
margin_bottom = 76.0094
text = " You died!
Game over"
[node name="Button" type="Button" parent="HUD/PopupWon"]
margin_left = 86.5054
margin_top = 144.902
margin_right = 179.505
margin_bottom = 181.902
text = "play again"
[node name="ProgressBar" type="ProgressBar" parent="HUD"]
margin_left = 410.651
margin_top = 560.551
margin_right = 614.651
margin_bottom = 582.551
step = 1.0
value = 100.0
[connection signal="pressed" from="HUD/PopupWon/Button" to="HUD" method="_on_Button_pressed"]

52
WikiJam/Player/UI/HUD.gd Normal file
View File

@ -0,0 +1,52 @@
extends Control
export(NodePath) var label_nodepath
export(NodePath) var popup_nodepath
const SCORE = 100
var _labelScore: Label
var _popup: Popup
var _score: int = 0
func _ready():
_labelScore = get_node(label_nodepath) as Label
assert(null != _labelScore)
_popup = get_node(popup_nodepath) as Popup
assert(null != _popup)
func increaseScore():
_score += SCORE
_labelScore.text = "Score: " + String(_score)
Logger.info(String(_score) + " of " + String(Collector.getCount() * SCORE) + " possible points")
if (_score >= (Collector.getCount() * SCORE)):
Logger.info("YOU WON!")
success()
func gameOver():
_endGame(false)
func success():
_endGame(true)
func _endGame (value):
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
Collector.Clear()
_popup.get_node("LabelWon").visible = value
_popup.get_node("LabelFail").visible = !value
_popup.get_node("PanelWon").visible = value
_popup.get_node("PanelFail").visible = !value
_popup.show()
func _on_Button_pressed():
get_tree().reload_current_scene()

View File

@ -0,0 +1,5 @@
[gd_scene format=2]
[node name="HUD" type="Control"]
margin_right = 40.0
margin_bottom = 40.0

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Step.wav-7d0ddf0513d871cbc1043ef07a7bc4cb.sample"
[deps]
source_file="res://Resources/Audio/Step.wav"
dest_files=[ "res://.import/Step.wav-7d0ddf0513d871cbc1043ef07a7bc4cb.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

BIN
WikiJam/Sounds/dino-eat.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/dino-eat.wav-0bc7be11b37e5673862d9b344ce11abc.sample"
[deps]
source_file="res://Sounds/dino-eat.wav"
dest_files=[ "res://.import/dino-eat.wav-0bc7be11b37e5673862d9b344ce11abc.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

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

@ -0,0 +1,17 @@
extends Node
var _collectibles: Array
func addCollectible (coll):
Logger.info("appending new collectible: " + String(coll.get_instance_id()))
_collectibles.append(coll)
Logger.info("current collection count: " + String(Collector.getCount()))
func getCount ():
return _collectibles.size()
func Clear ():
return _collectibles.clear()

View File

@ -57,11 +57,46 @@ _global_script_class_icons={
[application] [application]
config/name="WikiJam" config/name="WikiJam"
run/main_scene="res://Level/Fortaleza.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]
move_fwrd={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":87,"unicode":0,"echo":false,"script":null)
]
}
move_back={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":83,"unicode":0,"echo":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}
move_jump={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"unicode":0,"echo":false,"script":null)
]
}
move_sprint={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null)
]
}
[rendering] [rendering]