-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/Edearth/malaga-jam-2024
- Loading branch information
Showing
19 changed files
with
213 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
extends Node | ||
|
||
var rock_manager: Node | ||
|
||
|
||
# SHAKE NODES | ||
const _shake_level: float = 40 | ||
const _duration: float = .5 | ||
const _frequency: int = 10 | ||
const _property_to_shake: String = "position" | ||
func create_shake_node2d_tween(node: Node2D, shake_level: float = _shake_level, duration: float = _duration, frequency: float = _frequency, property_to_shake: String = _property_to_shake) -> Tween: | ||
var tween: Tween = get_tree().create_tween() | ||
var period = duration / frequency | ||
for i in range(frequency - 1): | ||
tween.tween_property(node, property_to_shake, node.position + get_random_offset(), period) | ||
tween.tween_property(node, property_to_shake, node.position, period) | ||
return tween | ||
|
||
func get_random_offset() -> Vector2: | ||
return Vector2(randf_range(-_shake_level, _shake_level), randf_range(-_shake_level, _shake_level)) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dd2homxrf853x"] | ||
|
||
[ext_resource type="Script" path="res://scenes/utils/signal_player_entered.gd" id="1_1wnt7"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ageqp"] | ||
size = Vector2(600, 300) | ||
|
||
[node name="DetectPlayer" type="Area2D"] | ||
position = Vector2(308, -728) | ||
script = ExtResource("1_1wnt7") | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("RectangleShape2D_ageqp") | ||
|
||
[connection signal="body_entered" from="." to="." method="_on_body_entered"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
extends Node2D | ||
|
||
signal game_finished | ||
|
||
@onready var player_character = $"../PlayerCharacter" | ||
var is_game_finished := false | ||
|
||
func _process(delta): | ||
if is_game_finished: | ||
return | ||
if player_character.position.y < position.y - 100: | ||
$StaticBody2D.position.x = 300 | ||
game_finished.emit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[gd_scene load_steps=5 format=3 uid="uid://g6i6xqvaxk81"] | ||
|
||
[ext_resource type="Texture2D" uid="uid://dds1sdaxddjq" path="res://assets/circle.svg" id="1_18x6o"] | ||
[ext_resource type="Script" path="res://scenes/gameplay/rock/rock_hit.gd" id="2_f6cby"] | ||
|
||
[sub_resource type="CircleShape2D" id="CircleShape2D_gafgp"] | ||
radius = 65.0 | ||
|
||
[sub_resource type="CircleShape2D" id="CircleShape2D_eggec"] | ||
radius = 43.0116 | ||
|
||
[node name="Rock" type="RigidBody2D"] | ||
collision_layer = 4 | ||
collision_mask = 4 | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
shape = SubResource("CircleShape2D_gafgp") | ||
|
||
[node name="Sprite2D" type="Sprite2D" parent="CollisionShape2D"] | ||
texture = ExtResource("1_18x6o") | ||
|
||
[node name="HitArea" type="Area2D" parent="."] | ||
collision_layer = 8 | ||
collision_mask = 2 | ||
script = ExtResource("2_f6cby") | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="HitArea"] | ||
shape = SubResource("CircleShape2D_eggec") | ||
|
||
[connection signal="body_entered" from="HitArea" to="HitArea" method="_on_body_entered"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
extends Area2D | ||
|
||
const push_down_velocity: float = 100 | ||
|
||
func _on_body_entered(body: Node2D): | ||
if body.is_in_group("player"): | ||
push_player_down(body) | ||
|
||
func break_rock(): | ||
queue_free() | ||
|
||
func push_player_down(player: Node2D): | ||
set_deferred("monitoring", false) | ||
#Global.rock_manager.set_deferred("sleeping", true) | ||
Global.rock_manager.propagate_call("set_sleeping", [true]) | ||
player.velocity = Vector2.DOWN * push_down_velocity | ||
var tween := Global.create_shake_node2d_tween(player) | ||
tween.tween_callback(restart_physics_and_free) | ||
|
||
func restart_physics_and_free(): | ||
Global.rock_manager.propagate_call("set_sleeping", [false]) | ||
call_deferred("queue_free") | ||
get_parent().queue_free() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
extends Node2D | ||
|
||
const DISTANCE_TO_DELETE: float = 1000 | ||
|
||
func _ready(): | ||
Global.rock_manager = self | ||
|
||
func _process(_delta): | ||
for child in get_children(): | ||
if child.position.y > 1000: | ||
child.queue_free() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
extends Area2D | ||
|
||
@onready var rock_scene: PackedScene = load("res://scenes/gameplay/rock/rock.tscn") | ||
@onready var timer = $Timer | ||
@export var spawn_rocks_on_start: bool = false | ||
|
||
func _ready(): | ||
if spawn_rocks_on_start: | ||
$Timer.start() | ||
|
||
func get_random_position_in_spawn_area() -> Vector2: | ||
var rect: Rect2 = $CollisionShape2D.shape.get_rect() | ||
var x = randf_range(rect.position.x, rect.position.x + rect.size.x) | ||
var y = randf_range(rect.position.y, rect.position.y + rect.size.y) | ||
return Vector2(x,y) | ||
|
||
func spawn_rock(): | ||
var instance = rock_scene.instantiate() | ||
instance.position = get_random_position_in_spawn_area() + self.global_position | ||
Global.rock_manager.add_child(instance) | ||
|
||
func _on_timer_timeout(): | ||
get_random_position_in_spawn_area() | ||
spawn_rock() | ||
|
||
func stop(): | ||
$Timer.stop() | ||
|
||
func start(): | ||
$Timer.start(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dcgm675xw4oul"] | ||
|
||
[ext_resource type="Script" path="res://scenes/gameplay/rock/rock_spawner.gd" id="1_cglio"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7ch2b"] | ||
size = Vector2(500, 20) | ||
|
||
[node name="RockSpawner" type="Area2D"] | ||
position = Vector2(-8, -488) | ||
script = ExtResource("1_cglio") | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
position = Vector2(0, 28) | ||
shape = SubResource("RectangleShape2D_7ch2b") | ||
|
||
[node name="Timer" type="Timer" parent="."] | ||
wait_time = 2.0 | ||
|
||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
extends Area2D | ||
|
||
signal on_player_entered | ||
|
||
func _on_body_entered(body): | ||
if body.is_in_group("player"): | ||
on_player_entered.emit() |