diff --git a/vegeconda/field.gd b/vegeconda/field.gd deleted file mode 100644 index eafffac..0000000 --- a/vegeconda/field.gd +++ /dev/null @@ -1,50 +0,0 @@ -class_name Field - -extends StaticBody2D - - -enum FieldType { - MIDDLE, CORNER, TOP, LEFT, -} -@export var type: FieldType - - -var POSITIONS_BY_TYPE : Dictionary = { - FieldType.MIDDLE: [ - Vector2(0, 0), - Vector2(16, 0), - Vector2(32, 0), - Vector2(0, 16), - Vector2(16, 16), - Vector2(32, 16), - ], - FieldType.CORNER: [ - Vector2(64, 32), - Vector2(64, 48), - ], - FieldType.TOP: [ - Vector2(0, 32), - Vector2(16, 32), - Vector2(32, 32), - Vector2(0, 48), - Vector2(16, 48), - Vector2(32, 48), - ], - FieldType.LEFT: [ - Vector2(48, 0), - Vector2(48, 16), - Vector2(48, 32), - Vector2(48, 48), - Vector2(64, 0), - Vector2(64, 16), - ], -} - - -func _ready() -> void: - update_atlas_position() - - -func update_atlas_position() -> void: - var positions = POSITIONS_BY_TYPE[type] - $Sprite2D.texture.region.position = positions[randi() % positions.size()] diff --git a/vegeconda/field.tscn b/vegeconda/field.tscn deleted file mode 100644 index 6f354af..0000000 --- a/vegeconda/field.tscn +++ /dev/null @@ -1,23 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://bo3w0sj364gql"] - -[ext_resource type="Texture2D" uid="uid://cueeywtu6xdbv" path="res://data/images/Fierd.png" id="1_84wqk"] -[ext_resource type="Script" path="res://field.gd" id="1_hih70"] - -[sub_resource type="AtlasTexture" id="AtlasTexture_moxxr"] -atlas = ExtResource("1_84wqk") -region = Rect2(0, 0, 16, 16) - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_17j0p"] -size = Vector2(16, 16) - -[node name="Field" type="StaticBody2D"] -script = ExtResource("1_hih70") - -[node name="Sprite2D" type="Sprite2D" parent="."] -texture_filter = 1 -position = Vector2(8, 8) -texture = SubResource("AtlasTexture_moxxr") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(8, 8) -shape = SubResource("RectangleShape2D_17j0p") diff --git a/vegeconda/forest.gd b/vegeconda/forest.gd deleted file mode 100644 index e63ee4d..0000000 --- a/vegeconda/forest.gd +++ /dev/null @@ -1,70 +0,0 @@ -class_name Forest - -extends StaticBody2D - - -enum ForestType { - TOP, BOTTOM, LEFT, RIGHT, - CORNER_TOP_LEFT, CORNER_TOP_RIGHT, - CORNER_BOTTOM_LEFT, CORNER_BOTTOM_RIGHT, - FRAME_TOP_LEFT, FRAME_TOP_RIGHT, - FRAME_BOTTOM_LEFT, FRAME_BOTTOM_RIGHT, -} -@export var type: ForestType - - -var POSITIONS_BY_TYPE : Dictionary = { - ForestType.TOP: [ - Vector2(16, 0), - Vector2(32, 0), - Vector2(16, 16), - Vector2(32, 16), - ], - ForestType.BOTTOM: [ - Vector2(16, 32), - Vector2(32, 32), - Vector2(16, 48), - Vector2(32, 48), - ], - ForestType.LEFT: [ - Vector2(0, 16), - Vector2(0, 32), - ], - ForestType.RIGHT: [ - Vector2(48, 16), - Vector2(48, 32), - ], - ForestType.CORNER_TOP_LEFT: [ - Vector2(0, 0), - ], - ForestType.CORNER_TOP_RIGHT: [ - Vector2(48, 0), - ], - ForestType.CORNER_BOTTOM_LEFT: [ - Vector2(0, 48), - ], - ForestType.CORNER_BOTTOM_RIGHT: [ - Vector2(48, 48), - ], - ForestType.FRAME_TOP_LEFT: [ - Vector2(64, 32), - ], - ForestType.FRAME_TOP_RIGHT: [ - Vector2(64, 48), - ], - ForestType.FRAME_BOTTOM_LEFT: [ - Vector2(64, 0), - ], - ForestType.FRAME_BOTTOM_RIGHT: [ - Vector2(64, 16), - ], -} - - -func _ready() -> void: - update_atlas_position() - - -func update_atlas_position() -> void: - var positions = POSITIONS_BY_TYPE[type] - $Sprite2D.texture.region.position = positions[randi() % positions.size()] diff --git a/vegeconda/forest.tscn b/vegeconda/forest.tscn deleted file mode 100644 index 14d8d75..0000000 --- a/vegeconda/forest.tscn +++ /dev/null @@ -1,23 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://cu2ub0e6tk0a0"] - -[ext_resource type="Script" path="res://forest.gd" id="1_2dsrk"] -[ext_resource type="Texture2D" uid="uid://b6wbb26dayco1" path="res://data/images/Forest.png" id="1_jq2nb"] - -[sub_resource type="AtlasTexture" id="AtlasTexture_dddgb"] -atlas = ExtResource("1_jq2nb") -region = Rect2(0, 0, 16, 16) - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_7s50m"] -size = Vector2(16, 16) - -[node name="Forest" type="StaticBody2D"] -script = ExtResource("1_2dsrk") - -[node name="Sprite2D" type="Sprite2D" parent="."] -texture_filter = 1 -position = Vector2(8, 8) -texture = SubResource("AtlasTexture_dddgb") - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -position = Vector2(8, 8) -shape = SubResource("RectangleShape2D_7s50m") diff --git a/vegeconda/level.gd b/vegeconda/level.gd index b589f1e..39b646a 100644 --- a/vegeconda/level.gd +++ b/vegeconda/level.gd @@ -1,27 +1,53 @@ extends Node2D -const FOREST = preload("res://forest.tscn") - - func _ready() -> void: create_level() func create_level() -> void: - var corners : Array - for i in range(4): - corners.append(FOREST.instantiate()) + create_forest() + create_field() + + +func create_forest() -> void: + $TileMapLayer.set_cell(Vector2i(0,0), 0, Vector2i(0,0)) + $TileMapLayer.set_cell(Vector2i(19,0), 0, Vector2i(3,0)) + $TileMapLayer.set_cell(Vector2i(0,10), 0, Vector2i(0,3)) + $TileMapLayer.set_cell(Vector2i(19,10), 0, Vector2i(3,3)) - corners[0].type = Forest.ForestType.CORNER_TOP_LEFT - corners[1].type = Forest.ForestType.CORNER_TOP_RIGHT - corners[2].type = Forest.ForestType.CORNER_BOTTOM_LEFT - corners[3].type = Forest.ForestType.CORNER_BOTTOM_RIGHT + const TOP_TILES = [ Vector2i(1,0), Vector2i(2,0), Vector2i(1,1), Vector2i(2,1) ] + const BOTTOM_TILES = [ Vector2i(1,2), Vector2i(2,2), Vector2i(1,3), Vector2i(2,3) ] + for i in range(1, 19): + $TileMapLayer.set_cell(Vector2i(i,0), 0, TOP_TILES[randi() % TOP_TILES.size()]) + $TileMapLayer.set_cell(Vector2i(i,10), 0, BOTTOM_TILES[randi() % BOTTOM_TILES.size()]) - corners[0].position = Vector2(0, 0) * 16 - corners[1].position = Vector2(19, 0) * 16 - corners[2].position = Vector2(0, 10) * 16 - corners[3].position = Vector2(19, 10) * 16 - - for corner in corners: - add_child(corner) + const LEFT_TILES = [ Vector2i(0,1), Vector2i(0,2) ] + const RIGHT_TILES = [ Vector2i(3,1), Vector2i(3,2) ] + for i in range(1, 10): + $TileMapLayer.set_cell(Vector2i(0,i), 0, LEFT_TILES[randi() % LEFT_TILES.size()]) + $TileMapLayer.set_cell(Vector2i(19,i), 0, RIGHT_TILES[randi() % RIGHT_TILES.size()]) + + +func create_field() -> void: + const CORNER_TILES = [ Vector2i(4,2), Vector2i(4,3) ] + $TileMapLayer.set_cell(Vector2i(1,1), 1, CORNER_TILES[randi() % CORNER_TILES.size()]) + const TOP_TILES = [ + Vector2i(0,2), Vector2i(1,2), Vector2i(2,2), + Vector2i(0,3), Vector2i(1,3), Vector2i(2,3), + ] + for i in range(2, 19): + $TileMapLayer.set_cell(Vector2i(i,1), 1, TOP_TILES[randi() % TOP_TILES.size()]) + const LEFT_TILES = [ + Vector2i(3,0), Vector2i(4,0), Vector2i(3,1), + Vector2i(4,1), Vector2i(3,2), Vector2i(3,3), + ] + for i in range(2, 10): + $TileMapLayer.set_cell(Vector2i(1,i), 1, LEFT_TILES[randi() % LEFT_TILES.size()]) + const CENTER_TILES = [ + Vector2i(0,0), Vector2i(1,0), Vector2i(2,0), + Vector2i(0,1), Vector2i(1,1), Vector2i(2,1), + ] + for i in range(2, 19): + for j in range(2, 10): + $TileMapLayer.set_cell(Vector2i(i,j), 1, CENTER_TILES[randi() % CENTER_TILES.size()]) diff --git a/vegeconda/level.tscn b/vegeconda/level.tscn index 32e59dc..9b73f91 100644 --- a/vegeconda/level.tscn +++ b/vegeconda/level.tscn @@ -1,6 +1,61 @@ -[gd_scene load_steps=2 format=3 uid="uid://c1h0h1viac0gy"] +[gd_scene load_steps=7 format=3 uid="uid://c1h0h1viac0gy"] [ext_resource type="Script" path="res://level.gd" id="1_t0agp"] +[ext_resource type="Texture2D" uid="uid://b6wbb26dayco1" path="res://data/images/Forest.png" id="2_acuqw"] +[ext_resource type="Texture2D" uid="uid://cueeywtu6xdbv" path="res://data/images/Fierd.png" id="3_uas50"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ux773"] +texture = ExtResource("2_acuqw") +0:0/0 = 0 +1:0/0 = 0 +2:0/0 = 0 +3:0/0 = 0 +4:0/0 = 0 +0:1/0 = 0 +1:1/0 = 0 +2:1/0 = 0 +3:1/0 = 0 +4:1/0 = 0 +0:2/0 = 0 +1:2/0 = 0 +2:2/0 = 0 +3:2/0 = 0 +4:2/0 = 0 +0:3/0 = 0 +1:3/0 = 0 +2:3/0 = 0 +3:3/0 = 0 +4:3/0 = 0 + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_yfk20"] +texture = ExtResource("3_uas50") +0:0/0 = 0 +1:0/0 = 0 +2:0/0 = 0 +3:0/0 = 0 +4:0/0 = 0 +0:1/0 = 0 +1:1/0 = 0 +2:1/0 = 0 +3:1/0 = 0 +4:1/0 = 0 +0:2/0 = 0 +1:2/0 = 0 +2:2/0 = 0 +3:2/0 = 0 +4:2/0 = 0 +0:3/0 = 0 +1:3/0 = 0 +2:3/0 = 0 +3:3/0 = 0 +4:3/0 = 0 + +[sub_resource type="TileSet" id="TileSet_e0bu0"] +sources/0 = SubResource("TileSetAtlasSource_ux773") +sources/1 = SubResource("TileSetAtlasSource_yfk20") [node name="Level" type="Node2D"] script = ExtResource("1_t0agp") + +[node name="TileMapLayer" type="TileMapLayer" parent="."] +tile_set = SubResource("TileSet_e0bu0") diff --git a/vegeconda/project.godot b/vegeconda/project.godot index 2a5dcb6..dc2cec4 100644 --- a/vegeconda/project.godot +++ b/vegeconda/project.godot @@ -11,16 +11,19 @@ config_version=5 [application] config/name="Vegeconda" -run/main_scene="res://level.tscn" config/features=PackedStringArray("4.3", "GL Compatibility") config/icon="res://icon.svg" [display] -window/size/viewport_width=2560 -window/size/viewport_height=1440 +window/size/viewport_width=1280 +window/size/viewport_height=720 window/size/resizable=false -window/stretch/scale=8.0 +window/stretch/scale=4.0 + +[dotnet] + +project/assembly_name="Vegeconda" [rendering]