summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorMarcelo Costa <>2024-01-27 12:19:01 -0300
committerMarcelo Costa <>2024-01-27 12:19:01 -0300
commitfd9f97b0146087ba54fb923bf9536e048b366a65 (patch)
treedb972f3164753e1990b91ba4337d580280e1e9df /game
parent657873d5a87ac10772c58a36d0089c4e864fa86c (diff)
downloadgamejam-ggj-2024-fd9f97b0146087ba54fb923bf9536e048b366a65.tar.gz
gamejam-ggj-2024-fd9f97b0146087ba54fb923bf9536e048b366a65.tar.bz2
gamejam-ggj-2024-fd9f97b0146087ba54fb923bf9536e048b366a65.zip
MVP for Heart Break microgame
Diffstat (limited to 'game')
-rw-r--r--game/microgames/heart_break/heart_break.gd8
-rw-r--r--game/microgames/heart_break/heart_break.tscn3
-rw-r--r--game/microgames/heart_break/player_heart.gd8
-rw-r--r--game/microgames/heart_break/spiky.gd17
-rw-r--r--game/microgames/heart_break/spiky.tscn3
5 files changed, 29 insertions, 10 deletions
diff --git a/game/microgames/heart_break/heart_break.gd b/game/microgames/heart_break/heart_break.gd
index b12ae70..d25afe8 100644
--- a/game/microgames/heart_break/heart_break.gd
+++ b/game/microgames/heart_break/heart_break.gd
@@ -12,7 +12,11 @@ func _process(delta):
func _on_player_heart_body_entered(body):
if body is Spiky:
- print("hey")
- $PlayerHeart.get_node("AnimatedSprite2D").play("death")
+ disable_player()
## GameOver
pass
+
+func disable_player():
+ $PlayerHeart.get_node("AnimatedSprite2D").play("death")
+ $PlayerHeart.playerControl = false
+
diff --git a/game/microgames/heart_break/heart_break.tscn b/game/microgames/heart_break/heart_break.tscn
index 68bec77..b130424 100644
--- a/game/microgames/heart_break/heart_break.tscn
+++ b/game/microgames/heart_break/heart_break.tscn
@@ -54,4 +54,7 @@ position = Vector2(235, 481)
[node name="Spiky4" parent="." instance=ExtResource("3_dfa23")]
position = Vector2(845, 496)
+[node name="Spiky5" parent="." instance=ExtResource("3_dfa23")]
+position = Vector2(570, 104)
+
[connection signal="body_entered" from="PlayerHeart" to="." method="_on_player_heart_body_entered"]
diff --git a/game/microgames/heart_break/player_heart.gd b/game/microgames/heart_break/player_heart.gd
index 565cee1..0a6b26a 100644
--- a/game/microgames/heart_break/player_heart.gd
+++ b/game/microgames/heart_break/player_heart.gd
@@ -1,6 +1,7 @@
extends RigidBody2D
var speed = 250
+var playerControl = true
# Called when the node enters the scene tree for the first time.
func _ready():
@@ -9,7 +10,8 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
- var moveVector = Vector2(Input.get_axis("Left","Right")*speed, Input.get_axis("Up","Down")*speed)
- apply_force(moveVector)
- #set_axis_velocity(moveVector)
+ if(playerControl):
+ var moveVector = Vector2(Input.get_axis("Left","Right")*speed, Input.get_axis("Up","Down")*speed)
+ apply_force(moveVector)
+ #set_axis_velocity(moveVector)
pass
diff --git a/game/microgames/heart_break/spiky.gd b/game/microgames/heart_break/spiky.gd
index 3fa5983..df4414b 100644
--- a/game/microgames/heart_break/spiky.gd
+++ b/game/microgames/heart_break/spiky.gd
@@ -1,11 +1,22 @@
-extends RigidBody2D
+extends CharacterBody2D
class_name Spiky
+var dir:Vector2 = Vector2.UP
+var speed = 200
+
# Called when the node enters the scene tree for the first time.
func _ready():
- pass # Replace with function body.
+ dir = dir.rotated(2*PI*randf())
+ #apply_central_force(dir*250)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
- pass
+ velocity = dir * speed
+ var collided = move_and_slide()
+ if(collided):
+ dir = dir.rotated(2*PI*randf())
+ var collider = get_last_slide_collision().get_collider()
+ if(collider is Node and collider.name == "PlayerHeart"):
+ collider.body_entered.emit(self)
+
diff --git a/game/microgames/heart_break/spiky.tscn b/game/microgames/heart_break/spiky.tscn
index 267dc26..da658b2 100644
--- a/game/microgames/heart_break/spiky.tscn
+++ b/game/microgames/heart_break/spiky.tscn
@@ -6,8 +6,7 @@
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1xy8p"]
size = Vector2(96.5, 90)
-[node name="Spiky" type="RigidBody2D"]
-gravity_scale = 0.0
+[node name="Spiky" type="CharacterBody2D"]
script = ExtResource("1_fx3ld")
[node name="Sprite2D" type="Sprite2D" parent="."]