fix: new 16x16 blocksize < AI changes, caterpillar fix
This commit is contained in:
parent
0a3799eee0
commit
18e5deb0d1
@ -11,12 +11,12 @@ button_index = 1
|
||||
[sub_resource type="InputEventMouseButton" id=3]
|
||||
button_index = 1
|
||||
|
||||
[sub_resource type="InputEventJoypadButton" id=4]
|
||||
button_index = 13
|
||||
|
||||
[sub_resource type="InputEventKey" id=5]
|
||||
physical_scancode = 83
|
||||
|
||||
[sub_resource type="InputEventJoypadButton" id=4]
|
||||
button_index = 13
|
||||
|
||||
[sub_resource type="InputEventKey" id=6]
|
||||
physical_scancode = 69
|
||||
|
||||
@ -26,11 +26,11 @@ button_index = 2
|
||||
[sub_resource type="InputEventKey" id=8]
|
||||
scancode = 32
|
||||
|
||||
[sub_resource type="InputEventJoypadButton" id=9]
|
||||
|
||||
[sub_resource type="InputEventKey" id=10]
|
||||
physical_scancode = 16777232
|
||||
|
||||
[sub_resource type="InputEventJoypadButton" id=9]
|
||||
|
||||
[sub_resource type="InputEventKey" id=11]
|
||||
scancode = 65
|
||||
|
||||
@ -100,6 +100,12 @@ button_index = 12
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
progress_dict = {
|
||||
"Actual Level 3": {
|
||||
"currency": 0,
|
||||
"deaths": 5,
|
||||
"frees": 0,
|
||||
"kills": 0
|
||||
},
|
||||
"Level 1": {
|
||||
"currency": 0,
|
||||
"deaths": 0,
|
||||
@ -118,15 +124,21 @@ progress_dict = {
|
||||
"deaths": 0,
|
||||
"frees": 0,
|
||||
"kills": 0
|
||||
},
|
||||
"LevelTemplate": {
|
||||
"currency": 8,
|
||||
"deaths": 5,
|
||||
"frees": 2,
|
||||
"kills": 3
|
||||
}
|
||||
}
|
||||
wallet = 3
|
||||
wallet = 6
|
||||
input_map = {
|
||||
"boost_move": [ SubResource( 1 ), SubResource( 2 ) ],
|
||||
"click": [ SubResource( 3 ) ],
|
||||
"duck": [ SubResource( 4 ), SubResource( 5 ) ],
|
||||
"duck": [ SubResource( 5 ), SubResource( 4 ) ],
|
||||
"interact": [ SubResource( 6 ), SubResource( 7 ) ],
|
||||
"jump": [ SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ],
|
||||
"jump": [ SubResource( 8 ), SubResource( 10 ), SubResource( 9 ) ],
|
||||
"move_left": [ SubResource( 11 ), SubResource( 12 ) ],
|
||||
"move_right": [ SubResource( 13 ), SubResource( 14 ) ],
|
||||
"pause": [ SubResource( 15 ), SubResource( 16 ) ],
|
||||
|
||||
@ -4,9 +4,10 @@ onready var left_src = $SlopeRaycastLeft
|
||||
onready var right_src = $SlopeRaycastRight
|
||||
onready var left_wrc = $WallRaycastLeft
|
||||
onready var right_wrc = $WallRaycastRight
|
||||
export var block_size := 16
|
||||
|
||||
var time = 0
|
||||
var snap = Vector2.DOWN * 24
|
||||
var snap = Vector2.DOWN * block_size
|
||||
|
||||
func _ready() -> void:
|
||||
velocity.x = -120
|
||||
|
||||
@ -32,7 +32,6 @@ physics_process_parent = true
|
||||
|
||||
[node name="EnemyBody" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( -6.37697e-07, 4.36357 )
|
||||
scale = Vector2( 1, 1 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="SlopeRaycastLeft" type="RayCast2D" parent="."]
|
||||
@ -48,13 +47,13 @@ cast_to = Vector2( 0, 2 )
|
||||
collision_mask = 8
|
||||
|
||||
[node name="WallRaycastLeft" type="RayCast2D" parent="."]
|
||||
position = Vector2( -15, 12 )
|
||||
position = Vector2( -14.711, 11.5 )
|
||||
enabled = true
|
||||
cast_to = Vector2( -3, 0 )
|
||||
collision_mask = 8
|
||||
|
||||
[node name="WallRaycastRight" type="RayCast2D" parent="."]
|
||||
position = Vector2( 15, 12 )
|
||||
position = Vector2( 14.711, 11.5 )
|
||||
enabled = true
|
||||
cast_to = Vector2( 3, 0 )
|
||||
collision_mask = 8
|
||||
@ -77,7 +76,6 @@ collision_layer = 2
|
||||
collision_mask = 126
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
||||
position = Vector2( -5.54991e-05, 0 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
|
||||
|
||||
@ -92,7 +92,7 @@ func detect_player() -> void:
|
||||
return
|
||||
player = players[0]
|
||||
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
||||
vision_raycast.cast_to = (player.global_position - global_position - Vector2(0,9)).normalized() * 24 * vision_distance
|
||||
vision_raycast.cast_to = (player.global_position - global_position - Vector2(0,9)).normalized() * 16 * vision_distance
|
||||
var ray_angle_to_facing = vision_raycast.cast_to.angle_to(orientation.cast_to)
|
||||
vision_raycast.force_raycast_update()
|
||||
var collider = vision_raycast.get_collider()
|
||||
|
||||
@ -19,11 +19,13 @@ export var vision_distance := 6.0
|
||||
export var attack_jump_range := 6.0
|
||||
export var loose_target_seconds := 3.0
|
||||
# Jump distance in blocks
|
||||
export var default_jump_distance := 3.0
|
||||
export var default_jump_distance := 4.0
|
||||
export var default_jump_angle := 70.0
|
||||
export var jump_time_search := 0.7
|
||||
export var jump_time_hunt := 0.3
|
||||
export var jump_time_standard_deviation := 0.1
|
||||
# TODO Make constant for project
|
||||
export var block_size := 16
|
||||
|
||||
|
||||
|
||||
@ -67,7 +69,7 @@ func _ready():
|
||||
|
||||
func bind_to_anchor(anchor_node: Node2D, radius: float ) -> void:
|
||||
anchor = anchor_node
|
||||
movement_radius = radius * 24
|
||||
movement_radius = radius * block_size
|
||||
is_bound = true
|
||||
$LeashAnchor.visible = true
|
||||
|
||||
@ -78,7 +80,7 @@ func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
var incoming_vel_vector: Vector2 = body.velocity.normalized()
|
||||
# TODO This is not the right angle somehow
|
||||
# print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
|
||||
# if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(60):
|
||||
# if abs(incoming_vel_vector.angle_to(\Vector2.DOWN.rotated(rotation))) > deg2rad(60):
|
||||
# print("too shallow entry")
|
||||
# return
|
||||
signalManager.emit_signal("got_stomped")
|
||||
@ -163,7 +165,7 @@ func hunting() -> Vector2:
|
||||
detect_timer = 0.0
|
||||
#TODO Dependent on block size
|
||||
elif(is_on_floor() && food_target != null && !was_target_freed &&
|
||||
global_position.distance_to(food_target.global_position) <= attack_jump_range * 24):
|
||||
global_position.distance_to(food_target.global_position) <= attack_jump_range * block_size):
|
||||
|
||||
var collider = check_feeler(food_target.global_position - global_position)
|
||||
if(!was_restricted && collider != null && collider.is_in_group("frogfood")):
|
||||
@ -212,7 +214,7 @@ func detect_food() -> void:
|
||||
i += 1
|
||||
food_node = food_sources[min_dist_f_index]
|
||||
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
||||
vision_raycast.cast_to = (food_node.global_position - global_position).normalized() * 24 * vision_distance
|
||||
vision_raycast.cast_to = (food_node.global_position - global_position).normalized() * block_size * vision_distance
|
||||
var ray_angle_to_facing = vision_raycast.cast_to.angle_to(orientation.cast_to)
|
||||
vision_raycast.force_raycast_update()
|
||||
var collider = vision_raycast.get_collider()
|
||||
@ -231,7 +233,7 @@ func detect_player() -> void:
|
||||
return
|
||||
player = players[0]
|
||||
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
||||
vision_raycast.cast_to = (player.global_position - global_position - Vector2(0, 9)).normalized() * 24 * vision_distance
|
||||
vision_raycast.cast_to = (player.global_position - global_position - Vector2(0, 9)).normalized() * block_size * vision_distance
|
||||
var ray_angle_to_facing = vision_raycast.cast_to.angle_to(orientation.cast_to)
|
||||
vision_raycast.force_raycast_update()
|
||||
var collider = vision_raycast.get_collider()
|
||||
@ -341,18 +343,19 @@ func consider_jump_landing_space(v: Vector2) -> Vector2:
|
||||
# TODO Unpacked loop, make function or something?
|
||||
# Shortens the jump in steps to make it more safe
|
||||
if(!is_jump_path_safe(v, global_position) || collider != null):
|
||||
jump_distance = calculate_jump_distance(v) - 18
|
||||
jump_distance = calculate_jump_distance(v) - block_size/1.5
|
||||
v = change_jump_distance(jump_distance, v)
|
||||
jump_height = calculate_jump_height(v)
|
||||
v = correct_jump_direction(v)
|
||||
collider = check_feeler(Vector2(jump_distance * get_facing_direction(), - jump_height/2))
|
||||
if(!is_jump_path_safe(v, global_position) || collider != null):
|
||||
jump_distance = calculate_jump_distance(v) - 12
|
||||
jump_distance = calculate_jump_distance(v) - block_size/2.0
|
||||
v = change_jump_distance(jump_distance, v)
|
||||
jump_height = calculate_jump_height(v)
|
||||
v = correct_jump_direction(v)
|
||||
collider = check_feeler(Vector2(jump_distance * get_facing_direction(), - jump_height/2))
|
||||
if((!is_jump_path_safe(v, global_position) || collider != null) && can_reverse_facing_direction()):
|
||||
# Can be printed when frog would jump into a wall too
|
||||
print("no safe landing space found")
|
||||
return Vector2(0,0)
|
||||
return v
|
||||
@ -367,7 +370,7 @@ func consider_jumping_on_top() -> Vector2:
|
||||
var map_position = tilemap.world_to_map(local_position)
|
||||
var tile_position = Vector2(map_position.x + facing, map_position.y)
|
||||
# TODO Here the climb height of frog is limited to one constantly
|
||||
var cell_id = tilemap.get_cell(tile_position.x, tile_position.y - 1)
|
||||
var cell_id = tilemap.get_cell(tile_position.x, tile_position.y - 2)
|
||||
if (cell_id != -1 &&
|
||||
#TODO 9 is the navigation tile, but thats subject to change!
|
||||
cell_id != 8):
|
||||
@ -394,15 +397,15 @@ func consider_jumping_on_top() -> Vector2:
|
||||
# Tries to shorten the jump, so that it lands in a tiles center
|
||||
func jump_to_tile_center(v: Vector2) -> Vector2:
|
||||
var distance = stepify(calculate_jump_distance(v), 0.01)
|
||||
if !is_equal_approx(fmod(abs(global_position.x + distance * get_facing_direction()), 24), 12):
|
||||
if !is_equal_approx(fmod(abs(global_position.x + distance * get_facing_direction()), block_size), (block_size/2.0)):
|
||||
# print(distance)
|
||||
# print(global_position.x + distance)
|
||||
# print(fmod((global_position.x + distance), 24))
|
||||
# print(fmod((global_position.x + distance), block_size))
|
||||
var new_distance = distance
|
||||
if(get_facing_direction() < 0):
|
||||
new_distance = fmod((global_position.x + distance), 24) - 12 + distance
|
||||
new_distance = fmod((global_position.x + distance), block_size) - (block_size/2.0) + distance
|
||||
else:
|
||||
new_distance = distance + 12 - fmod((global_position.x + distance), 24)
|
||||
new_distance = distance + block_size/2.0 - fmod((global_position.x + distance), block_size)
|
||||
# print("centering distance")
|
||||
# print(new_distance)
|
||||
v = change_jump_distance(abs(new_distance), v)
|
||||
@ -422,19 +425,19 @@ func is_jump_path_safe(v: Vector2, pos: Vector2) -> bool:
|
||||
# TODO Ignores spikes more than 4 blocks below and 3 jumps away
|
||||
# Also when its too near to one
|
||||
if (abs(node_pos.x - pos.x) > abs(jump_distance) * 3
|
||||
||abs(node_pos.y - pos.y) > 24 * 4
|
||||
||abs(node_pos.y - pos.y) > block_size * 4
|
||||
|| abs(node_pos.x - pos.x) < 1):
|
||||
continue
|
||||
var node_y = node_pos.y - 12
|
||||
var node_y = node_pos.y - block_size/2.0
|
||||
var initial_throw_height = node_y - (global_position.y + 9)
|
||||
var term1 = (pow(v0, 2) * sin(2 * angle)) / (2 * _gravity)
|
||||
var term2 = ((v0 * cos(angle))/_gravity) * sqrt(pow(v0, 2) * pow(sin(angle), 2) + 2 * _gravity * initial_throw_height)
|
||||
var distance = abs(term1) + abs(term2)
|
||||
# print("distance to next spike")
|
||||
# print(pos.x + sign(v.x) * distance - node_pos.x)
|
||||
var safe_distance = 12
|
||||
var safe_distance = block_size/2.0
|
||||
if (sign(initial_throw_height) < 0):
|
||||
safe_distance = 24
|
||||
safe_distance = block_size
|
||||
if(abs(pos.x + sign(v.x) * distance - node_pos.x) < safe_distance):
|
||||
return false
|
||||
return true
|
||||
@ -461,7 +464,7 @@ func change_jump_distance(target_distance: float, v: Vector2) -> Vector2:
|
||||
|
||||
|
||||
# Takes an angle and a distance to calculate a jump launching at that angle and covering the distance
|
||||
func velocity_for_jump_distance(distance: float = default_jump_distance*24, angle: float = deg2rad(default_jump_angle)) -> Vector2:
|
||||
func velocity_for_jump_distance(distance: float = default_jump_distance*block_size, angle: float = deg2rad(default_jump_angle)) -> Vector2:
|
||||
var abs_velocity = sqrt((distance * _gravity)/sin(2*angle))
|
||||
return Vector2(abs_velocity,0).rotated(-1*angle)
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ onready var min_rotation_speed = deg2rad(0.3)
|
||||
|
||||
# Detection limit in blocks
|
||||
export var vision_distance = 7
|
||||
export var block_size := 16
|
||||
|
||||
var prey_ref = weakref(null)
|
||||
# Ray that goes from the turret to the target
|
||||
@ -43,7 +44,7 @@ func searching():
|
||||
for sightline in sightcone.get_children():
|
||||
if !sightline.is_colliding():
|
||||
return
|
||||
if sightline.get_collision_point().distance_to(position) > vision_distance * 24:
|
||||
if sightline.get_collision_point().distance_to(position) > vision_distance * block_size:
|
||||
#print(sightline.get_collision_point().distance_to(position))
|
||||
return
|
||||
# The collider returns not the area or body it hit, but the parent of them
|
||||
|
||||
@ -16,6 +16,7 @@ var anchor_distance := 1.0
|
||||
var movement_radius := 1.0
|
||||
|
||||
export var rope_tightness := 0.5
|
||||
export var block_size := 16
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
# TODO Resize or reinitialize?
|
||||
@ -27,7 +28,7 @@ func _process(_delta: float) -> void:
|
||||
|
||||
func spawn_rope(start_pos: Vector2, end_pos: Vector2, m_radius: float = 100, new_anchors: bool = true):
|
||||
# The rope should be the defined length even if the anchors are close together/far apart
|
||||
movement_radius = m_radius * 24
|
||||
movement_radius = m_radius * block_size
|
||||
var mock_end_pos = start_pos + (end_pos - start_pos).normalized() * movement_radius * rope_tightness
|
||||
if(new_anchors):
|
||||
rope_start = RopeAnchor.instance()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_resource type="TileSet" load_steps=31 format=2]
|
||||
[gd_resource type="TileSet" load_steps=32 format=2]
|
||||
|
||||
[ext_resource path="res://assets/environment/blocks/basic_tileset_blobb-jakob-remix.png" type="Texture" id=1]
|
||||
|
||||
@ -89,6 +89,11 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
[sub_resource type="ConvexPolygonShape2D" id=34]
|
||||
points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
|
||||
[sub_resource type="NavigationPolygon" id=35]
|
||||
vertices = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
polygons = [ PoolIntArray( 0, 1, 2, 3 ) ]
|
||||
outlines = [ PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) ]
|
||||
|
||||
[resource]
|
||||
0/name = "basic_tileset_blobb-jakob-remix.png 0"
|
||||
0/texture = ExtResource( 1 )
|
||||
@ -310,3 +315,18 @@ points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
} ]
|
||||
1/z_index = 0
|
||||
2/name = "basic_tileset_blobb-jakob-remix.png 2"
|
||||
2/texture = ExtResource( 1 )
|
||||
2/tex_offset = Vector2( 0, 0 )
|
||||
2/modulate = Color( 1, 1, 1, 1 )
|
||||
2/region = Rect2( 0, 0, 16, 16 )
|
||||
2/tile_mode = 0
|
||||
2/occluder_offset = Vector2( 0, 0 )
|
||||
2/navigation_offset = Vector2( 0, 0 )
|
||||
2/navigation = SubResource( 35 )
|
||||
2/shape_offset = Vector2( 0, 0 )
|
||||
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
|
||||
2/shape_one_way = false
|
||||
2/shape_one_way_margin = 0.0
|
||||
2/shapes = [ ]
|
||||
2/z_index = 0
|
||||
|
||||
@ -113,10 +113,10 @@ visible = true
|
||||
visible = true
|
||||
|
||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||
frame = 3
|
||||
frame = 0
|
||||
|
||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||
frame = 6
|
||||
frame = 3
|
||||
|
||||
[node name="Blobby" parent="." instance=ExtResource( 9 )]
|
||||
unique_name_in_owner = true
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,11 +1,10 @@
|
||||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1]
|
||||
[ext_resource path="res://src/Utilities/SignalManager.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://src/Utilities/LevelState.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://src/Actors/BlobbyCam.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://src/Levels/x02 Level.tscn" type="PackedScene" id=6]
|
||||
[ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=8]
|
||||
[ext_resource path="res://src/Levels/Templates/LevelTemplate.gd" type="Script" id=9]
|
||||
@ -34,39 +33,20 @@ wait_time = 20.0
|
||||
unique_name_in_owner = true
|
||||
drag_margin_bottom = 0.3
|
||||
|
||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||
frame = 2
|
||||
|
||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||
frame = 12
|
||||
frame = 1
|
||||
|
||||
[node name="Blobby" parent="." instance=ExtResource( 7 )]
|
||||
unique_name_in_owner = true
|
||||
position = Vector2( -70, -1.90735e-06 )
|
||||
scale = Vector2( 0.878906, 0.936025 )
|
||||
|
||||
[node name="CollisionPolygon2D" parent="Blobby/BlobbySkin" index="0"]
|
||||
position = Vector2( 0.0286326, -10.0053 )
|
||||
|
||||
[node name="BlobbySprite" parent="Blobby" index="3"]
|
||||
scale = Vector2( -1, 1 )
|
||||
frame = 5
|
||||
|
||||
[node name="AnimationTree" parent="Blobby/BlobbySprite" index="0"]
|
||||
parameters/playback = SubResource( 4 )
|
||||
|
||||
[node name="BlobbyBody" parent="Blobby" index="8"]
|
||||
position = Vector2( 0.0392303, -10.002 )
|
||||
|
||||
[node name="Left_Wallcast1" parent="Blobby/WallRaycasts/LeftWallRaycast" index="0"]
|
||||
position = Vector2( -11.9763, -5 )
|
||||
|
||||
[node name="Left_Wallcast2" parent="Blobby/WallRaycasts/LeftWallRaycast" index="1"]
|
||||
position = Vector2( -11.9763, 5 )
|
||||
|
||||
[node name="Right_Wallcast1" parent="Blobby/WallRaycasts/RightWallRaycast" index="0"]
|
||||
position = Vector2( 12.0551, -5 )
|
||||
|
||||
[node name="Right_Wallcast2" parent="Blobby/WallRaycasts/RightWallRaycast" index="1"]
|
||||
position = Vector2( 12.0551, 5 )
|
||||
|
||||
[node name="TileMap" type="TileMap" parent="."]
|
||||
unique_name_in_owner = true
|
||||
tile_set = ExtResource( 1 )
|
||||
@ -81,7 +61,7 @@ tile_data = PoolIntArray( -458761, 1610612738, 0, -458760, 1610612738, 0, -45875
|
||||
|
||||
[node name="Portal" parent="." instance=ExtResource( 5 )]
|
||||
position = Vector2( 288, 120 )
|
||||
next_scene = ExtResource( 6 )
|
||||
next_scene = "res://src/Levels/Actual Level 1.tscn"
|
||||
|
||||
[connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user