Moved dust animation spawn to player script + player wall jump max gravity fix
This commit is contained in:
parent
5ec32f4447
commit
87b25dccd0
3 changed files with 27 additions and 21 deletions
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource path="res://assets/Tiles/tileset.png" type="Texture" id=1]
|
[ext_resource path="res://assets/Tiles/tileset.png" type="Texture" id=1]
|
||||||
|
|
||||||
[sub_resource type="OccluderPolygon2D" id=36]
|
[sub_resource type="OccluderPolygon2D" id=1]
|
||||||
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
polygon = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 )
|
||||||
|
|
||||||
[sub_resource type="OccluderPolygon2D" id=2]
|
[sub_resource type="OccluderPolygon2D" id=2]
|
||||||
|
@ -116,7 +116,7 @@ points = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 )
|
||||||
0/autotile/icon_coordinate = Vector2( 1, 0 )
|
0/autotile/icon_coordinate = Vector2( 1, 0 )
|
||||||
0/autotile/tile_size = Vector2( 16, 16 )
|
0/autotile/tile_size = Vector2( 16, 16 )
|
||||||
0/autotile/spacing = 0
|
0/autotile/spacing = 0
|
||||||
0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 36 ), Vector2( 0, 1 ), SubResource( 2 ), Vector2( 0, 2 ), SubResource( 3 ), Vector2( 1, 0 ), SubResource( 4 ), Vector2( 1, 1 ), SubResource( 5 ), Vector2( 1, 2 ), SubResource( 6 ), Vector2( 2, 0 ), SubResource( 7 ), Vector2( 2, 1 ), SubResource( 8 ), Vector2( 2, 2 ), SubResource( 9 ), Vector2( 3, 0 ), SubResource( 10 ), Vector2( 3, 1 ), SubResource( 11 ), Vector2( 3, 2 ), SubResource( 12 ), Vector2( 4, 0 ), SubResource( 13 ), Vector2( 4, 2 ), SubResource( 14 ), Vector2( 5, 0 ), SubResource( 15 ), Vector2( 5, 1 ), SubResource( 16 ), Vector2( 5, 2 ), SubResource( 17 ) ]
|
0/autotile/occluder_map = [ Vector2( 0, 0 ), SubResource( 1 ), Vector2( 0, 1 ), SubResource( 2 ), Vector2( 0, 2 ), SubResource( 3 ), Vector2( 1, 0 ), SubResource( 4 ), Vector2( 1, 1 ), SubResource( 5 ), Vector2( 1, 2 ), SubResource( 6 ), Vector2( 2, 0 ), SubResource( 7 ), Vector2( 2, 1 ), SubResource( 8 ), Vector2( 2, 2 ), SubResource( 9 ), Vector2( 3, 0 ), SubResource( 10 ), Vector2( 3, 1 ), SubResource( 11 ), Vector2( 3, 2 ), SubResource( 12 ), Vector2( 4, 0 ), SubResource( 13 ), Vector2( 4, 2 ), SubResource( 14 ), Vector2( 5, 0 ), SubResource( 15 ), Vector2( 5, 1 ), SubResource( 16 ), Vector2( 5, 2 ), SubResource( 17 ) ]
|
||||||
0/autotile/navpoly_map = [ ]
|
0/autotile/navpoly_map = [ ]
|
||||||
0/autotile/priority_map = [ ]
|
0/autotile/priority_map = [ ]
|
||||||
0/autotile/z_index_map = [ ]
|
0/autotile/z_index_map = [ ]
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
class_name Player
|
class_name Player
|
||||||
|
|
||||||
export var run_speed := 100
|
export var run_speed := 100.0
|
||||||
export var jump_power := 180
|
export var jump_power := 180.0
|
||||||
export var gravity: = 500
|
export var gravity: = 500.0
|
||||||
export var max_gravity:= 500
|
export var max_gravity:= 450.0
|
||||||
export var respawn_position:=Vector2.ZERO
|
export var respawn_position:=Vector2.ZERO
|
||||||
export var wall_slide_friction:=.2
|
export var wall_slide_friction:=.2
|
||||||
export var wall_jump_speed_factor := Vector2(2.5 ,.85)
|
export var wall_jump_speed_factor := Vector2(2.5 ,.85)
|
||||||
export var dash_thrust = 500
|
export var dash_thrust = 500.0
|
||||||
|
export var max_wall_slide_gravity := 100.0
|
||||||
|
|
||||||
|
var LandingDust = load("res://src/Actors/LandingDust.tscn")
|
||||||
|
var JumpDust = load("res://src/Actors/JumpDust.tscn")
|
||||||
|
|
||||||
|
|
||||||
signal landed
|
signal landed
|
||||||
|
@ -31,12 +35,15 @@ func _physics_process(delta: float) -> void:
|
||||||
if _alive:
|
if _alive:
|
||||||
var is_jump_canceled: = Input.is_action_just_released("jump") and !_is_wall_jumping and _velocity.y < 0.0
|
var is_jump_canceled: = Input.is_action_just_released("jump") and !_is_wall_jumping and _velocity.y < 0.0
|
||||||
var direction: = get_direction()
|
var direction: = get_direction()
|
||||||
_is_wall_sliding = _velocity.y >=0 and _is_next_to_wall() and !is_on_floor()
|
_is_wall_sliding = _velocity.y >=0 and _is_next_to_wall() and _in_air
|
||||||
_velocity = calculate_move_velocity(direction,is_jump_canceled, delta)
|
_velocity = calculate_move_velocity(direction,is_jump_canceled, delta)
|
||||||
_velocity = move_and_slide(_velocity, Vector2.UP)
|
_velocity = move_and_slide(_velocity, Vector2.UP)
|
||||||
update_sprite(direction)
|
update_sprite(direction)
|
||||||
if is_on_floor() and !_is_dashing: _can_dash = true;
|
if is_on_floor() and !_is_dashing: _can_dash = true;
|
||||||
if is_on_floor() and _in_air and !_is_dashing:
|
if is_on_floor() and _in_air and !_is_dashing:
|
||||||
|
var dust = LandingDust.instance()
|
||||||
|
dust.position = position
|
||||||
|
get_parent().add_child(dust)
|
||||||
_in_air = false
|
_in_air = false
|
||||||
_is_wall_jumping = false
|
_is_wall_jumping = false
|
||||||
emit_signal("landed", position)
|
emit_signal("landed", position)
|
||||||
|
@ -69,11 +76,12 @@ func calculate_move_velocity(direction:Vector2, is_jump_canceled:bool, delta:fl
|
||||||
var desired = -(run_speed * wall_jump_speed_factor.x * walljump__x_direction)
|
var desired = -(run_speed * wall_jump_speed_factor.x * walljump__x_direction)
|
||||||
output.x = desired
|
output.x = desired
|
||||||
output.y = jump_power * wall_jump_speed_factor.y * direction.y
|
output.y = jump_power * wall_jump_speed_factor.y * direction.y
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
#jump
|
#jump
|
||||||
output.y = jump_power * direction.y
|
output.y = jump_power * direction.y
|
||||||
|
var dust = JumpDust.instance()
|
||||||
|
dust.position = position;
|
||||||
|
get_parent().add_child(dust)
|
||||||
emit_signal("jumping", position)
|
emit_signal("jumping", position)
|
||||||
|
|
||||||
if not _is_dashing:
|
if not _is_dashing:
|
||||||
|
@ -86,6 +94,9 @@ func calculate_move_velocity(direction:Vector2, is_jump_canceled:bool, delta:fl
|
||||||
if _is_dashing:
|
if _is_dashing:
|
||||||
return _velocity
|
return _velocity
|
||||||
|
|
||||||
|
if _is_wall_sliding and output.y > max_wall_slide_gravity:
|
||||||
|
output.y = max_wall_slide_gravity
|
||||||
|
|
||||||
var dash_velocity := Vector2(
|
var dash_velocity := Vector2(
|
||||||
(-1 if $Sprite.flip_h else 1) * dash_thrust,
|
(-1 if $Sprite.flip_h else 1) * dash_thrust,
|
||||||
0
|
0
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
var LandingDust = load("res://src/Actors/LandingDust.tscn")
|
|
||||||
var JumpDust = load("res://src/Actors/JumpDust.tscn")
|
|
||||||
export var screen_size := Vector2(480, 270)
|
export var screen_size := Vector2(480, 270)
|
||||||
|
|
||||||
var _grid_active_cell_origin := Vector2.ZERO
|
var _grid_active_cell_origin := Vector2.ZERO
|
||||||
|
@ -40,12 +39,8 @@ func _update_camera(delta:float) -> void:
|
||||||
$Camera2D.update_grid_position(desired_camera_position)
|
$Camera2D.update_grid_position(desired_camera_position)
|
||||||
|
|
||||||
func _on_Player_landed(position:Vector2) -> void:
|
func _on_Player_landed(position:Vector2) -> void:
|
||||||
var dust = LandingDust.instance()
|
pass
|
||||||
add_child(dust)
|
|
||||||
dust.position = position
|
|
||||||
|
|
||||||
|
|
||||||
func _on_Player_jumping(position:Vector2) -> void:
|
func _on_Player_jumping(position:Vector2) -> void:
|
||||||
var dust = JumpDust.instance()
|
pass
|
||||||
add_child(dust)
|
|
||||||
dust.position = position
|
|
||||||
|
|
Loading…
Reference in a new issue