Initial commit

main
Martin Felis 2024-01-26 21:07:19 +01:00
commit 00d3088e21
10 changed files with 316 additions and 0 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

11
Game.gd Normal file
View File

@ -0,0 +1,11 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

59
entities/Player.gd Normal file
View File

@ -0,0 +1,59 @@
extends CharacterBody3D
@export var move_right_action := "move_right"
@export var move_left_action := "move_left"
@export var move_down_action := "move_down"
@export var move_up_action := "move_up"
@export var dash_action := "dash"
@onready var geometry = $Geometry
var angle = 0
var is_dashing = false
var dash_time = 0
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
const DASH_SPEED: float = 20
const DASH_DURATION: float = 0.2
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector(move_left_action, move_right_action, move_up_action, move_down_action)
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * SPEED
velocity.z = direction.z * SPEED
angle = direction.signed_angle_to(Vector3.FORWARD, Vector3.UP)
geometry.global_basis = Basis.from_euler(Vector3(0, -angle, 0))
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
velocity.z = move_toward(velocity.z, 0, SPEED)
if Input.is_action_just_pressed("dash_p1"):
is_dashing = true;
dash_time = DASH_DURATION
if is_dashing:
velocity.x = sin(angle) * DASH_SPEED
velocity.z = -cos(angle) * DASH_SPEED
geometry.global_basis = Basis.from_euler(Vector3(-0.3, -angle, 0))
dash_time -= delta
if dash_time <= 0:
is_dashing = false
move_and_slide()

1
icon.svg Normal file
View File

@ -0,0 +1 @@
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>

After

Width:  |  Height:  |  Size: 950 B

37
icon.svg.import Normal file
View File

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5xyjcnjoqxjm"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

64
project.godot Normal file
View File

@ -0,0 +1,64 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="DashBoomColorClash"
run/main_scene="res://scenes/Game.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"
[dotnet]
project/assembly_name="DashBoomColorClash"
[input]
move_up_p1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":-1.0,"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":118,"echo":false,"script":null)
]
}
move_down_p1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":1,"axis_value":1.0,"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":105,"echo":false,"script":null)
]
}
move_left_p1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":-1.0,"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":117,"echo":false,"script":null)
]
}
move_right_p1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":0,"axis_value":1.0,"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":97,"echo":false,"script":null)
]
}
dash_p1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":true,"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":79,"key_label":0,"unicode":102,"echo":false,"script":null)
]
}
bomp_p1={
"deadzone": 0.5,
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":1,"pressure":0.0,"pressed":true,"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":80,"key_label":0,"unicode":113,"echo":false,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"

41
scenes/Game.tscn Normal file
View File

@ -0,0 +1,41 @@
[gd_scene load_steps=5 format=3 uid="uid://rd48gl8k5x34"]
[ext_resource type="Script" path="res://Game.gd" id="1_7jqda"]
[ext_resource type="PackedScene" uid="uid://b1nm5h3yccr16" path="res://scenes/World.tscn" id="2_voimb"]
[sub_resource type="World3D" id="World3D_5g233"]
[sub_resource type="ViewportTexture" id="ViewportTexture_2lmj8"]
viewport_path = NodePath("Viewport")
[node name="Game" type="Node"]
script = ExtResource("1_7jqda")
[node name="Viewport" type="SubViewport" parent="."]
own_world_3d = true
world_3d = SubResource("World3D_5g233")
size = Vector2i(256, 256)
[node name="World" parent="Viewport" instance=ExtResource("2_voimb")]
[node name="Panel" type="Panel" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 6
size_flags_vertical = 6
[node name="WorldView" type="TextureRect" parent="Panel"]
texture_filter = 1
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = SubResource("ViewportTexture_2lmj8")
stretch_mode = 6

17
scenes/World.gd Normal file
View File

@ -0,0 +1,17 @@
extends Node3D
@onready var player1: CharacterBody3D = $Player1
@onready var camera: Camera3D = $Camera3D
var camera_offset: Vector3;
# Called when the node enters the scene tree for the first time.
func _ready():
camera_offset = camera.global_position - player1.global_position
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
camera.global_position = player1.global_position + camera_offset
pass

82
scenes/World.tscn Normal file
View File

@ -0,0 +1,82 @@
[gd_scene load_steps=11 format=3 uid="uid://b1nm5h3yccr16"]
[ext_resource type="Script" path="res://entities/Player.gd" id="1_ca7jo"]
[ext_resource type="Script" path="res://scenes/World.gd" id="1_gtcjp"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_wonuc"]
noise_type = 0
frequency = 0.014
fractal_lacunarity = 3.0
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_iklfu"]
width = 32
height = 32
seamless = true
seamless_blend_skirt = 0.857
normalize = false
noise = SubResource("FastNoiseLite_wonuc")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_b5tqf"]
albedo_color = Color(0.113725, 0.431373, 0.266667, 0.933333)
albedo_texture = SubResource("NoiseTexture2D_iklfu")
uv1_triplanar = true
texture_filter = 0
[sub_resource type="CylinderMesh" id="CylinderMesh_a3rev"]
material = SubResource("StandardMaterial3D_b5tqf")
top_radius = 20.0
bottom_radius = 20.0
height = 0.2
radial_segments = 8
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ar5d4"]
height = 0.2
radius = 20.0
[sub_resource type="BoxMesh" id="BoxMesh_yle83"]
size = Vector3(0.24, 0.75, 0.24)
[sub_resource type="CylinderShape3D" id="CylinderShape3D_rwgp3"]
height = 0.75
radius = 0.15
[sub_resource type="Environment" id="Environment_f3jci"]
ambient_light_source = 3
ambient_light_color = Color(0.521569, 0.521569, 0.521569, 1)
ambient_light_energy = 2.64
[node name="World" type="Node3D"]
script = ExtResource("1_gtcjp")
[node name="Platform" type="StaticBody3D" parent="."]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Platform"]
mesh = SubResource("CylinderMesh_a3rev")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Platform"]
shape = SubResource("CylinderShape3D_ar5d4")
[node name="Player1" type="CharacterBody3D" parent="."]
script = ExtResource("1_ca7jo")
move_right_action = "move_right_p1"
move_left_action = "move_left_p1"
move_down_action = "move_down_p1"
move_up_action = "move_up_p1"
[node name="Geometry" type="MeshInstance3D" parent="Player1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.472544, 0)
mesh = SubResource("BoxMesh_yle83")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Player1"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.496337, 0)
shape = SubResource("CylinderShape3D_rwgp3")
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_f3jci")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(-4.37114e-08, -0.528438, 0.848972, 0, 0.848972, 0.528438, -1, 2.30988e-08, -3.71097e-08, 0.936448, 2.01321, 1.19116)
shadow_enabled = true
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.305147, 0.952305, 0, -0.952305, 0.305147, -4.26326e-13, 4.70264, 1.09419)