camera movement & music
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c5qbqj52kr0aw"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c5qbqj52kr0aw"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dhhnr3xkxbxlu" path="res://player.tscn" id="1_vonw3"]
|
||||
[ext_resource type="PackedScene" uid="uid://bsv3h2lpv7h77" path="res://virus.tscn" id="2_oi3di"]
|
||||
[ext_resource type="PackedScene" uid="uid://bldi3fw0vmlu3" path="res://music.tscn" id="3_oi3di"]
|
||||
|
||||
[node name="Level" type="Node2D"]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_vonw3")]
|
||||
position = Vector2(349, 283)
|
||||
|
||||
[node name="Virus" parent="." instance=ExtResource("2_oi3di")]
|
||||
position = Vector2(969, 289)
|
||||
position = Vector2(468, -3)
|
||||
|
||||
[node name="Node2D" parent="." instance=ExtResource("3_oi3di")]
|
||||
|
||||
33
growth/music.tscn
Normal file
33
growth/music.tscn
Normal file
@@ -0,0 +1,33 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bldi3fw0vmlu3"]
|
||||
|
||||
[ext_resource type="AudioStream" uid="uid://3uk0hyhq2i4y" path="res://assets/music/module-krypton-synthwave-cyberpunk-370784.mp3" id="1_5vxup"]
|
||||
[ext_resource type="Script" uid="uid://b3y321qsrrrdw" path="res://music_mixer.gd" id="1_w5q55"]
|
||||
[ext_resource type="AudioStream" uid="uid://dtojrcxtfvk4e" path="res://assets/music/workout-cyberpunk-music-348203.mp3" id="2_w5q55"]
|
||||
|
||||
[sub_resource type="AudioStreamInteractive" id="AudioStreamInteractive_lr66j"]
|
||||
clip_count = 2
|
||||
clip_0/name = &"Base"
|
||||
clip_0/stream = ExtResource("1_5vxup")
|
||||
clip_0/auto_advance = 0
|
||||
clip_1/name = &"Boss"
|
||||
clip_1/stream = ExtResource("2_w5q55")
|
||||
clip_1/auto_advance = 0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_khlsn"]
|
||||
|
||||
[node name="MusicMixer" type="Node2D"]
|
||||
script = ExtResource("1_w5q55")
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = SubResource("AudioStreamInteractive_lr66j")
|
||||
|
||||
[node name="BossArea" type="Area2D" parent="AudioStreamPlayer"]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="AudioStreamPlayer/BossArea"]
|
||||
scale = Vector2(50, 50)
|
||||
shape = SubResource("CircleShape2D_khlsn")
|
||||
|
||||
[connection signal="area_entered" from="AudioStreamPlayer/BossArea" to="." method="_on_boss_area_entered"]
|
||||
[connection signal="area_exited" from="AudioStreamPlayer/BossArea" to="." method="_on_boss_area_exited"]
|
||||
18
growth/music_mixer.gd
Normal file
18
growth/music_mixer.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
extends Node
|
||||
|
||||
func _ready() -> void:
|
||||
$AudioStreamPlayer.play()
|
||||
|
||||
|
||||
func _on_boss_area_entered(_body: Node2D) -> void:
|
||||
if $AudioStreamPlayer["parameters/switch_to_clip"] == "Boss":
|
||||
return
|
||||
|
||||
$AudioStreamPlayer["parameters/switch_to_clip"] = "-> Boss"
|
||||
|
||||
|
||||
func _on_boss_area_exited(_body: Node2D) -> void:
|
||||
if $AudioStreamPlayer["parameters/switch_to_clip"] == "Base":
|
||||
return
|
||||
|
||||
$AudioStreamPlayer["parameters/switch_to_clip"] = "-> Base"
|
||||
1
growth/music_mixer.gd.uid
Normal file
1
growth/music_mixer.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b3y321qsrrrdw
|
||||
@@ -1,4 +1,4 @@
|
||||
extends Node2D
|
||||
extends CharacterBody2D
|
||||
|
||||
# ActionState should probably be expandable to
|
||||
enum ActionState {None, Cycling, Firing, Charging}
|
||||
@@ -8,9 +8,11 @@ enum MoveState {Still, Moving, Dashing, Knockback}
|
||||
@export var dash_cooldown = 0.3
|
||||
@export var hand_size = 3
|
||||
|
||||
@onready var camera: Camera2D = %PlayerCamera
|
||||
@onready var sprite: AnimatedSprite2D = $PlayerSprite
|
||||
|
||||
var shield_active = true;
|
||||
var move_direction = Vector2.ZERO;
|
||||
var velocity = Vector2.ZERO # The player's movement vector.
|
||||
var target = Vector2.ZERO # The position of the player's cursor.
|
||||
|
||||
const drawpile = [];
|
||||
@@ -43,6 +45,14 @@ func update_move_direction():
|
||||
|
||||
func update_target_coords():
|
||||
target = get_viewport().get_mouse_position()
|
||||
var self_view_position = self.position - camera.position + screen_size / 2
|
||||
sprite.look_at(target - self_view_position)
|
||||
|
||||
func update_camera_position():
|
||||
if not camera:
|
||||
return;
|
||||
var camera_target = (target - screen_size / 2) / 4
|
||||
camera.position = camera.position.lerp(camera_target, 0.1)
|
||||
|
||||
func charge():
|
||||
# Charge attack
|
||||
@@ -106,6 +116,7 @@ func _ready():
|
||||
|
||||
func _process(delta):
|
||||
update_target_coords();
|
||||
update_camera_position();
|
||||
if (move_state != MoveState.Dashing):
|
||||
update_move_direction();
|
||||
|
||||
@@ -126,9 +137,8 @@ func _process(delta):
|
||||
move_state = MoveState.Moving;
|
||||
else:
|
||||
move_state = MoveState.Still;
|
||||
|
||||
position += velocity * delta
|
||||
position = position.clamp(Vector2.ZERO, screen_size)
|
||||
|
||||
move_and_slide();
|
||||
|
||||
# Handle action_state
|
||||
if Input.is_action_pressed("play_card"):
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dhhnr3xkxbxlu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b6lfgkrbmr8ee" path="res://player.gd" id="1_4flbx"]
|
||||
[ext_resource type="Texture2D" uid="uid://c764pu231ki6l" path="res://icon.svg" id="2_onrkg"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcvpult8xfit6" path="res://assets/icons/Nortoff_logo.png" id="2_onrkg"]
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_i3pqv"]
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_onrkg"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
@@ -14,17 +14,25 @@ animations = [{
|
||||
"speed": 5.0
|
||||
}]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_onrkg"]
|
||||
size = Vector2(126, 128)
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_i3pqv"]
|
||||
|
||||
[node name="Player" type="Node2D"]
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
collision_layer = 5
|
||||
collision_mask = 31
|
||||
motion_mode = 1
|
||||
script = ExtResource("1_4flbx")
|
||||
metadata/_edit_group_ = true
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
sprite_frames = SubResource("SpriteFrames_i3pqv")
|
||||
[node name="PlayerSprite" type="AnimatedSprite2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
scale = Vector2(0.1, 0.1)
|
||||
sprite_frames = SubResource("SpriteFrames_onrkg")
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
[node name="Hurtbox" type="CollisionShape2D" parent="."]
|
||||
scale = Vector2(2.5, 2.5)
|
||||
shape = SubResource("CircleShape2D_i3pqv")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
shape = SubResource("RectangleShape2D_onrkg")
|
||||
[node name="PlayerCamera" type="Camera2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
position_smoothing_enabled = true
|
||||
|
||||
Reference in New Issue
Block a user