added SprintoMeter
This commit is contained in:
parent
4985642acb
commit
daec7a7238
@ -15,15 +15,19 @@ const ACCEL = 15.0
|
||||
const MAX_SLOPE_ANGLE = 40
|
||||
const MOUSE_SENSITIVITY = 0.05
|
||||
const INTERACT_DISTANCE = 4
|
||||
const SPRINT_DEC = 0.015;
|
||||
const SPRINT_ACC = 0.0015;
|
||||
|
||||
# private members
|
||||
var _body: Spatial
|
||||
var _camera: Camera
|
||||
var _animation: AnimationPlayer
|
||||
var _interface: Control
|
||||
var _dir = Vector3();
|
||||
var _vel = Vector3();
|
||||
var _is_sprinting;
|
||||
var _sprintometer: ProgressBar
|
||||
var _dir = Vector3()
|
||||
var _vel = Vector3()
|
||||
var _is_sprinting
|
||||
var _sprintVal: float = 100
|
||||
|
||||
|
||||
func _ready():
|
||||
@ -40,6 +44,9 @@ func _ready():
|
||||
_interface = get_node(ui_nodepath) as Control
|
||||
assert(null != _interface)
|
||||
|
||||
_sprintometer = _interface.get_node("ProgressBar")
|
||||
assert(null != _sprintometer)
|
||||
|
||||
# Setup mouse look
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
@ -48,10 +55,15 @@ func _physics_process(delta):
|
||||
_process_input()
|
||||
_process_movement(delta)
|
||||
_process_collision()
|
||||
#Logger.info("sprintVal: " + String(_sprintVal))
|
||||
|
||||
|
||||
func _process(_delta):
|
||||
func _process(delta):
|
||||
_process_animations()
|
||||
if _is_sprinting and _sprintVal > 0:
|
||||
_sprintVal -= SPRINT_DEC / delta
|
||||
elif _sprintVal < 100:
|
||||
_sprintVal += SPRINT_ACC / delta
|
||||
|
||||
|
||||
func _process_input():
|
||||
@ -81,7 +93,7 @@ func _process_input():
|
||||
_vel.y = JUMP_SPEED
|
||||
|
||||
# sprinting
|
||||
_is_sprinting = Input.is_action_pressed("move_sprint")
|
||||
_is_sprinting = Input.is_action_pressed("move_sprint") and _sprintVal > SPRINT_DEC
|
||||
|
||||
|
||||
func _process_movement(delta):
|
||||
@ -100,6 +112,8 @@ func _process_movement(delta):
|
||||
func _process_animations():
|
||||
_animation.playback_speed = _vel.length() / MOVE_SPEED
|
||||
|
||||
_sprintometer.value = _sprintVal
|
||||
|
||||
|
||||
func _process_collision():
|
||||
var collCount = get_slide_count()
|
||||
|
@ -128,4 +128,12 @@ margin_top = 144.902
|
||||
margin_right = 179.505
|
||||
margin_bottom = 181.902
|
||||
text = "play again"
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="HUD"]
|
||||
margin_left = 410.651
|
||||
margin_top = 560.551
|
||||
margin_right = 614.651
|
||||
margin_bottom = 582.551
|
||||
step = 1.0
|
||||
value = 100.0
|
||||
[connection signal="pressed" from="HUD/PopupWon/Button" to="HUD" method="_on_Button_pressed"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user