2024-06-11 19:49:35 +02:00
parent 845d04e3bb
commit eeaec4b538
21 changed files with 452 additions and 0 deletions

27
Mob.gd Normal file
View File

@@ -0,0 +1,27 @@
extends CharacterBody3D
@export var min_speed = 10
@export var max_speed = 18
signal squashed
func _physics_process(delta):
move_and_slide()
func initialize(start_position, player_position):
# Look to the player
look_at_from_position(start_position, player_position, Vector3.UP)
# But rotate a little bit
rotate_y(randf_range(-PI / 4, PI / 4))
# Set random speed
var random_speed = randi_range(min_speed, max_speed)
# Apply the velocity
velocity = Vector3.FORWARD * random_speed
velocity = velocity.rotated(Vector3.UP, rotation.y)
func squash():
squashed.emit()
queue_free()
func _on_visibility_notifier_screen_exited():
queue_free()

56
Player.gd Normal file
View File

@@ -0,0 +1,56 @@
extends CharacterBody3D
@export var speed = 14 # m/s
@export var fall_acceleration = 75 # m/s^2
@export var jump_impulse = 20 # m/s
@export var bounce_impulse = 16 # m/s
var target_velocity = Vector3.ZERO
func _physics_process(delta):
# By default, we are not moving
var direction = Vector3.ZERO
# Check inputs
if Input.is_action_pressed("move_right"):
direction.x += 1
if Input.is_action_pressed("move_left"):
direction.x -= 1
if Input.is_action_pressed("move_back"):
direction.z += 1
if Input.is_action_pressed("move_forward"):
direction.z -= 1
# If in movement, normalize direction and change looking_at
if direction != Vector3.ZERO:
direction = direction.normalized()
$Pivot.basis = Basis.looking_at(direction)
# Ground velocity
target_velocity.x = direction.x * speed
target_velocity.z = direction.z * speed
# Vertical velocity
if not is_on_floor():
target_velocity.y = target_velocity.y - (fall_acceleration * delta)
# Jumping
if is_on_floor() and Input.is_action_just_pressed("jump"):
target_velocity.y = jump_impulse
for index in range(get_slide_collision_count()):
var collision = get_slide_collision(index)
if collision.get_collider() == null:
continue
if collision.get_collider().is_in_group("mob"):
var mob = collision.get_collider()
if Vector3.UP.dot(collision.get_normal()) > 0.1:
mob.squash()
target_velocity.y = bounce_impulse
break
# Move the character
velocity = target_velocity
move_and_slide()

Binary file not shown.

View File

@@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://cx00shxtb3wu3"
path="res://.godot/imported/House In a Forest Loop.ogg-1a6a72ae843ad792b7039931227e8d50.oggvorbisstr"
[deps]
source_file="res://art/House In a Forest Loop.ogg"
dest_files=["res://.godot/imported/House In a Forest Loop.ogg-1a6a72ae843ad792b7039931227e8d50.oggvorbisstr"]
[params]
loop=true
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

BIN
art/body.material Normal file

Binary file not shown.

BIN
art/eye.material Normal file

Binary file not shown.

BIN
art/mob.glb Normal file

Binary file not shown.

34
art/mob.glb.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://gqs4tdvjq5vi"
path="res://.godot/imported/mob.glb-3afb43c03b9d1598b6af5154e2543eac.scn"
[deps]
source_file="res://art/mob.glb"
dest_files=["res://.godot/imported/mob.glb-3afb43c03b9d1598b6af5154e2543eac.scn"]
[params]
nodes/root_type="Spatial"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=0
meshes/lightmap_texel_size=0.1
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=0
gltf/embedded_image_handling=1

BIN
art/mob_body.material Normal file

Binary file not shown.

BIN
art/mob_eye.material Normal file

Binary file not shown.

BIN
art/player.glb Normal file

Binary file not shown.

34
art/player.glb.import Normal file
View File

