Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve player movement and collisions #64

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Sick_Day_Delivery/Scenes/bacterium.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[ext_resource type="Texture2D" uid="uid://dhuvgmi3gk51t" path="res://Sprites/BacteriumPlaceholderOpen.png" id="2_t8pqe"]
[ext_resource type="Texture2D" uid="uid://dy6wv6icnbxex" path="res://Sprites/BacteriumPlaceholderClosing.png" id="3_tsrh2"]
[ext_resource type="Texture2D" uid="uid://dkj22ftiqb28p" path="res://Sprites/BacteriumPlaceholderBlink.png" id="4_iwx0g"]
[ext_resource type="PackedScene" uid="uid://d1o54853ecumx" path="res://Scenes/mob_audio_controller.tscn" id="5_y6dl2"]
[ext_resource type="PackedScene" path="res://Scenes/mob_audio_controller.tscn" id="5_y6dl2"]
[ext_resource type="AudioStream" uid="uid://c43uubnn7a6lc" path="res://Audio/Foley/Enemy Hurt 1.mp3" id="6_dj75s"]
[ext_resource type="AudioStream" uid="uid://c6t4ivr56vew8" path="res://Audio/Foley/Enemy Hurt 2.mp3" id="7_s1ygv"]

Expand Down Expand Up @@ -48,3 +48,10 @@ actions = Array[AudioStream]([ExtResource("6_dj75s"), ExtResource("7_s1ygv"), Ex
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
build_mode = 1
polygon = PackedVector2Array(52, -44, 68, 12, 64, 56, 56, 64, 4, 64, -44, 64, -52, 52, -56, 8, -40, -44, 8, -48)

[node name="DeathTimer" type="Timer" parent="."]
process_callback = 0
wait_time = 0.4
one_shot = true

[connection signal="timeout" from="DeathTimer" to="." method="_on_death_timer_timeout"]
6 changes: 3 additions & 3 deletions Sick_Day_Delivery/Scenes/main.tscn
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[gd_scene load_steps=10 format=3 uid="uid://b4xi3mlkhu4ow"]

[ext_resource type="PackedScene" uid="uid://bhh5dmfulsc0f" path="res://Scenes/body_map.tscn" id="1_6xrru"]
[ext_resource type="PackedScene" path="res://Scenes/body_map.tscn" id="1_6xrru"]
[ext_resource type="Script" path="res://Scripts/main.gd" id="1_mnr5t"]
[ext_resource type="PackedScene" uid="uid://cvpq0di0nimsq" path="res://Scenes/player_cell.tscn" id="2_dynj6"]
[ext_resource type="PackedScene" uid="uid://cy8wae7f4lg5e" path="res://Scenes/audio.tscn" id="6_cs0yl"]
[ext_resource type="PackedScene" uid="uid://dp4x40y3bkvxf" path="res://Scenes/global_state.tscn" id="7_3cwkh"]
[ext_resource type="PackedScene" path="res://Scenes/global_state.tscn" id="7_3cwkh"]
[ext_resource type="PackedScene" uid="uid://q78nn6ov4tkl" path="res://Scenes/infection_spawner.tscn" id="7_sg8fw"]
[ext_resource type="PackedScene" uid="uid://cl3gneduvqjdn" path="res://Scenes/colony.tscn" id="8_nndff"]
[ext_resource type="PackedScene" uid="uid://by2kd0e26letn" path="res://Scenes/HUD.tscn" id="8_to7ic"]
[ext_resource type="PackedScene" path="res://Scenes/HUD.tscn" id="8_to7ic"]
[ext_resource type="PackedScene" path="res://Scenes/pause_menu.tscn" id="9_y16aj"]

[node name="Node2D" type="Node2D"]
Expand Down
10 changes: 6 additions & 4 deletions Sick_Day_Delivery/Scripts/Bacterium.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ func _physics_process(delta):

if collision:
var body_name = collision.get_collider().name
print_debug(collision.get_collider().name)
if body_name == "PlayerCell":
queue_free()

func _on_body_entered(_body):
await $MobAudioController.act(randi() % 4)
emit_signal("on_enemy_ded")
$DeathTimer.start()
destroy_bacteria()

func _on_death_timer_timeout():
queue_free()

func destroy_bacteria():
await $MobAudioController.act(randi() % 4)
emit_signal("on_enemy_ded")
$DeathTimer.start()
7 changes: 5 additions & 2 deletions Sick_Day_Delivery/Scripts/player_cell.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends CharacterBody2D

@export var acceleration := 20.0
@export var acceleration := 2.0
@export var max_speed := 400.0
@export var rotation_speed := 250.0

Expand All @@ -25,7 +25,10 @@ func _physics_process(delta):
move_and_slide()
for i in get_slide_collision_count():
var collision = get_slide_collision(i)
# print_debug(collision.get_collider().name)
if(collision.get_collider().has_method("destroy_bacteria")):
print_debug(collision.get_collider().name)
collision.get_collider().destroy_bacteria()


if Input.is_action_just_pressed("cure"):
if $GPUParticles2D.emitting == false:
Expand Down