summaryrefslogtreecommitdiff
path: root/stage
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-26 11:29:04 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-26 11:29:04 +0100
commitd572bc0a27b05c6632ba76bd630c7c4fd8f0ae5d (patch)
tree8bffeb9f025dc1c77bc53b65caf10d9b1fab5f2c /stage
initial commit
Diffstat (limited to 'stage')
-rw-r--r--stage/assets/tileset-01.pngbin0 -> 635 bytes
-rw-r--r--stage/assets/tileset-01.png.import34
-rw-r--r--stage/stage.gd15
-rw-r--r--stage/stage.tscn28
-rw-r--r--stage/stage_01.gd103
-rw-r--r--stage/stage_01.tscn29
-rw-r--r--stage/tile_map_layer.tscn44
-rw-r--r--stage/tileset-01.krabin0 -> 41461 bytes
8 files changed, 253 insertions, 0 deletions
diff --git a/stage/assets/tileset-01.png b/stage/assets/tileset-01.png
new file mode 100644
index 0000000..f2006f8
--- /dev/null
+++ b/stage/assets/tileset-01.png
Binary files differ
diff --git a/stage/assets/tileset-01.png.import b/stage/assets/tileset-01.png.import
new file mode 100644
index 0000000..8429b38
--- /dev/null
+++ b/stage/assets/tileset-01.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://4sbg8fnguw48"
+path="res://.godot/imported/tileset-01.png-85eb1066afb12100d0b0c110ba758473.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://stage/assets/tileset-01.png"
+dest_files=["res://.godot/imported/tileset-01.png-85eb1066afb12100d0b0c110ba758473.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
diff --git a/stage/stage.gd b/stage/stage.gd
new file mode 100644
index 0000000..8d72ee1
--- /dev/null
+++ b/stage/stage.gd
@@ -0,0 +1,15 @@
+class_name Stage
+extends Node2D
+
+
+func get_world_boundaries() -> Dictionary: #Dictionary[Vector2, float]
+ return {
+ Vector2.LEFT: 0.0,
+ Vector2.RIGHT: 0.0,
+ Vector2.UP: 0.0,
+ Vector2.DOWN: 0.0,
+ }
+
+
+func has_win_condition() -> bool:
+ return false
diff --git a/stage/stage.tscn b/stage/stage.tscn
new file mode 100644
index 0000000..9c8e256
--- /dev/null
+++ b/stage/stage.tscn
@@ -0,0 +1,28 @@
+[gd_scene load_steps=3 format=3 uid="uid://ivf0v2snsls5"]
+
+[ext_resource type="Script" path="res://stage/stage.gd" id="1_8ax4l"]
+[ext_resource type="PackedScene" uid="uid://ciyxysx3rwjhf" path="res://ui/hud.tscn" id="5_gnx55"]
+
+[node name="Stage" type="Node2D"]
+script = ExtResource("1_8ax4l")
+
+[node name="ColorRect" type="ColorRect" parent="."]
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_right = 256.0
+offset_bottom = 144.0
+grow_horizontal = 2
+grow_vertical = 2
+color = Color(0.419608, 0.65098, 0.290196, 1)
+
+[node name="Opponents" type="Node2D" parent="."]
+unique_name_in_owner = true
+
+[node name="HUD" parent="." instance=ExtResource("5_gnx55")]
+
+[node name="TickTimer" type="Timer" parent="."]
+wait_time = 2.0
+autostart = true
+
+[connection signal="timeout" from="TickTimer" to="." method="_on_tick_timer_timeout"]
diff --git a/stage/stage_01.gd b/stage/stage_01.gd
new file mode 100644
index 0000000..01cc558
--- /dev/null
+++ b/stage/stage_01.gd
@@ -0,0 +1,103 @@
+extends Stage
+
+
+var item_pool: Array = []
+var reserved_item_positions: Array = []
+
+
+func _ready() -> void:
+ $Player.camera.limit_left = get_world_boundaries()[Vector2.LEFT]
+ $Player.camera.limit_right = get_world_boundaries()[Vector2.RIGHT]
+ $Player.camera.limit_top = get_world_boundaries()[Vector2.UP]
+ $Player.camera.limit_bottom = get_world_boundaries()[Vector2.DOWN]
+
+ $TileMapLayer.modulate = Color(max(0.1, randf()), max(0.1, randf()), max(0.1, randf()))
+
+
+func get_world_boundaries() -> Dictionary:
+ return {
+ Vector2.LEFT: $TileMapLayer.get_used_rect().position.x * $TileMapLayer.tile_set.tile_size.x,
+ Vector2.RIGHT: $TileMapLayer.get_used_rect().end.x * $TileMapLayer.tile_set.tile_size.x,
+ Vector2.UP: $TileMapLayer.get_used_rect().position.y * $TileMapLayer.tile_set.tile_size.y - $HUD.size.y,
+ Vector2.DOWN: $TileMapLayer.get_used_rect().end.y * $TileMapLayer.tile_set.tile_size.y,
+ }
+
+
+func has_win_condition() -> bool:
+ return %Opponents.get_child_count() == 0
+
+
+func _on_tick_timer_timeout() -> void:
+ if randf() > 0.8 and item_pool.size() < 3:
+ var item_scene: PackedScene = [
+ preload("res://item/shoe.tscn"),
+ preload("res://item/crown.tscn"),
+ ].pick_random()
+
+ var item: Item = item_scene.instantiate()
+ var map: TileMapLayer = get_tree().get_first_node_in_group("tilemap")
+
+ var size_x := map.get_used_rect().position.x + map.get_used_rect().size.x
+ var size_y := map.get_used_rect().position.y + map.get_used_rect().size.y
+
+ var start_x: int = max(map.get_used_rect().position.x, range(size_x / 2).pick_random())
+ var start_y: int = max(map.get_used_rect().position.y, range(size_y / 2).pick_random())
+
+ var get_map_position = func() -> Vector2i:
+ for x in range(start_x, size_x):
+ for y in range(start_y, size_y):
+ var data = map.get_cell_tile_data(Vector2(x, y))
+ if not data:
+ return Vector2i(x, y)
+ return Vector2i.ZERO
+
+ var map_position = get_map_position.call()
+
+ #print(map_position)
+ if reserved_item_positions.has(map_position):
+ return
+
+ var local_position = map.map_to_local(map_position)
+
+ var _was_shifted := false
+ var collide_top = map.get_cell_tile_data(map.get_neighbor_cell(map_position, TileSet.CELL_NEIGHBOR_TOP_SIDE))
+ var collide_bottom = map.get_cell_tile_data(map.get_neighbor_cell(map_position, TileSet.CELL_NEIGHBOR_BOTTOM_SIDE))
+ var collide_right = map.get_cell_tile_data(map.get_neighbor_cell(map_position, TileSet.CELL_NEIGHBOR_RIGHT_SIDE))
+ if collide_top:
+ local_position += Vector2(0, map.tile_set.tile_size.y / 2)
+ _was_shifted = true
+ if collide_bottom:
+ local_position += Vector2(0, -map.tile_set.tile_size.y / 2)
+ _was_shifted = true
+ if collide_right:
+ local_position += Vector2(-map.tile_set.tile_size.x, 0)
+ _was_shifted = true
+ if not collide_top and not collide_right:
+ if map.get_cell_tile_data(map.get_neighbor_cell(map_position, TileSet.CELL_NEIGHBOR_TOP_RIGHT_CORNER)):
+ local_position += Vector2(-map.tile_set.tile_size.x, map.tile_set.tile_size.y / 2)
+ _was_shifted = true
+
+ #if not was_shifted:
+ local_position += Vector2(map.tile_set.tile_size.x / 2, 0)
+
+ item.position = local_position
+ add_child(item)
+
+ var get_reserved_positions = func() -> Array[Vector2i]:
+ var rp := [] as Array[Vector2i]
+ for x in range(0, 3):
+ for y in range(0, 3):
+ rp.append(Vector2i(x, y))
+ rp.append(Vector2i(-x, y))
+ rp.append(Vector2i(x, -y))
+ rp.append(Vector2i(-x, -y))
+ return rp
+
+ item.tree_exiting.connect(func():
+ item_pool.erase(item)
+ for v in get_reserved_positions.call():
+ reserved_item_positions.erase(map_position + v)
+ )
+ item_pool.append(item)
+ for v in get_reserved_positions.call():
+ reserved_item_positions.append(map_position + v)
diff --git a/stage/stage_01.tscn b/stage/stage_01.tscn
new file mode 100644
index 0000000..6b0d67c
--- /dev/null
+++ b/stage/stage_01.tscn
@@ -0,0 +1,29 @@
+[gd_scene load_steps=6 format=4 uid="uid://yb0no7vyekil"]
+
+[ext_resource type="Script" path="res://stage/stage_01.gd" id="1_2ycoy"]
+[ext_resource type="PackedScene" uid="uid://dfioemvleakyt" path="res://stage/tile_map_layer.tscn" id="1_4iotk"]
+[ext_resource type="PackedScene" uid="uid://ivf0v2snsls5" path="res://stage/stage.tscn" id="1_uanw1"]
+[ext_resource type="PackedScene" uid="uid://b4t3ipnq8vq2p" path="res://player/player.tscn" id="2_34lp1"]
+[ext_resource type="PackedScene" uid="uid://d1h8psjxqge0a" path="res://player/opponent.tscn" id="4_h35rr"]
+
+[node name="Stage01" instance=ExtResource("1_uanw1")]
+script = ExtResource("1_2ycoy")
+
+[node name="TileMapLayer" parent="." index="1" groups=["tilemap"] instance=ExtResource("1_4iotk")]
+tile_map_data = PackedByteArray("AAAIAAIAAAADAAAAAAAIAAMAAAAAAAAAAAAJAAIAAAAEAAAAAAAJAAMAAAACAAAAAAAKAAsAAAAAAAAAAAAKAAwAAAAAAAEAAAALAAsAAAACAAAAAAALAAwAAAACAAEAAAASAAgAAAAAAAAAAAASAAkAAAAAAAEAAAASAAoAAAAAAAEAAAASAAsAAAAAAAEAAAASAAwAAAAAAAEAAAATAAgAAAACAAAAAAATAAkAAAACAAEAAAATAAoAAAACAAEAAAATAAsAAAACAAEAAAATAAwAAAACAAEAAAAAAAIAAAADAAAAAAAAAAUAAAADAAEAAAAAAAgAAAADAAEAAAAAAAsAAAADAAEAAAAAAA4AAAADAAEAAAAAABEAAAADAAAAAAABAAIAAAAEAAAAAAABAAUAAAADAAEAAAABAAgAAAADAAEAAAABAAsAAAADAAEAAAABAA4AAAADAAEAAAABABEAAAAEAAAAAAACAAIAAAADAAAAAAACAAUAAAADAAEAAAACAAgAAAADAAEAAAACAAsAAAADAAEAAAACAA4AAAADAAEAAAACABEAAAADAAAAAAADAAIAAAAEAAAAAAADAAUAAAADAAEAAAADAAgAAAADAAEAAAADAAsAAAADAAEAAAADAA4AAAADAAEAAAADABEAAAAEAAAAAAAEAAIAAAADAAAAAAAEAAUAAAADAAEAAAAEAAgAAAADAAEAAAAEAAsAAAADAAEAAAAEABEAAAADAAAAAAAFAAIAAAAEAAAAAAAFAAUAAAADAAEAAAAFAAgAAAADAAEAAAAFAAsAAAADAAEAAAAFABEAAAAEAAAAAAAGAAIAAAADAAAAAAAGAAgAAA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AA4AAAADAAEAAAA=")
+
+[node name="Opponent" parent="Opponents" index="0" instance=ExtResource("4_h35rr")]
+position = Vector2(105, 128)
+current_type = null
+
+[node name="Opponent2" parent="Opponents" index="1" instance=ExtResource("4_h35rr")]
+position = Vector2(52, 80)
+current_type = 1
+
+[node name="Opponent3" parent="Opponents" index="2" instance=ExtResource("4_h35rr")]
+position = Vector2(120, 80)
+current_type = 2
+
+[node name="Player" parent="." index="3" instance=ExtResource("2_34lp1")]
+position = Vector2(16, 128)
+current_type = 2
diff --git a/stage/tile_map_layer.tscn b/stage/tile_map_layer.tscn
new file mode 100644
index 0000000..6fd9df1
--- /dev/null
+++ b/stage/tile_map_layer.tscn
@@ -0,0 +1,44 @@
+[gd_scene load_steps=4 format=3 uid="uid://dfioemvleakyt"]
+
+[ext_resource type="Texture2D" uid="uid://4sbg8fnguw48" path="res://stage/assets/tileset-01.png" id="1_kgkhx"]
+
+[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_kmxxx"]
+texture = ExtResource("1_kgkhx")
+separation = Vector2i(1, 1)
+texture_region_size = Vector2i(8, 8)
+0:0/0 = 0
+0:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+1:0/0 = 0
+1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+2:0/0 = 0
+2:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+0:1/0 = 0
+0:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+1:1/0 = 0
+1:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+2:1/0 = 0
+2:1/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+0:2/0 = 0
+0:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+1:2/0 = 0
+1:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+2:2/0 = 0
+2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+3:0/0 = 0
+3:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
+4:0/0 = 0
+4:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-4, -4, 4, -4, 4, 4, -4, 4)
+3:1/0 = 0
+3:1/0/physics_layer_1/polygon_0/points = PackedVector2Array(-4, -4, -4, 4, 4, 4, 4, -4)
+
+[sub_resource type="TileSet" id="TileSet_277cy"]
+tile_size = Vector2i(8, 8)
+physics_layer_0/collision_layer = 256
+physics_layer_0/collision_mask = 256
+physics_layer_1/collision_layer = 512
+physics_layer_1/collision_mask = 0
+sources/0 = SubResource("TileSetAtlasSource_kmxxx")
+
+[node name="TileMapLayer" type="TileMapLayer"]
+texture_filter = 1
+tile_set = SubResource("TileSet_277cy")
diff --git a/stage/tileset-01.kra b/stage/tileset-01.kra
new file mode 100644
index 0000000..68a3bf4
--- /dev/null
+++ b/stage/tileset-01.kra
Binary files differ