mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-12 21:42:23 +02:00
Merge branch 'bos_testing' into devRefactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
extends KinematicBody2D
|
||||
extends Hero
|
||||
class_name Player
|
||||
"""
|
||||
This is an example player controller script created by Paul
|
||||
@@ -27,7 +27,8 @@ export(String, FILE, "*.tscn,*.scn") var title_scene = ""
|
||||
enum moveState{
|
||||
MOVE,
|
||||
ROLL,
|
||||
HIT
|
||||
HIT,
|
||||
IDLE
|
||||
}
|
||||
|
||||
|
||||
@@ -43,14 +44,16 @@ var experience := 0.0
|
||||
func _debug_update():
|
||||
debug_label.text = str(player_stats.health) + "/" + str(player_stats.max_health) + " HP\n" + str(currency) + " €"
|
||||
|
||||
func _ready():
|
||||
grid = get_tree().current_scene.get_child(3)
|
||||
|
||||
func _physics_process(delta):
|
||||
totaldamage+=(damage_per_second - heal_per_second)*delta
|
||||
player_stats.speed+=10*delta
|
||||
while(totaldamage>1):
|
||||
totaldamage-=1
|
||||
totaldamage -= 1
|
||||
player_stats.health-=1
|
||||
while(totaldamage<-1):
|
||||
while(totaldamage < -1):
|
||||
totaldamage+=1
|
||||
player_stats.health+=1
|
||||
_debug_update()
|
||||
@@ -64,6 +67,15 @@ func _physics_process(delta):
|
||||
movement_hit()
|
||||
|
||||
$"Effects/HealEffect".emitting = heal_per_second > 0
|
||||
elif movementState == moveState.ROLL:
|
||||
movement_roll()
|
||||
elif movementState == moveState.HIT:
|
||||
movement_hit()
|
||||
elif movementState == moveState.IDLE:
|
||||
movement_idle()
|
||||
else:
|
||||
movement_run(Vector2(0,0), delta)
|
||||
makeMove(delta)
|
||||
move()
|
||||
|
||||
# IMPORTANT: If you are using move_and_slide don't multiply by delta
|
||||
@@ -71,7 +83,45 @@ func _physics_process(delta):
|
||||
# In move_and_collide(...) you have to multiply by delta.
|
||||
func move():
|
||||
move_and_slide(velocity)
|
||||
|
||||
|
||||
func set_animation_tree_vector():
|
||||
animation_tree.set("parameters/idle/blend_position", rollvector)
|
||||
animation_tree.set("parameters/hit/blend_position", rollvector)
|
||||
animation_tree.set("parameters/roll/blend_position", rollvector)
|
||||
animation_tree.set("parameters/run/blend_position", rollvector)
|
||||
|
||||
|
||||
# API Interface for ai_hero
|
||||
func attac(direction, delta):
|
||||
direction = direction.normalized()
|
||||
rollvector = direction
|
||||
set_animation_tree_vector()
|
||||
movementState = moveState.HIT
|
||||
|
||||
|
||||
# API Interface for ai_hero
|
||||
func roll(direction, delta):
|
||||
direction = direction.normalized()
|
||||
rollvector = direction
|
||||
set_animation_tree_vector()
|
||||
movementState = moveState.ROLL
|
||||
|
||||
|
||||
# API Interface for ai_hero
|
||||
func run(direction, delta):
|
||||
direction = direction.normalized()
|
||||
rollvector = direction
|
||||
set_animation_tree_vector()
|
||||
movementState = moveState.MOVE
|
||||
velocity = velocity.move_toward(player_stats.speed * rollvector, ACCELERATION * delta)
|
||||
|
||||
if direction == Vector2.ZERO:
|
||||
animation_state.travel("idle")
|
||||
else:
|
||||
animation_state.travel("run")
|
||||
|
||||
|
||||
func movement_move(delta):
|
||||
|
||||
var input_vector = Vector2.ZERO
|
||||
@@ -89,21 +139,24 @@ func movement_move(delta):
|
||||
velocity = Vector2.ZERO
|
||||
else:
|
||||
rollvector = input_vector
|
||||
animation_state.change_state("run")
|
||||
|
||||
set_animation_tree_vector()
|
||||
animation_state.change_state("run")
|
||||
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"):
|
||||
movementState = moveState.HIT
|
||||
|
||||
|
||||
|
||||
func movement_hit():
|
||||
velocity = Vector2.ZERO
|
||||
animation_state.change_state("attack")
|
||||
|
||||
func hit_finished():
|
||||
movementState = moveState.MOVE
|
||||
|
||||
movementState = moveState.IDLE
|
||||
ExecutionState = AI_MOVE
|
||||
|
||||
|
||||
func movement_roll():
|
||||
velocity = rollvector * ROLL_SPEED
|
||||
animation_state.change_state("roll")
|
||||
@@ -116,10 +169,11 @@ func movement_roll():
|
||||
func update():
|
||||
owner.velocity = rollvector * ROLL_SPEED
|
||||
"""
|
||||
|
||||
ExecutionState = EXECUTING
|
||||
|
||||
func roll_finished():
|
||||
movementState = moveState.MOVE
|
||||
movementState = moveState.IDLE
|
||||
ExecutionState = AI_MOVE
|
||||
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
@@ -149,5 +203,13 @@ func _on_Hitbox_area_entered(area):
|
||||
currency += area.currency_value
|
||||
player_stats.health = player_stats.health+area.health_value
|
||||
player_stats.speed -= area.slowdown_value
|
||||
|
||||
|
||||
|
||||
|
||||
func movement_run(direction, delta):
|
||||
run(direction, delta)
|
||||
|
||||
|
||||
func movement_idle():
|
||||
movementState = moveState.IDLE
|
||||
velocity = Vector2.ZERO
|
||||
animation_state.travel("idle")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=62 format=2]
|
||||
[gd_scene load_steps=57 format=2]
|
||||
|
||||
[ext_resource path="res://Player/Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Player/player.png" type="Texture" id=2]
|
||||
@@ -12,6 +12,7 @@
|
||||
[ext_resource path="res://Player/States/Attack.gd" type="Script" id=14]
|
||||
[ext_resource path="res://Player/PlayerStateMachine.gd" type="Script" id=15]
|
||||
[ext_resource path="res://Player/States/Roll.gd" type="Script" id=16]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=7]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=1]
|
||||
radius = 2.15976
|
||||
@@ -625,8 +626,14 @@ font_data = ExtResource( 6 )
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
script = ExtResource( 1 )
|
||||
debug = null
|
||||
ROLL_SPEED = null
|
||||
FRICTION = 270
|
||||
title_scene = "res://Menus/TitleScreen/TitleScreen.tscn"
|
||||
ACCELERATION = null
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 7 )]
|
||||
kind = 1
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0.273621, 3.88423 )
|
||||
@@ -688,7 +695,7 @@ shape = SubResource( 47 )
|
||||
|
||||
[node name="Pivot" type="Position2D" parent="."]
|
||||
position = Vector2( 0, -4.16248 )
|
||||
rotation = 1.5708
|
||||
rotation = 3.14159
|
||||
__meta__ = {
|
||||
"_gizmo_extents_": 20.0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user