Skip to content

Commit

Permalink
fix: map and boss
Browse files Browse the repository at this point in the history
boss animation was too long. The initial path always generates from left to right
  • Loading branch information
Guido-Bailon committed Jun 16, 2024
1 parent 0480ce1 commit 1b39e6e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Prefabs/Ally.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ tracks/2/keys = {
"values": [0]
}

[sub_resource type="Animation" id="Animation_n5mpm"]
resource_name = "attack_side"
[sub_resource type="Animation" id="Animation_xw6y3"]
resource_name = "attack_down"
length = 1.04
loop_mode = 1
tracks/0/type = "value"
Expand All @@ -124,7 +124,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"attack_side"]
"values": [&"attack_down"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand Down Expand Up @@ -156,8 +156,8 @@ tracks/2/keys = {
}]
}

[sub_resource type="Animation" id="Animation_xw6y3"]
resource_name = "attack_down"
[sub_resource type="Animation" id="Animation_n5mpm"]
resource_name = "attack_side"
length = 1.04
loop_mode = 1
tracks/0/type = "value"
Expand All @@ -170,7 +170,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [&"attack_down"]
"values": [&"attack_side"]
}
tracks/1/type = "value"
tracks/1/imported = false
Expand Down
2 changes: 1 addition & 1 deletion Prefabs/Enemies/Boss.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ size = Vector2(412, 416)

[sub_resource type="Animation" id="Animation_hpsuv"]
resource_name = "Attack"
length = 1.2
length = 0.62
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
Expand Down
4 changes: 2 additions & 2 deletions Scenes/mapa.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
[ext_resource type="PackedScene" uid="uid://bfuuqao2omga7" path="res://Scenes/canvas_layer.tscn" id="8_0iwi3"]
[ext_resource type="PackedScene" uid="uid://bsevkqk7cl15l" path="res://Scenes/slot_detector.tscn" id="9_hcxdh"]
[ext_resource type="PackedScene" uid="uid://crel0atg4ipct" path="res://Prefabs/target.tscn" id="10_ve2q4"]
[ext_resource type="PackedScene" uid="uid://c6oii6pq5ubrd" path="res://Scenes/spell_detector.tscn" id="12_drqm8"]
[ext_resource type="PackedScene" path="res://Scenes/spell_detector.tscn" id="12_drqm8"]
[ext_resource type="Script" path="res://Scripts/Map/fog.gd" id="13_uk752"]
[ext_resource type="PackedScene" path="res://Scenes/chest_detector.tscn" id="14_28lq2"]
[ext_resource type="PackedScene" uid="uid://dre2u2d8gmtvv" path="res://Scenes/chest_detector.tscn" id="14_28lq2"]

[node name="Mapa" type="Node"]
script = ExtResource("1_b8xhp")
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Map/path_generator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func generate_path(initial_pos:Vector2i, target_pos:Vector2i, curvature: float):
if tries > 5000:
break

path = path.slice(1, -1)
#path = path.slice(1, -1)

return path

Expand Down
9 changes: 7 additions & 2 deletions Scripts/Map/path_renderer.gd
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var textures = {

# Configuration
var padding = 3
var initial_path_length = 5

# Called when the node enters the scene tree for the first time.
func _ready():
Expand Down Expand Up @@ -104,15 +105,19 @@ func setup_level(initial_pos: Vector2i, target_pos: Vector2i):

ObstacleGenerator.init(width, height,5, height / 2 - 1)

var initial_path:Array[Vector2i]
for i in range(1,initial_path_length):
initial_path.append(initial_pos+Vector2i(i,0))
ObstacleGenerator.add_obstacles(Utils.add_padding(initial_path))
var path_generator = PathGenerator.new(width, height, get_tileset().tile_size, get_used_rect().end - get_used_rect().position, 150)
var path = path_generator.generate_path(initial_pos, target_pos-Vector2i(boss_arena_dimension.x,0), 2.0)
var path = path_generator.generate_path(initial_pos+Vector2i(initial_path_length,0), target_pos-Vector2i(boss_arena_dimension.x,0), 2.0)
var arena = generate_boss_path(path[-1])
ObstacleGenerator.add_obstacles(arena)
ObstacleGenerator.add_obstacles(Utils.add_padding(path))
# Add castles to initial obstacles
ObstacleGenerator.add_obstacles([initial_pos, target_pos])

for cell in path+arena:
for cell in initial_path+path+arena:
map[cell] = TileType.PATH

var slots = SlotGenerator.new(width, height).generate_slots(100, path, 10, 5)
Expand Down

0 comments on commit 1b39e6e

Please sign in to comment.