Skip to content

Commit

Permalink
add stone obstacle
Browse files Browse the repository at this point in the history
  • Loading branch information
myin142 committed Nov 14, 2023
1 parent 059a7c5 commit 28f1da0
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 8 deletions.
Binary file added godot/assets/Stones_Round.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions godot/assets/Stones_Round.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dbvhpmqxnmcww"
path="res://.godot/imported/Stones_Round.png-1e75a2ec186a05881bf8b0ea984b8df9.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/Stones_Round.png"
dest_files=["res://.godot/imported/Stones_Round.png-1e75a2ec186a05881bf8b0ea984b8df9.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
Binary file modified godot/assets/Tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions godot/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ start={
[layer_names]

2d_physics/layer_1="static"
2d_navigation/layer_1="Main"
2d_physics/layer_2="player"
2d_physics/layer_3="enemy"
2d_physics/layer_4="player_hurtbox"
Expand Down
7 changes: 6 additions & 1 deletion godot/src/Enemy.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ signal died()
var knockback: Vector2
var attacking := false
var last_hit_dir := Vector2.RIGHT
var avoidance_vel := Vector2.ZERO

func _update_mirror():
if GameManager.mirror:
Expand Down Expand Up @@ -57,6 +58,7 @@ func _ready():
)
navigation_agent.path_desired_distance = 4.0
navigation_agent.target_desired_distance = 4.0
navigation_agent.velocity_computed.connect(on_nav_velocity_computed)

func _player_pos():
return get_tree().get_first_node_in_group("Player").global_position
Expand All @@ -77,17 +79,20 @@ func _physics_process(delta):
var next_path_position: Vector2 = navigation_agent.get_next_path_position()

var new_velocity: Vector2 = next_path_position - current_agent_position
new_velocity += avoidance_vel
new_velocity = new_velocity.normalized()

var s = mirror_speed if GameManager.mirror else speed
new_velocity = new_velocity * s

new_velocity += soft_collision.get_push_vector() * delta

velocity = new_velocity

animation_player.play(move_anim)
move_and_slide()

func on_nav_velocity_computed(vel):
avoidance_vel = vel

func _on_hitbox_hit(dmg):
GameManager.hit()
Expand Down
2 changes: 1 addition & 1 deletion godot/src/character/bomb_bullet.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ radius = 8.0

[node name="BombBullet" type="Area2D" node_paths=PackedStringArray("speed", "collision_shape", "hurt_collision", "raycast", "death_spawner", "hit_box", "health")]
collision_layer = 0
collision_mask = 32
collision_mask = 33
script = ExtResource("1_w8slh")
speed = NodePath("SpeedValue")
max_reflections = 2
Expand Down
2 changes: 1 addition & 1 deletion godot/src/character/enemy.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ _data = {

[node name="Enemy" type="CharacterBody2D"]
collision_layer = 4
collision_mask = 0
script = ExtResource("1_xsn24")
mirror_speed = 40
speed = 30
Expand Down Expand Up @@ -134,6 +133,7 @@ script = ExtResource("11_ljeiv")
mirror_texture = ExtResource("3_g4yvg")

[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
avoidance_enabled = true

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 5)
Expand Down
2 changes: 1 addition & 1 deletion godot/src/character/enemy_bullet.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ radius = 5.0

[node name="EnemyBullet" type="Area2D" node_paths=PackedStringArray("speed", "collision_shape", "hurt_collision", "raycast", "death_spawner", "hit_box", "health")]
collision_layer = 0
collision_mask = 32
collision_mask = 33
script = ExtResource("1_m5cyv")
speed = NodePath("SpeedValue")
max_reflections = 2
Expand Down
7 changes: 5 additions & 2 deletions godot/src/character/projectile.gd
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func _ready():

if reflected > max_reflections and max_reflections >= 0:
_remove()
else:
elif area is Mirror:
if raycast and raycast.is_colliding():
set_physics_process(false)
hide()
Expand All @@ -46,7 +46,10 @@ func _ready():
global_rotation = Vector2.RIGHT.angle_to(dir)
reflected += 1
reflect.emit(dir)
)
else:
_remove()
)
body_entered.connect(func(_x): _remove())

