Score screen logic
This commit is contained in:
parent
df1d8c5015
commit
7af9aca2f5
9 changed files with 93 additions and 2 deletions
26
hotline_miami.gd
Normal file
26
hotline_miami.gd
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var viewport_x_div: float
|
||||||
|
@export var viewport_y_div: float
|
||||||
|
@export var x_offset: float = 0.0
|
||||||
|
|
||||||
|
var sway_amplitude = 20
|
||||||
|
var sway_speed = 1.0
|
||||||
|
var tilt_amplitude = 0.1
|
||||||
|
var tilt_lerp_speed = 5.0
|
||||||
|
|
||||||
|
var time := 0.0
|
||||||
|
var base_position := Vector2.ZERO
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
var viewport_size = get_viewport_rect().size
|
||||||
|
base_position = Vector2(viewport_size.x / viewport_x_div + x_offset, viewport_size.y / viewport_y_div)
|
||||||
|
position = base_position
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
time += delta
|
||||||
|
var sway_offset = sin(time * sway_speed) * sway_amplitude
|
||||||
|
position.x = base_position.x + sway_offset
|
||||||
|
var sway_velocity = cos(time * sway_speed) * sway_speed
|
||||||
|
var target_rotation = clamp(sway_velocity * tilt_amplitude, -tilt_amplitude, tilt_amplitude)
|
||||||
|
rotation = lerp(rotation, target_rotation, delta * tilt_lerp_speed)
|
||||||
1
hotline_miami.gd.uid
Normal file
1
hotline_miami.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bmn6cds78753q
|
||||||
BIN
loss.ogg
Normal file
BIN
loss.ogg
Normal file
Binary file not shown.
19
loss.ogg.import
Normal file
19
loss.ogg.import
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://b5r5846lmi31v"
|
||||||
|
path="res://.godot/imported/loss.ogg-a53eed42c0a67db7c9fc2938cae26881.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://loss.ogg"
|
||||||
|
dest_files=["res://.godot/imported/loss.ogg-a53eed42c0a67db7c9fc2938cae26881.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
16
score_screen.gd
Normal file
16
score_screen.gd
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
win()
|
||||||
|
|
||||||
|
func win():
|
||||||
|
$MorshoReactManager/MorshoHappy.visible = true
|
||||||
|
$MorshoReactManager/MorshoAngry.visible = false
|
||||||
|
%WinLossAudioPlayer.stream = load("res://win.ogg")
|
||||||
|
%WinLossAudioPlayer.play()
|
||||||
|
|
||||||
|
func lose():
|
||||||
|
$MorshoReactManager/MorshoAngry.visible = true
|
||||||
|
$MorshoReactManager/MorshoHappy.visible = false
|
||||||
|
%WinLossAudioPlayer.stream = load("res://loss.ogg")
|
||||||
|
%WinLossAudioPlayer.play()
|
||||||
1
score_screen.gd.uid
Normal file
1
score_screen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://cp71ivjeuuaaf
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://bcnpjrwddi5h8"]
|
[gd_scene load_steps=6 format=3 uid="uid://bcnpjrwddi5h8"]
|
||||||
|
|
||||||
[ext_resource type="Theme" uid="uid://d2rlcffg7nguy" path="res://menus.tres" id="1_3r2db"]
|
[ext_resource type="Theme" uid="uid://d2rlcffg7nguy" path="res://menus.tres" id="1_3r2db"]
|
||||||
|
[ext_resource type="Script" uid="uid://cp71ivjeuuaaf" path="res://score_screen.gd" id="1_cyy7t"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cabsfveh1oc6i" path="res://assets/menus/final score/morshu-happy-large.png" id="1_juxjb"]
|
[ext_resource type="Texture2D" uid="uid://cabsfveh1oc6i" path="res://assets/menus/final score/morshu-happy-large.png" id="1_juxjb"]
|
||||||
[ext_resource type="Texture2D" uid="uid://d24dlalqmr6r0" path="res://assets/menus/final score/morshu-anger-large.png" id="2_3r2db"]
|
[ext_resource type="Texture2D" uid="uid://d24dlalqmr6r0" path="res://assets/menus/final score/morshu-anger-large.png" id="2_3r2db"]
|
||||||
|
[ext_resource type="Script" uid="uid://bmn6cds78753q" path="res://hotline_miami.gd" id="4_joumd"]
|
||||||
|
|
||||||
[node name="Node2D" type="Node2D"]
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_cyy7t")
|
||||||
|
|
||||||
[node name="Control" type="Control" parent="."]
|
[node name="Control" type="Control" parent="."]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
|
|
@ -37,9 +40,12 @@ horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
|
|
||||||
[node name="MorshoReactManager" type="Node2D" parent="."]
|
[node name="MorshoReactManager" type="Node2D" parent="."]
|
||||||
|
texture_filter = 1
|
||||||
position = Vector2(870, 360)
|
position = Vector2(870, 360)
|
||||||
rotation = 0.20420352
|
|
||||||
scale = Vector2(2.5, 2.5)
|
scale = Vector2(2.5, 2.5)
|
||||||
|
script = ExtResource("4_joumd")
|
||||||
|
viewport_x_div = 1.5
|
||||||
|
viewport_y_div = 2.0
|
||||||
|
|
||||||
[node name="MorshoHappy" type="Sprite2D" parent="MorshoReactManager"]
|
[node name="MorshoHappy" type="Sprite2D" parent="MorshoReactManager"]
|
||||||
texture = ExtResource("1_juxjb")
|
texture = ExtResource("1_juxjb")
|
||||||
|
|
@ -47,3 +53,6 @@ texture = ExtResource("1_juxjb")
|
||||||
[node name="MorshoAngry" type="Sprite2D" parent="MorshoReactManager"]
|
[node name="MorshoAngry" type="Sprite2D" parent="MorshoReactManager"]
|
||||||
visible = false
|
visible = false
|
||||||
texture = ExtResource("2_3r2db")
|
texture = ExtResource("2_3r2db")
|
||||||
|
|
||||||
|
[node name="WinLossAudioPlayer" type="AudioStreamPlayer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
|
|
||||||
BIN
win.ogg
Normal file
BIN
win.ogg
Normal file
Binary file not shown.
19
win.ogg.import
Normal file
19
win.ogg.import
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="oggvorbisstr"
|
||||||
|
type="AudioStreamOggVorbis"
|
||||||
|
uid="uid://2g0mcrbwnkfc"
|
||||||
|
path="res://.godot/imported/win.ogg-925680d4a92658a999b17dd5ae4db057.oggvorbisstr"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://win.ogg"
|
||||||
|
dest_files=["res://.godot/imported/win.ogg-925680d4a92658a999b17dd5ae4db057.oggvorbisstr"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
loop=false
|
||||||
|
loop_offset=0
|
||||||
|
bpm=0
|
||||||
|
beat_count=0
|
||||||
|
bar_beats=4
|
||||||
Loading…
Add table
Reference in a new issue