More work on maps and multiplayer
This commit is contained in:
55
scripts/pawn_input.gd
Normal file
55
scripts/pawn_input.gd
Normal file
@@ -0,0 +1,55 @@
|
||||
class_name PawnInput extends Node
|
||||
|
||||
|
||||
@export var dir : Vector3
|
||||
@export var pressed : Dictionary[String, bool]
|
||||
@export var just_pressed : Dictionary[String, bool]
|
||||
@export var just_released : Dictionary[String, bool]
|
||||
|
||||
func _ready() -> void:
|
||||
pressed = {
|
||||
"left cycle trap":false,
|
||||
"right cycle trap":false,
|
||||
"detonate":false,
|
||||
"detect":false,
|
||||
"lay trap":false,
|
||||
"attack":false
|
||||
}
|
||||
just_pressed = {
|
||||
"left cycle trap":false,
|
||||
"right cycle trap":false,
|
||||
"detonate":false,
|
||||
"detect":false,
|
||||
"lay trap":false,
|
||||
"attack":false
|
||||
}
|
||||
just_released = {
|
||||
"left cycle trap":false,
|
||||
"right cycle trap":false,
|
||||
"detonate":false,
|
||||
"detect":false,
|
||||
"lay trap":false,
|
||||
"attack":false
|
||||
}
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
var d = Input.get_vector("west", "east", "north", "south")
|
||||
dir = Vector3(d.x, 0, d.y)
|
||||
for key : String in pressed:
|
||||
if Input.is_action_pressed(key):
|
||||
just_pressed[key] = !pressed[key]
|
||||
just_released[key] = false
|
||||
pressed[key] = true
|
||||
else:
|
||||
just_released[key] = pressed[key]
|
||||
just_pressed[key] = false
|
||||
pressed[key] = false
|
||||
|
||||
func is_action_pressed(action : String) -> bool:
|
||||
return pressed.has(action) && pressed[action]
|
||||
|
||||
func is_action_just_pressed(action : String) -> bool:
|
||||
return just_pressed.has(action) && just_pressed[action]
|
||||
|
||||
func is_action_just_released(action : String) -> bool:
|
||||
return just_released.has(action) && just_released[action]
|
||||
Reference in New Issue
Block a user