@@ -0,0 +1,34 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cpgf40og1627r"
path="res://.godot/imported/player.glb-08dcfb373480a049995065542e37637b.scn"
[deps]
source_file="res://art/player.glb"
dest_files=["res://.godot/imported/player.glb-08dcfb373480a049995065542e37637b.scn"]
[params]
nodes/root_type="Spatial"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=0
meshes/lightmap_texel_size=0.1
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=15
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
gltf/naming_version=0
gltf/embedded_image_handling=1

BIN
art/pupil.material Normal file

Binary file not shown.

43
fonts/LICENSE.txt Normal file
View File

@@ -0,0 +1,43 @@
Copyright 2011 The Montserrat Project Authors (https://github.com/JulietaUla/Montserrat)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
—————————————————————————————-
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
—————————————————————————————-
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
“Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
“Reserved Font Name” refers to any names specified as such after the copyright statement(s).
“Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s).
“Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
“Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

BIN
fonts/Montserrat-Medium.ttf Normal file

Binary file not shown.

View File

@@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://d1r2cqlplg2wb"
path="res://.godot/imported/Montserrat-Medium.ttf-e832861e4ad4110e172112dc430c04b0.fontdata"
[deps]
source_file="res://fonts/Montserrat-Medium.ttf"
dest_files=["res://.godot/imported/Montserrat-Medium.ttf-e832861e4ad4110e172112dc430c04b0.fontdata"]
[params]
Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}

14
main.gd Normal file
View File

@@ -0,0 +1,14 @@
extends Node
@export var mob_scene: PackedScene
func _on_mob_timer_timeout():
var mob = mob_scene.instantiate()
var mob_spawn_location = get_node("SpawnPath/SpawnLocation")
mob_spawn_location.progress_ratio = randf()
var player_position = $Player.position
mob.initialize(mob_spawn_location.position, player_position)
add_child(mob)

82
main.tscn Normal file
View File

@@ -0,0 +1,82 @@
[gd_scene load_steps=9 format=3 uid="uid://6o4jfv4sjc42"]
[ext_resource type="Script" path="res://main.gd" id="1_git68"]
[ext_resource type="PackedScene" uid="uid://bl4b5g1o8ud5y" path="res://player.tscn" id="1_qvjem"]
[ext_resource type="PackedScene" uid="uid://h2hapmuai55b" path="res://mob.tscn" id="2_oiwul"]
[sub_resource type="BoxShape3D" id="BoxShape3D_jiv4h"]
size = Vector3(60, 2, 60)
[sub_resource type="BoxMesh" id="BoxMesh_vamix"]
size = Vector3(60, 2, 60)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1f85g"]
albedo_color = Color(0.968627, 0.545098, 0, 1)
[sub_resource type="CylinderMesh" id="CylinderMesh_1gwnh"]
material = SubResource("StandardMaterial3D_1f85g")
[sub_resource type="Curve3D" id="Curve3D_476rq"]
_data = {
"points": PackedVector3Array(0, 0, 0, 0, 0, 0, -13.6297, 0, -15.0268, 0, 0, 0, 0, 0, 0, 13.2382, 0, -15.2266, 0, 0, 0, 0, 0, 0, 13.2382, 0, 15.3369, 0, 0, 0, 0, 0, 0, -13.6297, 0, 14.9374, 0, 0, 0, 0, 0, 0, -13.6297, 0, -15.0268),
"tilts": PackedFloat32Array(0, 0, 0, 0, 0)
}
point_count = 5
[node name="Main" type="Node"]
script = ExtResource("1_git68")
mob_scene = ExtResource("2_oiwul")
[node name="Ground" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
collision_layer = 4
collision_mask = 0
[node name="CollisionShape3D" type="CollisionShape3D" parent="Ground"]
shape = SubResource("BoxShape3D_jiv4h")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Ground"]
mesh = SubResource("BoxMesh_vamix")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 26.3214, 0)
shadow_enabled = true
[node name="Player" parent="." instance=ExtResource("1_qvjem")]
[node name="CameraPivot" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0, 19, 19)
[node name="Camera3D" type="Camera3D" parent="CameraPivot"]
projection = 1
size = 19.0
[node name="Cylinders" type="Node3D" parent="."]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Cylinders"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13.358, 0, -14.8422)
mesh = SubResource("CylinderMesh_1gwnh")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Cylinders"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13.3652, 0, 15.5517)
mesh = SubResource("CylinderMesh_1gwnh")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="Cylinders"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 13.4386, 0, -14.9891)
mesh = SubResource("CylinderMesh_1gwnh")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="Cylinders"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -13.358, 0, 15.1847)
mesh = SubResource("CylinderMesh_1gwnh")
[node name="SpawnPath" type="Path3D" parent="."]
curve = SubResource("Curve3D_476rq")
[node name="SpawnLocation" type="PathFollow3D" parent="SpawnPath"]
transform = Transform3D(0.00743461, 0, -0.999972, 0, 1, 0, 0.999972, 0, 0.00743461, -13.6297, 0, -15.0268)
[node name="MobTimer" type="Timer" parent="."]
wait_time = 0.5
autostart = true
[connection signal="timeout" from="MobTimer" to="." method="_on_mob_timer_timeout"]

