small improvements, prepare for menu

This commit is contained in:
Daniel Bulant 2024-05-19 23:24:40 +02:00
parent 0ce5a5cda7
commit be2d497c34
25 changed files with 437 additions and 34 deletions

BIN
FOT-Yuruka Std.ttf Normal file

Binary file not shown.

33
FOT-Yuruka Std.ttf.import Normal file
View file

@ -0,0 +1,33 @@
[remap]
importer="font_data_dynamic"
type="FontFile"
uid="uid://b7ivghntajsa4"
path="res://.godot/imported/FOT-Yuruka Std.ttf-8fd35eb67f6abdea4a2d71b93ad4bb40.fontdata"
[deps]
source_file="res://FOT-Yuruka Std.ttf"
dest_files=["res://.godot/imported/FOT-Yuruka Std.ttf-8fd35eb67f6abdea4a2d71b93ad4bb40.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={}

BIN
dice.res

Binary file not shown.

View file

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View file

@ -3,7 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://w1rxbv37o62n"
path.s3tc="res://.godot/imported/de.jpg-375fb5e746ebc72c2f7e234647368e57.s3tc.ctex"
path.s3tc="res://.godot/imported/de.jpg-bd75cd3a0d0393be5e9af74d7151c02c.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
@ -11,8 +11,8 @@ metadata={
[deps]
source_file="res://de.jpg"
dest_files=["res://.godot/imported/de.jpg-375fb5e746ebc72c2f7e234647368e57.s3tc.ctex"]
source_file="res://game/de.jpg"
dest_files=["res://.godot/imported/de.jpg-bd75cd3a0d0393be5e9af74d7151c02c.s3tc.ctex"]
[params]

67
game/dice-ui.gd Normal file
View file

@ -0,0 +1,67 @@
extends Control
@export var value := 1 :
set(_value):
value = _value
queue_redraw()
@export var color := Color(1, 1, 1) :
set(_color):
color = _color
queue_redraw()
@export var bg_color := Color(0, 0, 0) :
set(_bg_color):
bg_color = _bg_color
stylebox.bg_color = bg_color
queue_redraw()
func _get_minimum_size() -> Vector2:
return Vector2(30, 30)
var stylebox = StyleBoxFlat.new()
func _ready() -> void:
stylebox.bg_color = bg_color
var radius := 5
stylebox.corner_radius_bottom_left = radius
stylebox.corner_radius_bottom_right = radius
stylebox.corner_radius_top_left = radius
stylebox.corner_radius_top_right = radius
func _draw() -> void:
var dim = min(size.x, size.y)
draw_style_box(stylebox, Rect2(Vector2(), size))
var point_size = dim / 10
var center = Vector2(dim / 2, dim / 2)
var topleft = Vector2(dim / 4, dim / 4)
var topright = topleft + Vector2(dim / 2, 0)
var bottomleft = topleft + Vector2(0, dim / 2)
var bottomright = topleft + Vector2(dim / 2, dim / 2)
var centerleft = topleft + Vector2(0, dim / 4)
var centerright = topleft + Vector2(dim / 2, dim / 4)
var centertop = topleft + Vector2(dim / 4, 0)
var centerbottom = topleft + Vector2(dim / 4, dim / 2)
if value % 2 == 1:
draw_circle(center, point_size, color)
if value >= 2:
draw_circle(topleft, point_size, color)
draw_circle(bottomright, point_size, color)
if value >= 4:
draw_circle(topright, point_size, color)
draw_circle(bottomleft, point_size, color)
if value >= 6:
draw_circle(centerleft, point_size, color)
draw_circle(centerright, point_size, color)
if value >= 8:
draw_circle(centertop, point_size, color)
draw_circle(centerbottom, point_size, color)
pass

View file

@ -4,12 +4,12 @@ importer="scene"
importer_version=1
type="PackedScene"
uid="uid://d3mvfdbhh2a0r"
path="res://.godot/imported/dice.blend-8f74aeec4cc72ad8192a100c1f57a211.scn"
path="res://.godot/imported/dice.blend-a3577ff412d0dda056ae5bf1e3d92bc1.scn"
[deps]
source_file="res://dice.blend"
dest_files=["res://.godot/imported/dice.blend-8f74aeec4cc72ad8192a100c1f57a211.scn"]
source_file="res://game/dice.blend"
dest_files=["res://.godot/imported/dice.blend-a3577ff412d0dda056ae5bf1e3d92bc1.scn"]
[params]

BIN
game/dice.res Normal file

Binary file not shown.

BIN
game/dice.res.depren Normal file

Binary file not shown.

View file

Before

Width:  |  Height:  |  Size: 949 B

After

Width:  |  Height:  |  Size: 949 B

View file

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b5b4omm3i2vxh"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
path="res://.godot/imported/icon.svg-8a42633fca07710a1390ed2552c66ce6.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
source_file="res://game/icon.svg"
dest_files=["res://.godot/imported/icon.svg-8a42633fca07710a1390ed2552c66ce6.ctex"]
[params]

View file

@ -1,9 +1,9 @@
[gd_scene load_steps=14 format=3 uid="uid://bxphc5t7er28i"]
[ext_resource type="Script" path="res://main.gd" id="1_h1pkq"]
[ext_resource type="ArrayMesh" uid="uid://6ygsl6phockr" path="res://dice.res" id="1_qesf4"]
[ext_resource type="Script" path="res://dice.gd" id="2_jh75e"]
[ext_resource type="PackedScene" uid="uid://c8jkqtbqtg7ub" path="res://ui.tscn" id="4_80via"]
[ext_resource type="Script" path="res://game/main.gd" id="1_h1pkq"]
[ext_resource type="ArrayMesh" uid="uid://6ygsl6phockr" path="res://game/dice.res" id="1_qesf4"]
[ext_resource type="Script" path="res://game/dice.gd" id="2_jh75e"]
[ext_resource type="PackedScene" uid="uid://c8jkqtbqtg7ub" path="res://game/ui.tscn" id="4_80via"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_kmncl"]
bounce = 0.06
@ -20,14 +20,15 @@ plane = Plane(0, 0.5, 0.005, 0)
[sub_resource type="BoxShape3D" id="BoxShape3D_i1dy0"]
size = Vector3(1, 0.499512, 0.0229492)
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_55efa"]
ground_bottom_color = Color(0.158328, 0.184483, 0.141961, 1)
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_nxrab"]
ground_bottom_color = Color(0.610915, 0.695046, 0.774521, 1)
[sub_resource type="Sky" id="Sky_q42e0"]
sky_material = SubResource("ProceduralSkyMaterial_55efa")
sky_material = SubResource("ProceduralSkyMaterial_nxrab")
[sub_resource type="Environment" id="Environment_rm3d5"]
[sub_resource type="Environment" id="Environment_64y34"]
background_mode = 2
background_color = Color(1, 1, 1, 1)
sky = SubResource("Sky_q42e0")
ambient_light_source = 3
reflected_light_source = 2
@ -37,7 +38,7 @@ ssil_enabled = true
sdfgi_enabled = true
glow_enabled = true
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_i6kyw"]
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_k5qa7"]
[node name="Node3D" type="Node3D"]
script = ExtResource("1_h1pkq")
@ -124,16 +125,17 @@ transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 1,
[node name="CameraPositionTarget" type="Marker3D" parent="."]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_rm3d5")
camera_attributes = SubResource("CameraAttributesPractical_i6kyw")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.751874, 0.659306, 0, -0.659306, 0.751874, 0, 1.52296, 0)
shadow_enabled = true
shadow_bias = 0.01
directional_shadow_max_distance = 10.0
[node name="DiceThrowStart" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.408271, 0.326392, 0)
[node name="Ui" parent="." instance=ExtResource("4_80via")]
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_64y34")
camera_attributes = SubResource("CameraAttributesPractical_k5qa7")

View file

@ -5,8 +5,9 @@ signal roll_pressed
func _on_roll_button_pressed() -> void:
roll_pressed.emit()
@onready var current_throw_value = $current_throw_value
@onready var dice1 = $dice1
@onready var dice2 = $dice2
func set_current_throw_value(value: Array[int]) -> void:
current_throw_value.set_text(str(value))
pass
dice1.value = value[0]
dice2.value = value[1]

View file

@ -1,6 +1,7 @@
[gd_scene load_steps=4 format=3 uid="uid://c8jkqtbqtg7ub"]
[gd_scene load_steps=5 format=3 uid="uid://c8jkqtbqtg7ub"]
[ext_resource type="Script" path="res://ui.gd" id="1_qipxr"]
[ext_resource type="Script" path="res://game/ui.gd" id="1_qipxr"]
[ext_resource type="Script" path="res://game/dice-ui.gd" id="2_g0ok8"]
[sub_resource type="InputEventKey" id="InputEventKey_6n7ot"]
device = -1
@ -36,15 +37,28 @@ tooltip_text = "Click or press space to roll dice"
shortcut = SubResource("Shortcut_0osx3")
text = "Roll"
[node name="current_throw_value" type="RichTextLabel" parent="."]
[node name="dice1" type="Control" parent="."]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 10.0
offset_top = -29.0
offset_right = 51.0
offset_left = 7.0
offset_top = -48.0
offset_right = 47.0
offset_bottom = -8.0
grow_vertical = 0
text = "0, 0"
script = ExtResource("2_g0ok8")
[node name="dice2" type="Control" parent="."]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 55.0
offset_top = -48.0
offset_right = 95.0
offset_bottom = -8.0
grow_vertical = 0
script = ExtResource("2_g0ok8")
[connection signal="pressed" from="roll button" to="." method="_on_roll_button_pressed"]

93
main.tres Normal file
View file

@ -0,0 +1,93 @@
[gd_resource type="Theme" load_steps=8 format=3 uid="uid://c3k6p6wm7hgd6"]
[ext_resource type="FontFile" uid="uid://b7ivghntajsa4" path="res://FOT-Yuruka Std.ttf" id="1_p6lue"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_0bv53"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(0, 0.654902, 0.870588, 1)
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color(1, 1, 1, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
shadow_color = Color(1, 1, 1, 0.6)
shadow_size = 4
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_aw3w3"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(0.412188, 0.812156, 1, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
shadow_size = 4
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_du6qe"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(1.15514e-06, 0.654919, 0.870125, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
shadow_color = Color(0, 0, 0, 0.494118)
shadow_size = 4
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cad51"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(3.27289e-06, 0.505601, 0.675926, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
shadow_size = 4
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ak7dy"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(0.105882, 0.105882, 0.105882, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cb60y"]
content_margin_left = 8.0
content_margin_top = 8.0
content_margin_right = 8.0
content_margin_bottom = 8.0
bg_color = Color(0.10748, 0.10748, 0.10748, 1)
corner_radius_top_left = 8
corner_radius_top_right = 8
corner_radius_bottom_right = 8
corner_radius_bottom_left = 8
shadow_size = 1
[resource]
default_font = ExtResource("1_p6lue")
Button/colors/font_color = Color(1, 1, 1, 1)
Button/constants/h_separation = 4
Button/font_sizes/font_size = 28
Button/styles/focus = SubResource("StyleBoxFlat_0bv53")
Button/styles/hover = SubResource("StyleBoxFlat_aw3w3")
Button/styles/normal = SubResource("StyleBoxFlat_du6qe")
Button/styles/pressed = SubResource("StyleBoxFlat_cad51")
LineEdit/styles/focus = SubResource("StyleBoxFlat_ak7dy")
LineEdit/styles/normal = SubResource("StyleBoxFlat_cb60y")

BIN
menu/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

35
menu/logo.png.import Normal file
View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cxbx2nxeemwdu"
path.s3tc="res://.godot/imported/logo.png-27fb6b5bbe263423da3f70ed315b172f.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://menu/logo.png"
dest_files=["res://.godot/imported/logo.png-27fb6b5bbe263423da3f70ed315b172f.s3tc.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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=0

6
menu/menu_bg.gd Normal file
View file

@ -0,0 +1,6 @@
extends Node3D
var main_scene = preload("res://game/main.tscn")
func _on_menu_ui_start_pressed() -> void:
get_tree().change_scene_to_packed(main_scene)

86
menu/menu_bg.tscn Normal file
View file

@ -0,0 +1,86 @@
[gd_scene load_steps=10 format=3 uid="uid://cmt0o37jd1gt6"]
[ext_resource type="ArrayMesh" uid="uid://6ygsl6phockr" path="res://game/dice.res" id="1_8u4bs"]
[ext_resource type="Script" path="res://menu/menu_bg.gd" id="1_mvbgk"]
[ext_resource type="PackedScene" uid="uid://dfarwiq8kvcxa" path="res://menu/menu_ui.tscn" id="2_5dpja"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_os646"]
ground_bottom_color = Color(0.610915, 0.695046, 0.774521, 1)
[sub_resource type="Sky" id="Sky_cj84e"]
sky_material = SubResource("ProceduralSkyMaterial_os646")
[sub_resource type="Environment" id="Environment_hqpr0"]
background_mode = 2
background_color = Color(1, 1, 1, 1)
sky = SubResource("Sky_cj84e")
ambient_light_source = 3
reflected_light_source = 2
tonemap_mode = 3
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
glow_enabled = true
[sub_resource type="CameraAttributesPractical" id="CameraAttributesPractical_cvruf"]
[sub_resource type="Animation" id="Animation_fnyq0"]
resource_name = "float"
length = 4.0
loop_mode = 1
tracks/0/type = "position_3d"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("MeshInstance3D")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = PackedFloat32Array(0, 1, 0.152777, 0.229333, 0.63782, 1.5, 1, 0.153, 0.2, 0.638, 3, 1, 0.153, 0.24, 0.638, 4, 1, 0.152777, 0.229333, 0.63782)
tracks/1/type = "position_3d"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("MeshInstance3D2")
tracks/1/interp = 2
tracks/1/loop_wrap = true
tracks/1/keys = PackedFloat32Array(0, 1, 0.28552, 0.392348, 0.63782, 1.1, 1, 0.286, 0.37, 0.638, 2.6, 1, 0.286, 0.43, 0.638, 4, 1, 0.28552, 0.392348, 0.63782)
[sub_resource type="AnimationLibrary" id="AnimationLibrary_dymnn"]
_data = {
"float": SubResource("Animation_fnyq0")
}
[node name="MenuBg" type="Node3D"]
script = ExtResource("1_mvbgk")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.323323, 0.972071)
current = true
near = 0.003
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_hqpr0")
camera_attributes = SubResource("CameraAttributesPractical_cvruf")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
transform = Transform3D(0.902146, 0.161505, -0.400062, -0.132644, 0.986206, 0.0990162, 0.410534, -0.0362611, 0.911124, 0, 1.52296, 0)
shadow_enabled = true
shadow_bias = 0.01
directional_shadow_max_distance = 10.0
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_dymnn")
}
autoplay = "float"
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(-0.0374396, -0.00439883, 0.032847, -0.0194431, 0.0430478, -0.0163967, -0.0268373, -0.0250506, -0.0339444, 0.152866, 0.215249, 0.637892)
mesh = ExtResource("1_8u4bs")
skeleton = NodePath("../..")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(0.0475114, -0.0035802, -0.0151608, 0.0155677, 0.0091615, 0.0466231, -0.000560477, -0.049023, 0.00982022, 0.28582, 0.375627, 0.637932)
mesh = ExtResource("1_8u4bs")
[node name="MenuUi" parent="." instance=ExtResource("2_5dpja")]
[connection signal="start_pressed" from="MenuUi" to="." method="_on_menu_ui_start_pressed"]

6
menu/menu_ui.gd Normal file
View file

@ -0,0 +1,6 @@
extends Control
signal start_pressed
func _on_button_pressed() -> void:
start_pressed.emit()

55
menu/menu_ui.tscn Normal file
View file

@ -0,0 +1,55 @@
[gd_scene load_steps=5 format=3 uid="uid://dfarwiq8kvcxa"]
[ext_resource type="Texture2D" uid="uid://cxbx2nxeemwdu" path="res://menu/logo.png" id="1_eaex1"]
[ext_resource type="Script" path="res://menu/menu_ui.gd" id="1_umdqb"]
[sub_resource type="InputEventKey" id="InputEventKey_437qb"]
device = -1
keycode = 32
unicode = 32
[sub_resource type="Shortcut" id="Shortcut_rqmbn"]
events = [SubResource("InputEventKey_437qb")]
[node name="MenuUi" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_umdqb")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -540.0
offset_top = -191.0
offset_right = 88.0
offset_bottom = 215.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_eaex1")
expand_mode = 1
[node name="Button" type="Button" parent="."]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -24.0
offset_top = -49.0
offset_right = 22.0
offset_bottom = -18.0
grow_horizontal = 2
grow_vertical = 0
shortcut = SubResource("Shortcut_rqmbn")
text = "Start"
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]

View file

@ -11,14 +11,19 @@ config_version=5
[application]
config/name="programovani-kostky"
run/main_scene="res://main.tscn"
run/main_scene="res://menu/menu_bg.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg"
config/icon="res://game/icon.svg"
[filesystem]
import/fbx/enabled=false
[gui]
theme/custom="res://main.tres"
[rendering]
anti_aliasing/quality/msaa_2d=2
anti_aliasing/quality/msaa_3d=2