added tilemap added falling and jumping animation added textures for player crate and grenade, camera, game scaling
This commit is contained in:
1 parent
5418f512cd
commit
cdfa1a3f50
61 files changed
+948
-101
No files matched your search
+22
-1
@@ -10,12 +10,14 @@ const JUMP_VELOCITY = -400.0
|
||||
var direction
|
||||
enum FaceDirection{LEFT, RIGHT}
|
||||
var facing:FaceDirection = FaceDirection.RIGHT
|
||||
enum State{IDLE,RUNNING}
|
||||
enum State{IDLE,RUNNING,JUMPING,FALLING}
|
||||
var currentState:State = State.IDLE
|
||||
|
||||
var pushTarget:RigidBody2D
|
||||
var pushEnabled:bool = false
|
||||
|
||||
var upJump:bool = false
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
handle_input()
|
||||
handle_movement(delta)
|
||||
@@ -42,6 +44,8 @@ func handle_input()->void:
|
||||
|
||||
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
upJump = true
|
||||
currentState = State.JUMPING
|
||||
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
@@ -94,9 +98,26 @@ func handle_state():
|
||||
currentState = State.RUNNING
|
||||
State.RUNNING when velocity.x == 0:
|
||||
currentState = State.IDLE
|
||||
State.JUMPING when velocity.y > 0:
|
||||
currentState = State.FALLING
|
||||
State.FALLING when velocity.y == 0:
|
||||
currentState = State.IDLE
|
||||
func handle_animation():
|
||||
match currentState:
|
||||
State.IDLE:
|
||||
player_graphic.play("idle")
|
||||
State.RUNNING:
|
||||
player_graphic.play("Run")
|
||||
State.JUMPING:
|
||||
if upJump:
|
||||
player_graphic.play("jump")
|
||||
State.FALLING:
|
||||
if not upJump:
|
||||
player_graphic.play("fall")
|
||||
|
||||
|
||||
|
||||
func _on_player_graphic_animation_finished():
|
||||
match currentState:
|
||||
State.JUMPING:
|
||||
upJump = false
|
||||
Reference in new issue
Block a user