24
mob.tscn Normal file
View File

@@ -0,0 +1,24 @@
[gd_scene load_steps=4 format=3 uid="uid://h2hapmuai55b"]
[ext_resource type="Script" path="res://Mob.gd" id="1_fih7b"]
[ext_resource type="PackedScene" uid="uid://gqs4tdvjq5vi" path="res://art/mob.glb" id="2_0f7cl"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vwmkp"]
size = Vector3(2, 1, 2.5)
[node name="Mob" type="CharacterBody3D" groups=["mob"]]
collision_layer = 2
collision_mask = 0
script = ExtResource("1_fih7b")
[node name="Pivot" type="Node3D" parent="."]
[node name="Character" parent="Pivot" instance=ExtResource("2_0f7cl")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("BoxShape3D_vwmkp")
[node name="VisibilityNotifier" type="VisibleOnScreenNotifier3D" parent="."]
aabb = AABB(-1.5, -1, -2, 3, 2, 4)
[connection signal="screen_exited" from="VisibilityNotifier" to="." method="_on_visibility_notifier_screen_exited"]

18
player.tscn Normal file
View File

@@ -0,0 +1,18 @@
[gd_scene load_steps=4 format=3 uid="uid://bl4b5g1o8ud5y"]
[ext_resource type="Script" path="res://Player.gd" id="1_hmkw8"]
[ext_resource type="PackedScene" uid="uid://cpgf40og1627r" path="res://art/player.glb" id="1_s5jny"]
[sub_resource type="SphereShape3D" id="SphereShape3D_afne8"]
radius = 1.1
[node name="Player" type="CharacterBody3D"]
collision_mask = 6
script = ExtResource("1_hmkw8")
[node name="Pivot" type="Node3D" parent="."]
[node name="Character" parent="Pivot" instance=ExtResource("1_s5jny")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_afne8")

View File

@@ -14,7 +14,75 @@ config/name="Godot"
config/features=PackedStringArray("4.2", "Forward Plus") config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[display]
window/size/viewport_width=720
window/size/viewport_height=540
[editor] [editor]
version_control/plugin_name="GitPlugin" version_control/plugin_name="GitPlugin"
version_control/autoload_on_startup=true version_control/autoload_on_startup=true
[input]
ui_accept={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194309,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194310,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_select={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":32,"physical_keycode":0,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":3,"pressure":0.0,"pressed":false,"script":null)
]
}
ui_cancel={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194305,"physical_keycode":0,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
]
}
move_left={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"script":null)
]
}
move_right={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"script":null)
]
}
move_forward={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"script":null)
]
}
move_back={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"script":null)
]
}
jump={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
[layer_names]
3d_physics/layer_1="player"
3d_physics/layer_2="enemies"
3d_physics/layer_3="world"