Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Paulpanther committed Dec 6, 2020
2 parents b6f7ce0 + ed5307a commit 54573d4
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 5 deletions.
15 changes: 15 additions & 0 deletions 2d/checkpoint.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
extends Area2D

var activated = false

func _ready():
$Label.visible = false

func _on_checkpoint_body_entered(body):
if body.is_in_group("player") and not activated:
activated = true
$Label.visible = true
body.last_checkpoint = self

func get_spawn_position():
return $spawn_point.global_position
32 changes: 32 additions & 0 deletions 2d/checkpoint.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[gd_scene load_steps=5 format=2]

[ext_resource path="res://assets/Roboto-Medium.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://2d/checkpoint.gd" type="Script" id=2]

[sub_resource type="DynamicFont" id=1]
font_data = ExtResource( 1 )

[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 17.3624, 172.791 )

[node name="checkpoint" type="Area2D"]
script = ExtResource( 2 )

[node name="Label" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 14.0
rect_rotation = -89.9999
custom_fonts/font = SubResource( 1 )
custom_colors/font_color = Color( 0.51, 1.16, 30.06, 1 )
text = "CHECKPOINT"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 17.1005, -115.586 )
shape = SubResource( 2 )

[node name="spawn_point" type="Node2D" parent="."]
position = Vector2( 21.0224, -58.2321 )
[connection signal="body_entered" from="." to="." method="_on_checkpoint_body_entered"]
14 changes: 12 additions & 2 deletions 2d/game.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]

[ext_resource path="res://2d/Scene2D.tscn" type="PackedScene" id=1]
[ext_resource path="res://script/game.gd" type="Script" id=2]
Expand Down Expand Up @@ -51,6 +51,13 @@ void fragment() {
shader = SubResource( 1 )
shader_param/ZoomStrength = 0.0

[sub_resource type="Environment" id=4]
background_mode = 4
background_canvas_max_layer = 5
glow_enabled = true
glow_intensity = 1.28
glow_strength = 0.84

[node name="game" type="Node2D"]
script = ExtResource( 2 )

Expand All @@ -66,7 +73,10 @@ __meta__ = {
[node name="Viewport" type="Viewport" parent="ViewportContainer"]
size = Vector2( 1024, 600 )
handle_input_locally = false
usage = 0
render_direct_to_screen = true
render_target_update_mode = 3

[node name="WorldEnvironment" type="WorldEnvironment" parent="ViewportContainer/Viewport"]
environment = SubResource( 4 )

[node name="scene" parent="ViewportContainer/Viewport" instance=ExtResource( 1 )]
2 changes: 1 addition & 1 deletion default_env.tres
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
[sub_resource type="ProceduralSky" id=1]

[resource]
background_mode = 2
background_sky = SubResource( 1 )
glow_intensity = 1.49
5 changes: 3 additions & 2 deletions script/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var start_pos
var dead = false
var anchors

var last_checkpoint

func _ready():
start_pos = position
Expand Down Expand Up @@ -65,9 +66,9 @@ func die():
func _integrate_forces(state):
if state.linear_velocity.length() > max_velocity:
state.linear_velocity = state.linear_velocity.normalized() * max_velocity

if dead:
state.transform = Transform2D(0, start_pos)
state.transform = Transform2D(0, last_checkpoint.get_spawn_position() if last_checkpoint else start_pos)
state.linear_velocity = Vector2.ZERO
dead = false

Expand Down

0 comments on commit 54573d4

Please sign in to comment.