Added Door to Level
This commit is contained in:
+5
-3
@@ -31,9 +31,9 @@ region = Rect2(0, 16, 16, 16)
|
||||
atlas = ExtResource("1_n81fa")
|
||||
region = Rect2(16, 0, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_il5p2"]
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d06fb"]
|
||||
atlas = ExtResource("1_n81fa")
|
||||
region = Rect2(48, 48, 16, 16)
|
||||
region = Rect2(16, 48, 16, 16)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wwyt8"]
|
||||
atlas = ExtResource("1_n81fa")
|
||||
@@ -150,7 +150,7 @@ animations = [{
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_il5p2")
|
||||
"texture": SubResource("AtlasTexture_d06fb")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"bottom_door_opened",
|
||||
@@ -257,3 +257,5 @@ animation = &"bottom_door_opened"
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(8, 8)
|
||||
shape = SubResource("RectangleShape2D_notjl")
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animated_sprite_2d_animation_finished"]
|
||||
|
||||
+81
-29
@@ -1,5 +1,43 @@
|
||||
extends Node2D
|
||||
|
||||
@export_range(2, 17) var top_door_x: int = 2
|
||||
@export_range(2, 17) var bottom_door_x: int = 2
|
||||
|
||||
|
||||
const DOOR = preload("res://door.tscn")
|
||||
|
||||
|
||||
const TOP_LEFT_FOREST = Vector2i(0,0)
|
||||
const TOP_RIGHT_FOREST = Vector2i(3,0)
|
||||
const BOTTOM_LEFT_FOREST = Vector2i(0,3)
|
||||
const BOTTOM_RIGHT_FOREST = Vector2i(3,3)
|
||||
|
||||
const TOP_FORESTS = [ Vector2i(1,0), Vector2i(2,0), Vector2i(1,1), Vector2i(2,1) ]
|
||||
const BOTTOM_FORESTS = [ Vector2i(1,2), Vector2i(2,2), Vector2i(1,3), Vector2i(2,3) ]
|
||||
|
||||
const LEFT_FORESTS = [ Vector2i(0,1), Vector2i(0,2) ]
|
||||
const RIGHT_FORESTS = [ Vector2i(3,1), Vector2i(3,2) ]
|
||||
|
||||
const TOP_LEFT_DOOR = Vector2i(4,2)
|
||||
const TOP_RIGHT_DOOR = Vector2i(4,3)
|
||||
const BOTTOM_LEFT_DOOR = Vector2i(4,0)
|
||||
const BOTTOM_RIGHT_DOOR = Vector2i(4,1)
|
||||
|
||||
|
||||
const CORNER_FIELDS = [ Vector2i(4,2), Vector2i(4,3) ]
|
||||
const TOP_FIELDS = [
|
||||
Vector2i(0,2), Vector2i(1,2), Vector2i(2,2), Vector2i(0,3), Vector2i(1,3), Vector2i(2,3),
|
||||
]
|
||||
const LEFT_FIELDS = [
|
||||
Vector2i(3,0), Vector2i(4,0), Vector2i(3,1), Vector2i(4,1), Vector2i(3,2), Vector2i(3,3),
|
||||
]
|
||||
const CENTER_FIELDS = [
|
||||
Vector2i(0,0), Vector2i(1,0), Vector2i(2,0), Vector2i(0,1), Vector2i(1,1), Vector2i(2,1),
|
||||
]
|
||||
|
||||
var top_door = null
|
||||
var bottom_door = null
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
create_level()
|
||||
@@ -8,46 +46,60 @@ func _ready() -> void:
|
||||
func create_level() -> void:
|
||||
create_forest()
|
||||
create_field()
|
||||
add_top_door()
|
||||
add_bottom_door()
|
||||
|
||||
|
||||
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))
|
||||
$TileMapLayer.set_cell(Vector2i(0,0), 0, TOP_LEFT_FOREST)
|
||||
$TileMapLayer.set_cell(Vector2i(19,0), 0, TOP_RIGHT_FOREST)
|
||||
$TileMapLayer.set_cell(Vector2i(0,10), 0, BOTTOM_LEFT_FOREST)
|
||||
$TileMapLayer.set_cell(Vector2i(19,10), 0, BOTTOM_RIGHT_FOREST)
|
||||
|
||||
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()])
|
||||
$TileMapLayer.set_cell(Vector2i(i,0), 0, TOP_FORESTS[randi() % TOP_FORESTS.size()])
|
||||
$TileMapLayer.set_cell(Vector2i(i,10), 0, BOTTOM_FORESTS[randi() % BOTTOM_FORESTS.size()])
|
||||
|
||||
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()])
|
||||
$TileMapLayer.set_cell(Vector2i(0,i), 0, LEFT_FORESTS[randi() % LEFT_FORESTS.size()])
|
||||
$TileMapLayer.set_cell(Vector2i(19,i), 0, RIGHT_FORESTS[randi() % RIGHT_FORESTS.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),
|
||||
]
|
||||
$TileMapLayer.set_cell(Vector2i(1,1), 1, CORNER_FIELDS[randi() % CORNER_FIELDS.size()])
|
||||
|
||||
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),
|
||||
]
|
||||
$TileMapLayer.set_cell(Vector2i(i,1), 1, TOP_FIELDS[randi() % TOP_FIELDS.size()])
|
||||
|
||||
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),
|
||||
]
|
||||
$TileMapLayer.set_cell(Vector2i(1,i), 1, LEFT_FIELDS[randi() % LEFT_FIELDS.size()])
|
||||
|
||||
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()])
|
||||
$TileMapLayer.set_cell(Vector2i(i,j), 1, CENTER_FIELDS[randi() % CENTER_FIELDS.size()])
|
||||
|
||||
func add_top_door():
|
||||
const y = 0
|
||||
$TileMapLayer.set_cell(Vector2i(top_door_x-1,y), 0, TOP_LEFT_DOOR)
|
||||
$TileMapLayer.set_cell(Vector2i(top_door_x,y), 1, LEFT_FIELDS[randi() % LEFT_FIELDS.size()])
|
||||
$TileMapLayer.set_cell(Vector2i(top_door_x,y+1), 1, CENTER_FIELDS[randi() % LEFT_FIELDS.size()])
|
||||
$TileMapLayer.set_cell(Vector2i(top_door_x+1,y), 0, TOP_RIGHT_DOOR)
|
||||
|
||||
top_door = DOOR.instantiate()
|
||||
top_door.type = Door.DoorType.TOP_DOOR
|
||||
top_door.state = Door.DoorState.CLOSED
|
||||
top_door.position = Vector2i(top_door_x,y)*16
|
||||
add_child(top_door)
|
||||
|
||||
|
||||
func add_bottom_door():
|
||||
const y = 10
|
||||
$TileMapLayer.set_cell(Vector2i(bottom_door_x-1,y), 0, BOTTOM_LEFT_DOOR)
|
||||
$TileMapLayer.set_cell(Vector2i(bottom_door_x,y), 1, LEFT_FIELDS[randi() % LEFT_FIELDS.size()])
|
||||
$TileMapLayer.set_cell(Vector2i(bottom_door_x+1,y), 0, BOTTOM_RIGHT_DOOR)
|
||||
|
||||
bottom_door = DOOR.instantiate()
|
||||
bottom_door.type = Door.DoorType.BOTTOM_DOOR
|
||||
bottom_door.state = Door.DoorState.CLOSED
|
||||
bottom_door.position = Vector2i(bottom_door_x,y)*16
|
||||
add_child(bottom_door)
|
||||
|
||||
@@ -11,6 +11,7 @@ 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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user