#func _temp_disable_collision():
# _disable_hit()
Expand Down
2 changes: 1 addition & 1 deletion godot/src/character/trident.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ size = Vector2(8, 12)

[node name="Trident" type="Area2D" node_paths=PackedStringArray("speed", "collision_shape", "raycast", "hit_box")]
collision_layer = 0
collision_mask = 32
collision_mask = 33
script = ExtResource("1_uombx")
speed = NodePath("SpeedValue")
disable_initial_hit = false
Expand Down
16 changes: 15 additions & 1 deletion godot/src/props/room.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://ct26q2u8q7f3m"]
[gd_scene load_steps=14 format=3 uid="uid://ct26q2u8q7f3m"]

[ext_resource type="Shader" path="res://src/tile_mirror.gdshader" id="1_ergtu"]
[ext_resource type="Texture2D" uid="uid://c51ce62nmbjb5" path="res://assets/Tiles.png" id="3_j70vk"]
Expand All @@ -18,6 +18,8 @@ vertices = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
outlines = Array[PackedVector2Array]([PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)])

[sub_resource type="NavigationPolygon" id="NavigationPolygon_v806k"]

[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_im7wa"]
texture = ExtResource("3_j70vk")
0:0/0 = 0
Expand Down Expand Up @@ -98,6 +100,11 @@ texture = ExtResource("3_j70vk")
2:2/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
2:2/0/terrains_peering_bit/left_side = 0
2:2/0/terrains_peering_bit/top_side = 0
3:0/0 = 0
3:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
3:0/0/physics_layer_0/angular_velocity = 0.0
3:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-8, -8, 8, -8, 8, 8, -8, 8)
3:0/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_v806k")

