Boost improvements
This commit is contained in:
parent
66ed42e3cb
commit
53e0e535f0
13 changed files with 199 additions and 7 deletions
|
|
@ -76,7 +76,7 @@ switch_weapons={
|
|||
"events": [Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":10,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
dash={
|
||||
boost={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":7,"pressure":0.0,"pressed":true,"script":null)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bauklhpieuivd"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://bauklhpieuivd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d0qswyhwbhdua" path="res://scripts/game.gd" id="1_u5sy4"]
|
||||
[ext_resource type="Texture2D" uid="uid://dtwo7g0ipc4k" path="res://textures/ship_1.png" id="1_uwrxv"]
|
||||
[ext_resource type="Script" uid="uid://bfxfkrkaebxk0" path="res://scripts/player.gd" id="1_yqjtg"]
|
||||
[ext_resource type="AudioStream" uid="uid://brqjxveo53kco" path="res://sounds/boost.mp3" id="2_iywne"]
|
||||
[ext_resource type="AudioStream" uid="uid://5tr30e1tmdp6" path="res://sounds/collision.mp3" id="2_lbhrr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dgng5vdhn6anc" path="res://scenes/asteroid.tscn" id="3_lnu2h"]
|
||||
[ext_resource type="AudioStream" uid="uid://b1ung55xg31l3" path="res://sounds/boost_finish.mp3" id="3_p57ef"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"]
|
||||
radius = 16.0
|
||||
|
|
@ -12,11 +15,18 @@ radius = 16.0
|
|||
radius = 20.0
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
script = ExtResource("1_u5sy4")
|
||||
|
||||
[node name="Player" type="RigidBody2D" parent="."]
|
||||
linear_damp = 6.247
|
||||
script = ExtResource("1_yqjtg")
|
||||
|
||||
[node name="Boost" type="AudioStreamPlayer" parent="Player"]
|
||||
stream = ExtResource("2_iywne")
|
||||
|
||||
[node name="BoostFinish" type="AudioStreamPlayer" parent="Player"]
|
||||
stream = ExtResource("3_p57ef")
|
||||
|
||||
[node name="Collision" type="AudioStreamPlayer" parent="Player"]
|
||||
stream = ExtResource("2_lbhrr")
|
||||
|
||||
|
|
@ -51,4 +61,20 @@ position = Vector2(-216, 134)
|
|||
[node name="Asteroid4" parent="." instance=ExtResource("3_lnu2h")]
|
||||
position = Vector2(-192, -427)
|
||||
|
||||
[node name="UI" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Control" type="Control" parent="UI"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="BoostText" type="Label" parent="UI/Control"]
|
||||
layout_mode = 0
|
||||
offset_right = 40.0
|
||||
offset_bottom = 24.0
|
||||
text = "BOOST: 100"
|
||||
|
||||
[connection signal="body_shape_entered" from="Player/Hitbox" to="Player" method="_on_hitbox_body_shape_entered"]
|
||||
|
|
|
|||
4
scripts/game.gd
Normal file
4
scripts/game.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
extends Node2D
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$UI/Control/BoostText.text = "BOOST: " + str($Player.boost)
|
||||
1
scripts/game.gd.uid
Normal file
1
scripts/game.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d0qswyhwbhdua
|
||||
|
|
@ -1,13 +1,35 @@
|
|||
extends RigidBody2D
|
||||
|
||||
var health = 1000
|
||||
var boost = 100
|
||||
var time_since_last_collision = 1
|
||||
var camera_shake_power = 0
|
||||
var boosting = false
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
$Camera.offset.x = randi_range(-camera_shake_power, camera_shake_power)
|
||||
$Camera.offset.y = randi_range(-camera_shake_power, camera_shake_power)
|
||||
|
||||
if boosting:
|
||||
if Input.is_action_pressed("boost"):
|
||||
boost -= delta * 40
|
||||
|
||||
if boost <= 0:
|
||||
boost = 0
|
||||
boosting = false
|
||||
$BoostFinish.play()
|
||||
else:
|
||||
boosting = false
|
||||
$BoostFinish.play()
|
||||
else:
|
||||
boost += delta * 25
|
||||
if boost > 100: boost = 100
|
||||
|
||||
$Boost.stop()
|
||||
if Input.is_action_just_pressed("boost") and (boost > 33):
|
||||
boosting = true
|
||||
$Boost.play()
|
||||
|
||||
if camera_shake_power > 0:
|
||||
camera_shake_power -= delta * 20
|
||||
|
||||
|
|
@ -22,12 +44,18 @@ func _physics_process(delta: float) -> void:
|
|||
|
||||
angular_velocity = deg_to_rad(180 * axis)
|
||||
|
||||
var new_velocity = transform.y * Input.get_axis("forward", "backward") * 512
|
||||
var final_speed = 512
|
||||
|
||||
if boosting:
|
||||
final_speed = 1024
|
||||
|
||||
# Slow down on collision and gradually speed up
|
||||
if time_since_last_collision < 1: final_speed *= (time_since_last_collision + 0.15) * 2
|
||||
|
||||
var new_velocity = transform.y * Input.get_axis("forward", "backward") * final_speed
|
||||
|
||||
if (new_velocity.length() > linear_velocity.length() - 12):
|
||||
linear_velocity = transform.y * Input.get_axis("forward", "backward") * 512
|
||||
if time_since_last_collision < 1:
|
||||
linear_velocity *= (time_since_last_collision + 0.15) * 2
|
||||
linear_velocity = new_velocity
|
||||
|
||||
|
||||
func _on_hitbox_body_shape_entered(body_rid: RID, body: Node2D, body_shape_index: int, local_shape_index: int) -> void:
|
||||
|
|
|
|||
19
sounds/2050_bass.mp3.import
Normal file
19
sounds/2050_bass.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://cdi7o5r4y3jpm"
|
||||
path="res://.godot/imported/2050_bass.mp3-c0e821cf8314cd27ac0ff57d7b69ce25.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/2050_bass.mp3"
|
||||
dest_files=["res://.godot/imported/2050_bass.mp3-c0e821cf8314cd27ac0ff57d7b69ce25.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
sounds/2050_drums.mp3.import
Normal file
19
sounds/2050_drums.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://dklt4lfyqp2c"
|
||||
path="res://.godot/imported/2050_drums.mp3-bb466a17b0f21890ffac6024700bc7fc.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/2050_drums.mp3"
|
||||
dest_files=["res://.godot/imported/2050_drums.mp3-bb466a17b0f21890ffac6024700bc7fc.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
sounds/2050_music.mp3.import
Normal file
19
sounds/2050_music.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://gf01n1oediuk"
|
||||
path="res://.godot/imported/2050_music.mp3-a0fe9e1226f9749db65bebe92870c677.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/2050_music.mp3"
|
||||
dest_files=["res://.godot/imported/2050_music.mp3-a0fe9e1226f9749db65bebe92870c677.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
sounds/boost.mp3.import
Normal file
19
sounds/boost.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://brqjxveo53kco"
|
||||
path="res://.godot/imported/boost.mp3-c798be6ee26d6992b2c525033a00927f.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/boost.mp3"
|
||||
dest_files=["res://.godot/imported/boost.mp3-c798be6ee26d6992b2c525033a00927f.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
BIN
sounds/boost_finish.mp3
Normal file
BIN
sounds/boost_finish.mp3
Normal file
Binary file not shown.
19
sounds/boost_finish.mp3.import
Normal file
19
sounds/boost_finish.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://b1ung55xg31l3"
|
||||
path="res://.godot/imported/boost_finish.mp3-c7f5fcd3886d94e59aec4bcb773c8e83.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/boost_finish.mp3"
|
||||
dest_files=["res://.godot/imported/boost_finish.mp3-c7f5fcd3886d94e59aec4bcb773c8e83.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
sounds/explode.mp3.import
Normal file
19
sounds/explode.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://bney1c4julhfk"
|
||||
path="res://.godot/imported/explode.mp3-779e98f8498469f1ae8daf592f8f81c5.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/explode.mp3"
|
||||
dest_files=["res://.godot/imported/explode.mp3-779e98f8498469f1ae8daf592f8f81c5.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
19
sounds/fire.mp3.import
Normal file
19
sounds/fire.mp3.import
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://y7lhonymtk3t"
|
||||
path="res://.godot/imported/fire.mp3-fc7cda2211bc9c4cfc0d66c7122cab14.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/fire.mp3"
|
||||
dest_files=["res://.godot/imported/fire.mp3-fc7cda2211bc9c4cfc0d66c7122cab14.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
Loading…
Reference in a new issue