Traps updated, Live and Collactables added

This commit is contained in:
Jan Schuffenhauer
2020-04-18 18:56:05 +02:00
parent b0a35659d9
commit dd01067dac
30 changed files with 240 additions and 103 deletions

View File

@@ -6,13 +6,13 @@ This is an example player controller script created by Paul
var velocity := Vector2.ZERO
var rollvector := Vector2.ZERO
# This is how you export variables with ranges to the editor window
export(int, 0, 500) var MAX_SPEED := 125
export(int, 0, 500) var ROLL_SPEED := 150
export(int, 0, 500) var FRICTION := 200 # Speed at which the player deaccelarates
export(int, 0, 500) var ACCELERATION := 450
# Reference for the current player
onready var player_stats := $Stats
onready var debug_label := $DebugLabel
onready var animation_player := $AnimationPlayer
onready var animation_tree := $AnimationTree
onready var animation_state = animation_tree.get("parameters/playback")
@@ -25,9 +25,26 @@ enum moveState{
var movementState = moveState.MOVE
var damage_per_second := 0.0
var totaldamage := 0.0
var currency := 0
var experience := 0.0
func _debug_update():
debug_label.text = str(player_stats.health) + "/" + str(player_stats.max_health) + " HP\n" + str(currency) + ""
func _physics_process(delta):
totaldamage+=damage_per_second*delta
player_stats.speed+=10*delta
while(totaldamage>1):
totaldamage-=1
player_stats.health-=1
while(totaldamage<-1):
totaldamage+=1
player_stats.health+=1
_debug_update()
match movementState:
moveState.MOVE:
movement_move(delta)
@@ -65,7 +82,7 @@ func movement_move(delta):
animation_tree.set("parameters/roll/blend_position", input_vector)
animation_tree.set("parameters/run/blend_position", input_vector)
animation_state.travel("run")
velocity = velocity.move_toward(MAX_SPEED * input_vector, ACCELERATION * delta)
velocity = velocity.move_toward(player_stats.speed * input_vector, ACCELERATION * delta)
if Input.is_action_just_pressed("roll"):
movementState = moveState.ROLL
elif Input.is_action_just_pressed("attack"):
@@ -87,8 +104,21 @@ func roll_finished():
func _on_Hurtbox_area_entered(area):
player_stats.health-=area.damage
damage_per_second = damage_per_second + area.damage
func _on_Hurtbox_area_exited(area):
damage_per_second = damage_per_second - area.damage
func _on_Stats_no_health():
queue_free()
get_tree().change_scene("res://Menus/TitleScreen/TitleScreen.tscn")
func _on_Hitbox_area_entered(area):
pass
currency += area.currency_value
player_stats.health = player_stats.health+area.health_value
player_stats.speed -= area.slowdown_value

View File

@@ -1,10 +1,11 @@
[gd_scene load_steps=54 format=2]
[gd_scene load_steps=56 format=2]
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Player/Player.png" type="Texture" id=2]
[ext_resource path="res://HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=3]
[ext_resource path="res://HurtHit_Box/Hitbox.tscn" type="PackedScene" id=4]
[ext_resource path="res://Overlap/Stats.tscn" type="PackedScene" id=5]
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=3]
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=4]
[ext_resource path="res://Overlap/Stats/Stats.tscn" type="PackedScene" id=5]
[ext_resource path="res://Fonts/Harmonic/Harmonic.ttf" type="DynamicFontData" id=6]
[sub_resource type="CapsuleShape2D" id=1]
radius = 2.15976
@@ -611,6 +612,10 @@ height = 0.175497
radius = 4.03497
height = 6.99104
[sub_resource type="DynamicFont" id=49]
size = 12
font_data = ExtResource( 6 )
[node name="Player" type="KinematicBody2D"]
script = ExtResource( 1 )
FRICTION = 270
@@ -689,9 +694,22 @@ position = Vector2( 8.43416, 0.0698299 )
shape = SubResource( 48 )
disabled = true
[node name="DebugLabel" type="Label" parent="."]
margin_left = -8.01196
margin_top = -21.2223
margin_right = 8.98804
margin_bottom = -9.22228
custom_fonts/font = SubResource( 49 )
text = "Ahh"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Stats" parent="." instance=ExtResource( 5 )]
max_health = 5
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
[editable path="Hitbox"]