Double jump? +Jump sound?
This commit is contained in:
parent
0e03ced3c6
commit
4256b2001f
BIN
assets/audio/jump.ogg
Normal file
BIN
assets/audio/jump.ogg
Normal file
Binary file not shown.
19
assets/audio/jump.ogg.import
Normal file
19
assets/audio/jump.ogg.import
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://de2e8sy4x724m"
|
||||||
|
path="res://.godot/imported/jump.ogg-09aff86a6f79a8fce2febb69902962cf.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/audio/jump.ogg"
|
||||||
|
dest_files=["res://.godot/imported/jump.ogg-09aff86a6f79a8fce2febb69902962cf.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
3
assets/test.tscn
Normal file
3
assets/test.tscn
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[gd_scene format=3 uid="uid://cuyws13lbkmxb"]
|
||||||
|
|
||||||
|
[node name="Test" type="Node2D"]
|
||||||
@ -7,10 +7,16 @@ const MOVE_SPEED := 8.0
|
|||||||
const ACCELLERATION := 30.0
|
const ACCELLERATION := 30.0
|
||||||
const DECELLERATION := 40.0
|
const DECELLERATION := 40.0
|
||||||
const JUMP_SPEED := 4.0
|
const JUMP_SPEED := 4.0
|
||||||
|
const MAX_NUMBER_OF_JUMPS := 2
|
||||||
|
|
||||||
var mouse_sensitivity := 0.005
|
var mouse_sensitivity := 0.005
|
||||||
var rotation_x := 0.0
|
var rotation_x := 0.0
|
||||||
var rotation_y := 0.0
|
var rotation_y := 0.0
|
||||||
var cameraMoveMode := false
|
var cameraMoveMode := false
|
||||||
|
var current_number_of_jumps := 0
|
||||||
|
|
||||||
|
var jump_sound = preload("res://assets/audio/jump.ogg")
|
||||||
|
var audio_player = AudioStreamPlayer.new()
|
||||||
|
|
||||||
@export var camera_path: NodePath
|
@export var camera_path: NodePath
|
||||||
@onready var cam: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
|
@onready var cam: Camera3D = get_node(camera_path) if camera_path != NodePath("") else null
|
||||||
@ -21,6 +27,9 @@ func _ready() -> void:
|
|||||||
angular_damp = 6.0
|
angular_damp = 6.0
|
||||||
contact_monitor = true
|
contact_monitor = true
|
||||||
max_contacts_reported = 4
|
max_contacts_reported = 4
|
||||||
|
add_child(audio_player)
|
||||||
|
audio_player.stream = jump_sound
|
||||||
|
audio_player.volume_db = -20
|
||||||
|
|
||||||
func _integrate_forces(state):
|
func _integrate_forces(state):
|
||||||
# Input as 2D vector
|
# Input as 2D vector
|
||||||
@ -55,8 +64,10 @@ func _integrate_forces(state):
|
|||||||
on_floor = true
|
on_floor = true
|
||||||
break
|
break
|
||||||
|
|
||||||
if on_floor and Input.is_action_just_pressed("ui_accept"):
|
if Input.is_action_just_pressed("ui_accept") and (on_floor or current_number_of_jumps == 1):
|
||||||
|
current_number_of_jumps = (current_number_of_jumps + 1) % 2
|
||||||
linear_velocity.y = JUMP_SPEED
|
linear_velocity.y = JUMP_SPEED
|
||||||
|
audio_player.play()
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user