-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abdc7a6
commit e4eca16
Showing
10 changed files
with
122 additions
and
17 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,12 @@ | ||
extends Area2D | ||
|
||
onready var animatedSprite: = $AnimatedSprite | ||
|
||
var active = true | ||
|
||
func _on_Checkpoint_body_entered(body): | ||
if not body is Player: return | ||
if not active: return | ||
animatedSprite.play("Checked") | ||
active = false | ||
Events.emit_signal("hit_checkpoint", position) |
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,46 @@ | ||
[gd_scene load_steps=8 format=2] | ||
|
||
[ext_resource path="res://tiles_packed.png" type="Texture" id=1] | ||
[ext_resource path="res://Checkpoint.gd" type="Script" id=2] | ||
|
||
[sub_resource type="AtlasTexture" id=1] | ||
atlas = ExtResource( 1 ) | ||
region = Rect2( 198, 90, 18, 18 ) | ||
|
||
[sub_resource type="AtlasTexture" id=2] | ||
atlas = ExtResource( 1 ) | ||
region = Rect2( 216, 90, 18, 18 ) | ||
|
||
[sub_resource type="AtlasTexture" id=3] | ||
atlas = ExtResource( 1 ) | ||
region = Rect2( 198, 108, 18, 18 ) | ||
|
||
[sub_resource type="SpriteFrames" id=4] | ||
animations = [ { | ||
"frames": [ SubResource( 1 ), SubResource( 2 ) ], | ||
"loop": true, | ||
"name": "Checked", | ||
"speed": 5.0 | ||
}, { | ||
"frames": [ SubResource( 3 ) ], | ||
"loop": true, | ||
"name": "Unchecked", | ||
"speed": 5.0 | ||
} ] | ||
|
||
[sub_resource type="RectangleShape2D" id=5] | ||
extents = Vector2( 9, 9 ) | ||
|
||
[node name="Checkpoint" type="Area2D"] | ||
script = ExtResource( 2 ) | ||
|
||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."] | ||
position = Vector2( 0, -9 ) | ||
frames = SubResource( 4 ) | ||
animation = "Unchecked" | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
position = Vector2( 0, -9 ) | ||
shape = SubResource( 5 ) | ||
|
||
[connection signal="body_entered" from="." to="." method="_on_Checkpoint_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,4 @@ | ||
extends Node | ||
|
||
signal player_died | ||
signal hit_checkpoint(checkpoint_position) |
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
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
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 |
---|---|---|
@@ -1,4 +1,27 @@ | ||
extends Node2D | ||
|
||
const PlayerScene = preload("res://Player.tscn") | ||
|
||
var player_spawn_location = Vector2.ZERO | ||
|
||
onready var camera: = $Camera2D | ||
onready var player: = $Player | ||
onready var timer: = $Timer | ||
|
||
func _ready(): | ||
VisualServer.set_default_clear_color(Color.lightblue) | ||
player.connect_camera(camera) | ||
player_spawn_location = player.global_position | ||
Events.connect("player_died", self, "_on_player_died") | ||
Events.connect("hit_checkpoint", self, "_on_hit_checkpoint") | ||
|
||
func _on_player_died(): | ||
timer.start(1.0) | ||
yield(timer, "timeout") | ||
var player = PlayerScene.instance() | ||
player.position = player_spawn_location | ||
add_child(player) | ||
player.connect_camera(camera) | ||
|
||
func _on_hit_checkpoint(checkpoint_position): | ||
player_spawn_location = checkpoint_position |
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