[sub_resource type="TileSet" id="TileSet_k6e46"]
physics_layer_0/collision_layer = 1
Expand Down Expand Up @@ -139,6 +146,13 @@ layer_1/y_sort_enabled = true
layer_1/y_sort_origin = 0
layer_1/z_index = -1
layer_1/tile_data = PackedInt32Array(393225, 65539, 2, 327689, 65539, 1, 262153, 65539, 1, 196617, 65539, 1, 131081, 65539, 1, 65545, 65539, 1, 9, 65539, 1, -65527, 65539, 1, -131063, 65539, 1, -196599, 65539, 1, -262135, 65539, 1, -327671, 65539, 1, -393207, 65539, 1, -458743, 65539, 0, 393224, 65539, 2, 327688, 65539, 1, 262152, 65539, 1, 196616, 65539, 1, 131080, 65539, 1, 65544, 65539, 1, 8, 65539, 1, -65528, 65539, 1, -131064, 65539, 1, -196600, 65539, 1, -262136, 65539, 1, -327672, 65539, 1, -393208, 65539, 1, -458744, 65539, 0, 393223, 65539, 2, 327687, 65539, 1, 262151, 65539, 1, 196615, 65539, 1, 131079, 65539, 1, 65543, 65539, 1, 7, 65539, 1, -65529, 65539, 1, -131065, 65539, 1, -196601, 65539, 1, -262137, 65539, 1, -327673, 65539, 1, -393209, 65539, 1, -458745, 65539, 0, 393222, 65539, 2, 327686, 65539, 1, 262150, 65539, 1, 196614, 65539, 1, 131078, 65539, 1, 65542, 65539, 1, 6, 65539, 1, -65530, 65539, 1, -131066, 65539, 1, -196602, 65539, 1, -262138, 65539, 1, -327674, 65539, 1, -393210, 65539, 1, -458746, 65539, 0, 393221, 65539, 2, 327685, 65539, 1, 262149, 65539, 1, 196613, 65539, 1, 131077, 65539, 1, 65541, 65539, 1, 5, 65539, 1, -65531, 65539, 1, -131067, 65539, 1, -196603, 65539, 1, -262139, 65539, 1, -327675, 65539, 1, -393211, 65539, 1, -458747, 65539, 0, 393220, 65539, 2, 327684, 65539, 1, 262148, 65539, 1, 196612, 65539, 1, 131076, 65539, 1, 65540, 65539, 1, 4, 65539, 1, -65532, 65539, 1, -131068, 65539, 1, -196604, 65539, 1, -262140, 65539, 1, -327676, 65539, 1, -393212, 65539, 1, -458748, 65539, 0, 393219, 65539, 2, 327683, 65539, 1, 262147, 65539, 1, 196611, 65539, 1, 131075, 65539, 1, 65539, 65539, 1, 3, 65539, 1, -65533, 65539, 1, -131069, 65539, 1, -196605, 65539, 1, -262141, 65539, 1, -327677, 65539, 1, -393213, 65539, 1, -458749, 65539, 0, 393218, 65539, 2, 327682, 65539, 1, 262146, 65539, 1, 196610, 65539, 1, 131074, 65539, 1, 65538, 65539, 1, 2, 65539, 1, -65534, 65539, 1, -131070, 65539, 1, -196606, 65539, 1, -262142, 65539, 1, -327678, 65539, 1, -393214, 65539, 1, -458750, 65539, 0, 393217, 65539, 2, 327681, 65539, 1, 262145, 65539, 1, 196609, 65539, 1, 131073, 65539, 1, 65537, 65539, 1, 1, 65539, 1, -65535, 65539, 1, -131071, 65539, 1, -196607, 65539, 1, -262143, 65539, 1, -327679, 65539, 1, -393215, 65539, 1, -458751, 65539, 0, 393216, 65539, 2, 327680, 65539, 1, 262144, 65539, 1, 196608, 65539, 1, 131072, 65539, 1, 65536, 65539, 1, 0, 65539, 1, -65536, 65539, 1, -131072, 65539, 1, -196608, 65539, 1, -262144, 65539, 1, -327680, 65539, 1, -393216, 65539, 1, 458751, 65539, 2, 393215, 65539, 1, 327679, 65539, 1, 262143, 65539, 1, 196607, 65539, 1, 131071, 65539, 1, 65535, 65539, 1, -1, 65539, 1, -65537, 65539, 1, -131073, 65539, 1, -196609, 65539, 1, -262145, 65539, 1, -327681, 65539, 1, 458750, 65539, 2, 393214, 65539, 1, 327678, 65539, 1, 262142, 65539, 1, 196606, 65539, 1, 131070, 65539, 1, 65534, 65539, 1, -2, 65539, 1, -65538, 65539, 1, -131074, 65539, 1, -196610, 65539, 1, -262146, 65539, 1, -327682, 65539, 1, -393218, 65539, 0, 458749, 65539, 2, 393213, 65539, 1, 327677, 65539, 1, 262141, 65539, 1, 196605, 65539, 1, 131069, 65539, 1, 65533, 65539, 1, -3, 65539, 1, -65539, 65539, 1, -131075, 65539, 1, -196611, 65539, 1, -262147, 65539, 1, -327683, 65539, 1, -393219, 65539, 0, 458748, 65539, 2, 393212, 65539, 1, 327676, 65539, 1, 262140, 65539, 1, 196604, 65539, 1, 131068, 65539, 1, 65532, 65539, 1, -4, 65539, 1, -65540, 65539, 1, -131076, 65539, 1, -196612, 65539, 1, -262148, 65539, 1, -327684, 65539, 1, -393220, 65539, 0, 458747, 65539, 2, 393211, 65539, 1, 327675, 65539, 1, 262139, 65539, 1, 196603, 65539, 1, 131067, 65539, 1, 65531, 65539, 1, -5, 65539, 1, -65541, 65539, 1, -131077, 65539, 1, -196613, 65539, 1, -262149, 65539, 1, -327685, 65539, 1, -393221, 65539, 0, 458746, 65539, 2, 393210, 65539, 1, 327674, 65539, 1, 262138, 65539, 1, 196602, 65539, 1, 131066, 65539, 1, 65530, 65539, 1, -6, 65539, 1, -65542, 65539, 1, -131078, 65539, 1, -196614, 65539, 1, -262150, 65539, 1, -327686, 65539, 1, -393222, 65539, 0, 458745, 65539, 2, 393209, 65539, 1, 327673, 65539, 1, 262137, 65539, 1, 196601, 65539, 1, 131065, 65539, 1, 65529, 65539, 1, -7, 65539, 1, -65543, 65539, 1, -131079, 65539, 1, -196615, 65539, 1, -262151, 65539, 1, -327687, 65539, 1, -393223, 65539, 0, 458744, 65539, 2, 393208, 65539, 1, 327672, 65539, 1, 262136, 65539, 1, 196600, 65539, 1, 131064, 65539, 1, 65528, 65539, 1, -8, 65539, 1, -65544, 65539, 1, -131080, 65539, 1, -196616, 65539, 1, -262152, 65539, 1, -327688, 65539, 1, -393224, 65539, 0, 458743, 65539, 2, 393207, 65539, 1, 327671, 65539, 1, 262135, 65539, 1, 196599, 65539, 1, 131063, 65539, 1, 65527, 65539, 1, -9, 65539, 1, -65545, 65539, 1, -131081, 65539, 1, -196617, 65539, 1, -262153, 65539, 1, -327689, 65539, 1, -393225, 65539, 0, 458742, 65539, 2, 393206, 65539, 1, 327670, 65539, 1, 262134, 65539, 1, 196598, 65539, 1, 131062, 65539, 1, 65526, 65539, 1, -10, 65539, 1, -65546, 65539, 1, -131082, 65539, 1, -196618, 65539, 1, -262154, 65539, 1, -327690, 65539, 1, -393226, 65539, 0, 458741, 3, 2, 393205, 3, 1, 327669, 3, 1, 262133, 3, 1, 196597, 3, 1, 131061, 3, 1, 65525, 3, 1, -11, 3, 1, -65547, 3, 1, -131083, 3, 1, -196619, 3, 1, -262155, 3, 1, -327691, 3, 1, -393227, 3, 0, 393226, 131075, 2, 327690, 131075, 1, 262154, 131075, 1, 196618, 131075, 1, 131082, 131075, 1, 65546, 131075, 1, 10, 131075, 1, -65526, 131075, 1, -131062, 131075, 1, -196598, 131075, 1, -262134, 131075, 1, -327670, 131075, 1, -393206, 131075, 1, -458742, 131075, 0, -393217, 65539, 0, -458752, 65539, 0)
layer_2/name = "Obstacles"
layer_2/enabled = true
layer_2/modulate = Color(1, 1, 1, 1)
layer_2/y_sort_enabled = true
layer_2/y_sort_origin = 0
layer_2/z_index = 1
layer_2/tile_data = PackedInt32Array()
script = ExtResource("4_qpude")

[node name="DoorN" parent="." instance=ExtResource("5_vts0r")]
Expand Down
19 changes: 19 additions & 0 deletions godot/src/props/stone.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=3 uid="uid://bqndpno6afbql"]

[ext_resource type="Texture2D" uid="uid://dbvhpmqxnmcww" path="res://assets/Stones_Round.png" id="1_i6d4t"]

[sub_resource type="CircleShape2D" id="CircleShape2D_hr4nb"]
radius = 5.0

[node name="Stone" type="NavigationObstacle2D"]
position = Vector2(-82, 29)
radius = 5.0

[node name="Stone" type="StaticBody2D" parent="."]
collision_mask = 0

[node name="Sprite2D" type="Sprite2D" parent="Stone"]
texture = ExtResource("1_i6d4t")

[node name="CollisionShape2D" type="CollisionShape2D" parent="Stone"]
shape = SubResource("CircleShape2D_hr4nb")

0 comments on commit 28f1da0

Please sign in to comment.