cleaned up player code and animations a bit; mapped new colours onto veg assets
This commit is contained in:
1 parent
f1d7c8968a
commit
a57003ec24
7 files changed
+21
-41
No files matched your search
@@ -2,7 +2,7 @@ extends Node2D
|
||||
|
||||
var coins_collected : int = 0
|
||||
var total_coins : int = 0
|
||||
var levels = ["res://scenes/game.tscn", "res://scenes/level_2.tscn", "res://scenes/level_3.tscn"]
|
||||
var levels = ["res://scenes/level_1.tscn", "res://scenes/level_2.tscn", "res://scenes/level_3.tscn"]
|
||||
var timers = [10, 15, 20]
|
||||
var time_available : int = 0
|
||||
var current_level = 0
|
||||
|
||||
+6
-11
@@ -18,17 +18,17 @@ enum State {
|
||||
PUNCH
|
||||
}
|
||||
|
||||
const JUMP_VELOCITY = -500.0
|
||||
const SPEED = 200.0
|
||||
const JUMP_VELOCITY := -500.0 ## Power applied for jumping
|
||||
const SPEED := 200.0 ## (Max) movement speed
|
||||
|
||||
@export var BUMP_POWER := 50 ## Power from bumping into objects
|
||||
@export var PUNCH_POWER := 300 ## Power from shoving objects
|
||||
@export var ACCELERATION := 10 ## Amount of "slide-y-ness" in side-to-side-movement
|
||||
@export var HARD_GRAVITY := 2 ## Factor applied during FALL state
|
||||
|
||||
var current_state: State = State.IDLE
|
||||
var facing : FaceDirection = FaceDirection.RIGHT
|
||||
var direction : float = 0.0
|
||||
var current_state: State = State.IDLE ## Player state for FSM
|
||||
var facing : FaceDirection = FaceDirection.RIGHT ## Facing direction for animation orientation
|
||||
var direction : float = 0.0
|
||||
var punch_target : RigidBody2D
|
||||
var punch_enabled : bool = false
|
||||
var jump_buffer_timer : Timer
|
||||
@@ -42,6 +42,7 @@ var shoot_cooldown_timer : Timer
|
||||
|
||||
func _ready() -> void:
|
||||
jump_buffer_timer = Timer.new()
|
||||
jump_buffer_timer.one_shot = true
|
||||
add_child(jump_buffer_timer)
|
||||
shoot_cooldown_timer = Timer.new()
|
||||
shoot_cooldown_timer.one_shot = true
|
||||
@@ -95,28 +96,22 @@ func handle_input() -> void:
|
||||
current_state = State.SHOOT_RUN
|
||||
else:
|
||||
current_state = State.SHOOT_STILL
|
||||
print("pew-pew")
|
||||
match facing:
|
||||
FaceDirection.RIGHT:
|
||||
%SceneManager.make_bullet(right_spawn.global_transform, 700)
|
||||
print("shoot right")
|
||||
FaceDirection.LEFT:
|
||||
%SceneManager.make_bullet(left_spawn.global_transform, -700)
|
||||
print("shoot left")
|
||||
shoot_cooldown_timer.start(0.2)
|
||||
else:
|
||||
print("can't shoot right now because there are %s seconds left in the cooldown timer" % shoot_cooldown_timer.time_left)
|
||||
|
||||
# Handle throwing grenades
|
||||
if Input.is_action_just_pressed("throw"):
|
||||
print("grenade!")
|
||||
match facing:
|
||||
FaceDirection.RIGHT:
|
||||
%SceneManager.make_grenade(right_spawn.global_transform, 1.0)
|
||||
print("throwing right")
|
||||
FaceDirection.LEFT:
|
||||
%SceneManager.make_grenade(left_spawn.global_transform, -1.0)
|
||||
print("throwing left")
|
||||
|
||||
func handle_movement(delta) -> void:
|
||||
# Left-right movement. Use acceleration for smoothing
|
||||
|
||||
Reference in new issue
Block a user