diff --git a/maps/test_room.tscn b/maps/test_room.tscn index 8ba4493..fd31a5f 100644 --- a/maps/test_room.tscn +++ b/maps/test_room.tscn @@ -192,7 +192,7 @@ tile_set = ExtResource( 3 ) cell_size = Vector2( 8, 8 ) collision_layer = 9 format = 1 -tile_data = PoolIntArray( 196630, 1, 0, 262166, 1, 0, 327702, 1, 0, 393238, 1, 0, 458774, 1, 0, 524310, 1, 0, 589846, 1, 0, 655382, 1, 0, 655388, 0, 196609, 983062, 0, 65537, 983063, 0, 65537, 983064, 0, 65537, 983065, 0, 65537, 983066, 0, 65537, 983067, 0, 65537, 983068, 0, 65537, 983069, 0, 65537, 1048579, 0, 65537, 1048580, 0, 65537, 1048581, 0, 65537, 1048582, 0, 65537, 1048583, 0, 65537, 1441792, 0, 0, 1441793, 0, 0, 1441794, 0, 0, 1441795, 0, 0, 1441796, 0, 0, 1441797, 0, 0, 1441798, 0, 0, 1441799, 0, 0, 1441800, 0, 0, 1441801, 0, 0, 1441802, 0, 0, 1441803, 0, 0, 1441804, 0, 0, 1441805, 0, 0, 1441806, 0, 0, 1441807, 0, 0, 1441808, 0, 0, 1441809, 0, 0, 1441810, 0, 0, 1441811, 0, 0, 1441812, 0, 0, 1441813, 0, 0, 1441814, 0, 0, 1441815, 0, 0, 1441816, 0, 0, 1441817, 0, 0, 1441818, 0, 0, 1441819, 0, 0, 1441820, 0, 0, 1441821, 0, 0, 1441822, 0, 0, 1441823, 0, 0, 1507328, 0, 1, 1507329, 0, 1, 1507330, 0, 1, 1507331, 0, 1, 1507332, 0, 1, 1507333, 0, 1, 1507334, 0, 1, 1507335, 0, 1, 1507336, 0, 1, 1507337, 0, 1, 1507338, 0, 1, 1507339, 0, 1, 1507340, 0, 1, 1507341, 0, 1, 1507342, 0, 1, 1507343, 0, 1, 1507344, 0, 1, 1507345, 0, 1, 1507346, 0, 1, 1507347, 0, 1, 1507348, 0, 1, 1507349, 0, 1, 1507350, 0, 1, 1507351, 0, 1, 1507352, 0, 1, 1507353, 0, 1, 1507354, 0, 1, 1507355, 0, 1, 1507356, 0, 1, 1507357, 0, 1, 1507358, 0, 1, 1507359, 0, 1 ) +tile_data = PoolIntArray( 196630, 1, 0, 262166, 1, 0, 327702, 1, 0, 393238, 1, 0, 458774, 1, 0, 524310, 1, 0, 589846, 1, 0, 655382, 1, 0, 655388, 0, 196609, 983062, 0, 0, 983063, 0, 0, 983064, 0, 0, 983065, 0, 0, 983066, 0, 0, 983067, 0, 0, 983068, 0, 0, 983069, 0, 0, 1048579, 0, 65537, 1048580, 0, 65537, 1048581, 0, 65537, 1048582, 0, 65537, 1048583, 0, 65537, 1441792, 0, 0, 1441793, 0, 0, 1441794, 0, 0, 1441795, 0, 0, 1441796, 0, 0, 1441797, 0, 0, 1441798, 0, 0, 1441799, 0, 0, 1441800, 0, 0, 1441801, 0, 0, 1441802, 0, 0, 1441803, 0, 0, 1441804, 0, 0, 1441805, 0, 0, 1441806, 0, 0, 1441807, 0, 0, 1441808, 0, 0, 1441809, 0, 0, 1441810, 0, 0, 1441811, 0, 0, 1441812, 0, 0, 1441813, 0, 0, 1441814, 0, 0, 1441815, 0, 0, 1441816, 0, 0, 1441817, 0, 0, 1441818, 0, 0, 1441819, 0, 0, 1441820, 0, 0, 1441821, 0, 0, 1441822, 0, 0, 1441823, 0, 0, 1507328, 0, 1, 1507329, 0, 1, 1507330, 0, 1, 1507331, 0, 1, 1507332, 0, 1, 1507333, 0, 1, 1507334, 0, 1, 1507335, 0, 1, 1507336, 0, 1, 1507337, 0, 1, 1507338, 0, 1, 1507339, 0, 1, 1507340, 0, 1, 1507341, 0, 1, 1507342, 0, 1, 1507343, 0, 1, 1507344, 0, 1, 1507345, 0, 1, 1507346, 0, 1, 1507347, 0, 1, 1507348, 0, 1, 1507349, 0, 1, 1507350, 0, 1, 1507351, 0, 1, 1507352, 0, 1, 1507353, 0, 1, 1507354, 0, 1, 1507355, 0, 1, 1507356, 0, 1, 1507357, 0, 1, 1507358, 0, 1, 1507359, 0, 1 ) [node name="Slime" parent="." instance=ExtResource( 10 )] position = Vector2( 264, 168 ) @@ -254,6 +254,7 @@ position = Vector2( 48, 120 ) [node name="AnimatedSprite" parent="RollingFiend" index="0"] visible = false +frame = 1 [node name="SawTest2" type="AnimatedSprite" parent="RollingFiend"] material = SubResource( 4 ) @@ -310,6 +311,10 @@ move_direction = 1 position = Vector2( 200, 168 ) left_boundary = 3.0 right_boundary = 4.0 +speed = 100.0 jump_distance = 4.0 +jump_speed = 100.0 +bottom_jumps = [ 3.0 ] +top_jumps = [ 0.0 ] [editable path="RollingFiend"] diff --git a/objects/enemy/super_slime.gd b/objects/enemy/super_slime.gd index 226f04a..5d9440a 100644 --- a/objects/enemy/super_slime.gd +++ b/objects/enemy/super_slime.gd @@ -9,6 +9,9 @@ export var direction: float = 1.0 export var speed: float = 50.0 export var jump_distance: float = 0.0 export var jump_speed: float = 50.0 +export (Array, float) var bottom_jumps: Array = [] setget _set_bottom_jumps +export (Array, float) var top_jumps: Array = [] setget _set_top_jumps +export var detect_player: bool = false var _jumping: bool = false var _jump_direction: float = -1.0 @@ -24,6 +27,10 @@ func _ready() -> void: left_boundary *= 8.0 right_boundary *= 8.0 jump_distance *= 8.0 + for i in bottom_jumps.size(): + bottom_jumps[i] *= 8.0 + for i in top_jumps.size(): + top_jumps[i] *= 8.0 detect_player_cast.cast_to = Vector2(0.0, -jump_distance) speed *= Game.enemy_speed_factor @@ -31,8 +38,14 @@ func _ready() -> void: func _physics_process(delta: float) -> void: if Engine.editor_hint: return - # check for player and jump - if detect_player_cast.is_colliding(): + # check for jump point + var jump_points = bottom_jumps if sign(_jump_direction) == -1.0 else top_jumps + for x in jump_points: + if abs(hitbox.position.x - x) <= 2.0: + _jumping = true + break + # check for player + if detect_player and detect_player_cast.is_colliding(): _jumping = true # move if not jumping if _jumping: @@ -55,8 +68,8 @@ func _physics_process(delta: float) -> void: sprite.flip_h = true elif hitbox.position.x <= -left_boundary: hitbox.position.x = -left_boundary - direction = 1.0 sprite.flip_h = false + direction = 1.0 func _process(delta: float) -> void: @@ -78,12 +91,36 @@ func _draw() -> void: Vector2(right_boundary * 8.0 + 8.0, -jump_distance * 8.0 - 4.0), Color(0.4, 0.2, 0.6, 0.75), 1.01, false ) - # jump line - draw_line( - Vector2(4.0, 4.0), - Vector2(4.0, -jump_distance * 8.0 - 4.0), - Color(0.4, 0.2, 0.6, 0.75), 1.01, false - ) + # jump lines + for x in bottom_jumps: + draw_line( + Vector2(x * 8.0, 4.0), + Vector2(x * 8.0, -jump_distance * 4.0), + Color(1.0, 0.0, 0.0, 0.75), 1.01, false + ) + draw_circle(Vector2(x * 8.0, 4.0), 2.0, Color.red) + for x in top_jumps: + draw_line( + Vector2(x * 8.0, -jump_distance * 8.0 - 4.0), + Vector2(x * 8.0, -jump_distance * 4.0), + Color(1.0, 0.0, 0.0, 0.75), 1.01, false + ) + draw_circle(Vector2(x * 8.0, -jump_distance * 8.0 - 4.0), 2.0, Color.red) +# draw_line( +# Vector2(4.0, 4.0), +# Vector2(4.0, -jump_distance * 8.0 - 4.0), +# Color(0.4, 0.2, 0.6, 0.75), 1.01, false +# ) + + +func _set_bottom_jumps(value: Array) -> void: + bottom_jumps = value + update() + + +func _set_top_jumps(value: Array) -> void: + top_jumps = value + update() func die() -> void: diff --git a/objects/enemy/super_slime.tscn b/objects/enemy/super_slime.tscn index a10c470..121f8ed 100644 --- a/objects/enemy/super_slime.tscn +++ b/objects/enemy/super_slime.tscn @@ -40,7 +40,6 @@ blood = false material = SubResource( 4 ) position = Vector2( 4, 3 ) frames = SubResource( 5 ) -frame = 1 playing = true [node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]