From 5e62cca19ee202353d9ad17c9ee0cfe96671864b Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Thu, 26 Sep 2024 22:45:36 +0100 Subject: dungeon_manager: Create 3D portal model with texture --- models/portal.blend | Bin 0 -> 923584 bytes models/portal.blend.import | 51 +++++++++++++++++++++++++++++++++++++++++++++ models/portal.png | Bin 0 -> 1143 bytes models/portal.png.import | 34 ++++++++++++++++++++++++++++++ models/portal.xcf | Bin 0 -> 6296 bytes prefabs/exit.tscn | 14 ++++--------- scripts/dungeon_manager.gd | 10 ++++++++- 7 files changed, 98 insertions(+), 11 deletions(-) create mode 100644 models/portal.blend create mode 100644 models/portal.blend.import create mode 100644 models/portal.png create mode 100644 models/portal.png.import create mode 100644 models/portal.xcf diff --git a/models/portal.blend b/models/portal.blend new file mode 100644 index 0000000..4a7a8a3 Binary files /dev/null and b/models/portal.blend differ diff --git a/models/portal.blend.import b/models/portal.blend.import new file mode 100644 index 0000000..2ea2d0a --- /dev/null +++ b/models/portal.blend.import @@ -0,0 +1,51 @@ +[remap] + +importer="scene" +importer_version=1 +type="PackedScene" +uid="uid://qk10uduhdjr1" +path="res://.godot/imported/portal.blend-abbdc16f3d286a69c387458cff373f6c.scn" + +[deps] + +source_file="res://models/portal.blend" +dest_files=["res://.godot/imported/portal.blend-abbdc16f3d286a69c387458cff373f6c.scn"] + +[params] + +nodes/root_type="" +nodes/root_name="" +nodes/apply_root_scale=true +nodes/root_scale=1.0 +nodes/import_as_skeleton_bones=false +meshes/ensure_tangents=true +meshes/generate_lods=true +meshes/create_shadow_meshes=true +meshes/light_baking=1 +meshes/lightmap_texel_size=0.2 +meshes/force_disable_compression=false +skins/use_named_skins=true +animation/import=true +animation/fps=30 +animation/trimming=false +animation/remove_immutable_tracks=true +animation/import_rest_as_RESET=false +import_script/path="" +_subresources={} +blender/nodes/visible=0 +blender/nodes/active_collection_only=false +blender/nodes/punctual_lights=true +blender/nodes/cameras=true +blender/nodes/custom_properties=true +blender/nodes/modifiers=1 +blender/meshes/colors=false +blender/meshes/uvs=true +blender/meshes/normals=true +blender/meshes/tangents=true +blender/meshes/skins=2 +blender/meshes/export_bones_deforming_mesh_only=false +blender/materials/unpack_enabled=true +blender/materials/export_materials=1 +blender/animation/limit_playback=true +blender/animation/always_sample=true +blender/animation/group_tracks=true diff --git a/models/portal.png b/models/portal.png new file mode 100644 index 0000000..653d74e Binary files /dev/null and b/models/portal.png differ diff --git a/models/portal.png.import b/models/portal.png.import new file mode 100644 index 0000000..ceea174 --- /dev/null +++ b/models/portal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dc0hjmpa4ta58" +path="res://.godot/imported/portal.png-1a01825bc426d7d71d336be9d465e5bf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://models/portal.png" +dest_files=["res://.godot/imported/portal.png-1a01825bc426d7d71d336be9d465e5bf.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=0 diff --git a/models/portal.xcf b/models/portal.xcf new file mode 100644 index 0000000..96859e3 Binary files /dev/null and b/models/portal.xcf differ diff --git a/prefabs/exit.tscn b/prefabs/exit.tscn index c6da7d7..33fa94e 100644 --- a/prefabs/exit.tscn +++ b/prefabs/exit.tscn @@ -1,10 +1,6 @@ -[gd_scene load_steps=4 format=3 uid="uid://bby6nvx5y03x"] +[gd_scene load_steps=3 format=3 uid="uid://bby6nvx5y03x"] -[sub_resource type="BoxMesh" id="BoxMesh_80n3v"] -size = Vector3(1, 0.1, 1) - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_yj1cw"] -albedo_color = Color(0, 0, 0.988235, 1) +[ext_resource type="PackedScene" uid="uid://qk10uduhdjr1" path="res://models/portal.blend" id="1_qaf38"] [sub_resource type="BoxShape3D" id="BoxShape3D_5ln3u"] @@ -12,10 +8,8 @@ albedo_color = Color(0, 0, 0.988235, 1) collision_layer = 4 collision_mask = 4 -[node name="MeshInstance3D" type="MeshInstance3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0) -mesh = SubResource("BoxMesh_80n3v") -surface_material_override/0 = SubResource("StandardMaterial3D_yj1cw") +[node name="portal" parent="." instance=ExtResource("1_qaf38")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.5, 0, -0.5) [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) diff --git a/scripts/dungeon_manager.gd b/scripts/dungeon_manager.gd index 12b80fa..39b6131 100644 --- a/scripts/dungeon_manager.gd +++ b/scripts/dungeon_manager.gd @@ -45,8 +45,16 @@ func create_exit() -> void: exit.connect("body_entered", _on_player_exit) while not found_pos: var pos = Vector2i(randi_range(0, grid_width-1), randi_range(0, grid_height-1)) + var left = pos + Vector2i.LEFT + var right = pos + Vector2i.RIGHT + var up = pos + Vector2i.UP + var down = pos + Vector2i.DOWN - if grid[pos.y * grid_width + pos.x] == Tile.Tile.FLOOR: + if grid[pos.y * grid_width + pos.x] == Tile.Tile.FLOOR \ + and grid[left.y * grid_width + left.x] == Tile.Tile.FLOOR \ + and grid[right.y * grid_width + right.x] == Tile.Tile.FLOOR \ + and grid[up.y * grid_width + up.x] == Tile.Tile.FLOOR \ + and grid[down.y * grid_width + down.x] == Tile.Tile.FLOOR: exit.position = Vector3(pos.x, 0, pos.y) + Vector3(0.5, 0, 0.5) found_pos = true -- cgit