This commit is contained in:
megamichi 2025-02-28 17:13:53 +01:00
commit 7bb83a1340
35 changed files with 735 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

15
.gitignore vendored Normal file
View file

@ -0,0 +1,15 @@
# Godot 4+ specific ignores
.godot/
# Godot-specific ignores
.import/
export.cfg
export_presets.cfg
# Imported translations (automatically generated from CSV files)
*.translation
# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json

7
LICENCE.md Normal file
View file

@ -0,0 +1,7 @@
Copyright (c) 2025 Michael S.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# Maze Generator made in Godot 4
uses TileMapLayers

BIN
assets/1739714130462.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bffviwchp0c7f"
path="res://.godot/imported/1739714130462.jpg-b508e8a1d2cea8bd72a258f2ca310d39.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/1739714130462.jpg"
dest_files=["res://.godot/imported/1739714130462.jpg-b508e8a1d2cea8bd72a258f2ca310d39.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

BIN
assets/blo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

34
assets/blo.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b27nu8tq38o1h"
path="res://.godot/imported/blo.png-8514f867270f641ad8483b5297a0acb2.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/blo.png"
dest_files=["res://.godot/imported/blo.png-8514f867270f641ad8483b5297a0acb2.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

BIN
assets/butto_toggledn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cwuboikffi42n"
path="res://.godot/imported/butto_toggledn.png-4b10b88d4c42fa6ddb3779d487ef0d22.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/butto_toggledn.png"
dest_files=["res://.godot/imported/butto_toggledn.png-4b10b88d4c42fa6ddb3779d487ef0d22.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

BIN
assets/button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

34
assets/button.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c8shyusyohh1u"
path="res://.godot/imported/button.png-c79155b6e84601a7c5a042250ad77b07.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/button.png"
dest_files=["res://.godot/imported/button.png-c79155b6e84601a7c5a042250ad77b07.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

BIN
assets/end.wav Normal file

Binary file not shown.

24
assets/end.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dvgttysddy5yy"
path="res://.godot/imported/end.wav-4375002f3da799f8c457d7b03062a19d.sample"
[deps]
source_file="res://assets/end.wav"
dest_files=["res://.godot/imported/end.wav-4375002f3da799f8c457d7b03062a19d.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

1
assets/icon.svg Normal file
View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><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 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
assets/icon.svg.import Normal file
View file

@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://l23nhnmvj08l"
path="res://.godot/imported/icon.svg-56083ea2a1f1a4f1e49773bdc6d7826c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/icon.svg"
dest_files=["res://.godot/imported/icon.svg-56083ea2a1f1a4f1e49773bdc6d7826c.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

BIN
assets/maze_tileset.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://d11d3alxengr0"
path="res://.godot/imported/maze_tileset.png-f77bccccd37a90aa8b3572820de59417.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/maze_tileset.png"
dest_files=["res://.godot/imported/maze_tileset.png-f77bccccd37a90aa8b3572820de59417.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

25
end.tscn Normal file
View file

@ -0,0 +1,25 @@
[gd_scene load_steps=3 format=3 uid="uid://b4qu1t0icb1sa"]
[ext_resource type="Texture2D" uid="uid://bffviwchp0c7f" path="res://assets/1739714130462.jpg" id="1_xnady"]
[ext_resource type="AudioStream" uid="uid://dvgttysddy5yy" path="res://assets/end.wav" id="2_pdnru"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_xnady")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="TextureRect"]
stream = ExtResource("2_pdnru")
autoplay = true

55
generator.gd Normal file
View file

@ -0,0 +1,55 @@
extends Sprite2D
var maze_pos = Vector2i(0, 0)
var dir_history = []
var directions = [Vector2i.UP, Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT]
var tile_b = Vector2i(1, 0) # border # black
var tile_n = Vector2i(0, 0) # no visited # grey
var tile_v = Vector2i(0, 1) # visited # blue
var tile_s = Vector2i(1, 1) # visited and stuck # green
signal done
@onready var Maze = $"../maze"
func _ready() -> void:
Maze.set_cell(maze_pos,0,tile_v)
func get_neighbors():
var dlist = []
for dir in directions:
var next_pos = maze_pos + dir * 2
if $"../maze".get_cell_atlas_coords(next_pos) == tile_n:
#$"../maze".set_cell(next_pos,0,tile_v)
#print(next_pos)
dlist.append(dir)
print(dlist)
return dlist
func _process(delta: float) -> void:
var dlist = get_neighbors()
if dlist.is_empty():
if dir_history.is_empty():
print("Maze generation completed")
done.emit()
set_process(false)
return
var removed_item = dir_history.pop_back()
$"../maze".set_cell(maze_pos-removed_item, 0, tile_s)
$"../maze".set_cell(maze_pos, 0, tile_s)
maze_pos = maze_pos - removed_item*2
else:
# 2.1 pick random neighbar
var dir = dlist.pick_random()
# Wand zwischen Zellen entfernen
$"../maze".set_cell(maze_pos + dir, 0, tile_v)
# add to stack
dir_history.append(dir)
# set new cell
maze_pos += dir * 2
$"../maze".set_cell(maze_pos, 0, tile_v)
position = 16 * maze_pos+Vector2i(1, 1)

BIN
how does it work?.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bcp8jli5qcqc2"
path="res://.godot/imported/how does it work?.jpg-f28590553fb40d554183b8248255c8e7.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://how does it work?.jpg"
dest_files=["res://.godot/imported/how does it work?.jpg-f28590553fb40d554183b8248255c8e7.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

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

34
icon.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://p32ebl4thj62"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.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

120
main.tscn Normal file

File diff suppressed because one or more lines are too long

28
player.gd Normal file
View file

@ -0,0 +1,28 @@
extends CharacterBody2D
const SPEED = 100
var direction: Vector2
var button_toggled: bool
var inp :Vector3
func _physics_process(delta: float) -> void:
if button_toggled:
inp = Input.get_accelerometer()
direction = Vector2(inp.x,-inp.y)
else:
if $"../CanvasLayer/stick/Joystick".posVector:
direction = $"../CanvasLayer/stick/Joystick".posVector
else:
direction = Input.get_vector("ui_left", "ui_right","ui_up","ui_down")
velocity = direction*SPEED
move_and_slide()
func _on_generator_done() -> void:
$Camera2D.enabled = true
func _on_button_toggled(toggled_on: bool) -> void:
button_toggled = toggled_on

31
project.godot Normal file
View file

@ -0,0 +1,31 @@
; 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="maze-generator"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.3", "GL Compatibility")
config/icon="res://icon.png"
[display]
window/stretch/mode="viewport"
window/stretch/aspect="keep_height"
[input_devices]
pointing/emulate_touch_from_mouse=true
[rendering]
textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="mobile"
textures/vram_compression/import_etc2_astc=true

38
stick/Knob.gd Normal file
View file

@ -0,0 +1,38 @@
extends Sprite2D
@onready var parent = $".."
var pressing = false
@export var maxLength = 50
var deadzone = 15
func _ready():
#deadzone = parent.deadzone
maxLength *= parent.scale.x
func _process(delta):
if pressing:
if get_global_mouse_position().distance_to(parent.global_position) <= maxLength:
global_position = get_global_mouse_position()
else:
var angle = parent.global_position.angle_to_point(get_global_mouse_position())
global_position.x = parent.global_position.x + cos(angle)*maxLength
global_position.y = parent.global_position.y + sin(angle)*maxLength
calculateVector()
else:
global_position = lerp(global_position, parent.global_position, delta*50)
parent.posVector = Vector2(0,0)
func calculateVector():
if abs((global_position.x - parent.global_position.x)) >= deadzone:
parent.posVector.x = (global_position.x - parent.global_position.x)/maxLength
if abs((global_position.y - parent.global_position.y)) >= deadzone:
parent.posVector.y = (global_position.y - parent.global_position.y)/maxLength
func _on_button_button_down():
pressing = true
func _on_button_button_up():
pressing = false

BIN
stick/joyknobpng.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://hg42snfhm6ei"
path="res://.godot/imported/joyknobpng.png-a28fc8935f3ab4ef8d5e001c65466020.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://stick/joyknobpng.png"
dest_files=["res://.godot/imported/joyknobpng.png-a28fc8935f3ab4ef8d5e001c65466020.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

BIN
stick/joyring.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

34
stick/joyring.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bidhxucp2kd66"
path="res://.godot/imported/joyring.png-ec9f3d6435e376d6bd5a8bc8d136998d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://stick/joyring.png"
dest_files=["res://.godot/imported/joyring.png-ec9f3d6435e376d6bd5a8bc8d136998d.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

8
stick/joystick.gd Normal file
View file

@ -0,0 +1,8 @@
extends Node2D
var posVector: Vector2
@export var deadzone = 15
func _ready() -> void:
if not DisplayServer.is_touchscreen_available():
set_process(false)

27
stick/joystick.tscn Normal file
View file

@ -0,0 +1,27 @@
[gd_scene load_steps=6 format=3 uid="uid://dm6q0abakck7u"]
[ext_resource type="Script" path="res://stick/joystick.gd" id="1_ii2vn"]
[ext_resource type="Texture2D" uid="uid://bidhxucp2kd66" path="res://stick/joyring.png" id="2_w2jn3"]
[ext_resource type="Texture2D" uid="uid://hg42snfhm6ei" path="res://stick/joyknobpng.png" id="3_voruw"]
[ext_resource type="Script" path="res://stick/Knob.gd" id="4_g4kk1"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wuxim"]
size = Vector2(100, 100)
[node name="Joystick" type="Node2D"]
script = ExtResource("1_ii2vn")
[node name="Ring" type="Sprite2D" parent="."]
scale = Vector2(0.055, 0.055)
texture = ExtResource("2_w2jn3")
[node name="Knob" type="Sprite2D" parent="."]
scale = Vector2(0.02, 0.02)
texture = ExtResource("3_voruw")
script = ExtResource("4_g4kk1")
[node name="Button" type="TouchScreenButton" parent="."]
shape = SubResource("RectangleShape2D_wuxim")
[connection signal="pressed" from="Button" to="Knob" method="_on_button_button_down"]
[connection signal="released" from="Button" to="Knob" method="_on_button_button_up"]

8
ziel.gd Normal file
View file

@ -0,0 +1,8 @@
extends Sprite2D
func _on_area_2d_body_entered(body: Node2D) -> void:
if body.name == "Player":
get_tree().change_scene_to_file("res://end.tscn")