Repository navigation
Expand file tree
/
Copy pathmain.qml
More file actions
1818 lines (1680 loc) · 65.6 KB
/
Copy pathmain.qml
File metadata and controls
1818 lines (1680 loc) · 65.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2026 - Timo Könnecke <github.com/moWerk>
*
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 2.1 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick
import QtSensors
import Nemo.Ngf
import QtQuick.Shapes
import org.asteroid.controls
import org.asteroid.dodger
import Nemo.KeepAlive
Item {
id: root
anchors.fill: parent
visible: true
// --- Game Mechanics ---
property bool calibrating: false
property int calibrationTimer: 2
property bool comboActive: false
property int comboCount: 0
property bool debugMode: false
property bool gameOver: false
property bool invincible: false
property bool isGraceActive: false
property bool isInvincibleActive: false
property bool isShrinkActive: false
property bool isSlowMoActive: false
property bool isSpeedBoostActive: false
property real lastDodgeTime: 0
property int level: 1
property bool paused: false
property int score: 0
property real scoreMultiplier: 1.0
property int shield: balance.initialShield
property bool showingNow: false
property bool showingSurvive: false
property bool isAutoFireActive: false
property bool playerDying: false
property real deathProgress: 0.0
// --- Difficulty & Persistence ---
property string currentDifficulty: "Cadet Swerver"
property bool selectingDifficulty: true
// true whenever we are on any pre-game screen (not yet in active play)
readonly property bool inPreGame: selectingDifficulty || calibrating || showingNow || showingSurvive
// --- Game Over Screen Model ---
property var goModel: []
// --- Object Spawning and Pools ---
property var activeLaser: null
property var activeParticles: []
property var activePowerups: []
property var activeShots: []
property int asteroidCount: 0
property real asteroidDensity: balance.initialAsteroidDensity + (level - 1) * balance.asteroidDensityPerLevel
property var asteroidPool: []
property int asteroidPoolSize: 40
property int asteroidsPerLevel: balance.asteroidsPerLevel
property real largeAsteroidDensity: asteroidDensity / 3
property var largeAsteroidPool: []
property int largeAsteroidPoolSize: 10
property real lastAsteroidSpawn: 0
property real lastLargeAsteroidSpawn: 0
property real lastObjectSpawn: 0
property int spawnCooldown: Math.max(balance.minSpawnCooldown, balance.initialSpawnCooldown - (level - 1) * balance.spawnCooldownPerLevel)
// --- Visual and Timing Settings ---
property real baselineX: 0
property real dimsFactor: Dims.l(100) / 100
property real goScale: 1.2
property string flashColor: ""
property real lastFrameTime: 0
property real playerSpeed: balance.playerSensitivity
property real basePlayerSpeed: balance.playerSensitivity
property real preSlowSpeed: 0
property real savedScrollSpeed: 0
property real scrollSpeed: balance.initialScrollSpeed
// Spawn config — built once at root level, rebuilt by applyDifficulty
// when weightInvincibility changes between difficulties.
property var powerupTypes: [
{ type: "shield", weight: balance.weightShield },
{ type: "invincibility", weight: balance.weightInvincibility },
{ type: "speedBoost", weight: balance.weightSpeedBoost },
{ type: "scoreMultiplier", weight: balance.weightScoreMultiplier },
{ type: "slowMo", weight: balance.weightSlowMo },
{ type: "shrink", weight: balance.weightShrink },
{ type: "laserSwipe", weight: balance.weightLaserSwipe },
{ type: "autoFire", weight: balance.weightAutoFire },
]
// Gameplay tuning + difficulty presets live in Balance.qml
Balance { id: balance }
onPausedChanged: {
if (paused) {
savedScrollSpeed = scrollSpeed
scrollSpeed = 0
if (comboActive) {
comboMeterAnimation.pause()
}
comboHitboxAnimation.pause()
} else {
scrollSpeed = savedScrollSpeed
if (comboActive) {
comboMeterAnimation.resume()
}
if (scoreMultiplierTimer.running) {
comboHitboxAnimation.resume()
}
}
}
onGameOverChanged: {
if (gameOver) {
DodgerStorage.setHighScore(currentDifficulty, score)
DodgerStorage.setHighLevel(currentDifficulty, level)
clearPowerupBars()
// Build sorted leaderboard for the game over screen
var diffs = ["Cadet Swerver", "Captain Slipstreamer", "Commander Stardust", "Major Roadkill"]
var entries = []
for (var i = 0; i < diffs.length; i++) {
entries.push({
name: diffs[i],
score: DodgerStorage.highScore(diffs[i]),
level: DodgerStorage.highLevel(diffs[i])
})
}
entries.sort(function(a, b) { return b.score - a.score })
var model = []
model.push({ rowType: "current", name: currentDifficulty, score: score, level: level })
model.push({ rowType: "header", name: "", score: 0, level: 0 })
for (var j = 0; j < entries.length; j++) {
model.push({ rowType: "history", name: entries[j].name, score: entries[j].score, level: entries[j].level })
}
goModel = model
}
}
NonGraphicalFeedback {
id: feedback
event: "press"
}
// KeepAlive 1.2 API: DisplayBlanking is instantiable, not a singleton.
DisplayBlanking { id: displayBlanking }
Component {
id: progressBarComponent
Item {
id: progressBar
property real progress: 1.0
property string fillColor: "#FFD700"
property string bgColor: "#45220A"
property int duration: 0
width: dimsFactor * 28
height: dimsFactor * 2
Rectangle {
width: parent.width
height: parent.height
radius: dimsFactor * 1
color: bgColor
}
Rectangle {
id: fill
width: parent.width * progress
height: parent.height
color: fillColor
radius: dimsFactor * 1
}
Timer {
id: progressTimer
interval: 16
repeat: true
property real elapsed: 0
onTriggered: {
elapsed += interval
progress = Math.max(0, 1 - elapsed / duration)
if (progress <= 0) {
progressBar.destroy()
}
}
}
function startTimer() {
progressTimer.elapsed = 0
progressTimer.restart()
}
}
}
Timer {
id: gameTimer
interval: 16
running: !gameOver && !inPreGame
repeat: true
property real lastFps: 60
property var fpsHistory: []
property real lastFpsUpdate: 0
property real lastGraphUpdate: 0
property real smoothedX: 0
property real smoothingFactor: 0.5
onTriggered: {
var currentTime = Date.now()
var deltaTime = lastFrameTime > 0 ? (currentTime - lastFrameTime) / 1000 : 0.016
if (deltaTime > 0.033) deltaTime = 0.033
lastFrameTime = currentTime
updateGame(deltaTime)
if (!paused && !playerDying) {
var rawX = accelerometer.reading.x
smoothedX = smoothedX + smoothingFactor * (rawX - smoothedX)
var deltaX = (smoothedX - baselineX) * -2
var newX = playerContainer.x + deltaX * playerSpeed
playerContainer.x = Math.max(player.width / 2, Math.min(root.width - player.width / 2, newX))
}
if (debugMode) {
var currentFps = deltaTime > 0 ? 1 / deltaTime : 60
lastFps = currentFps
if (currentTime - lastFpsUpdate >= 500) {
lastFpsUpdate = currentTime
fpsDisplay.text = "FPS: " + Math.round(currentFps)
}
if (currentTime - lastGraphUpdate >= 500) {
lastGraphUpdate = currentTime
var tempHistory = fpsHistory.slice()
tempHistory.push(currentFps)
if (tempHistory.length > 10) tempHistory.shift()
fpsHistory = tempHistory
}
}
}
}
Timer {
id: graceTimer
interval: balance.gracePeriodMs
running: isGraceActive && !paused
repeat: false
onTriggered: {
isGraceActive = false
if (!isInvincibleActive) {
invincible = false
}
removePowerup("grace")
}
onRunningChanged: {
if (running && !paused) {
addPowerupBar("grace", balance.gracePeriodMs, "#FF69B4", "#8B374F")
}
}
}
Timer {
id: invincibilityTimer
interval: balance.invincibilityMs
running: isInvincibleActive && !paused
repeat: false
onTriggered: {
isInvincibleActive = false
if (!isGraceActive) {
invincible = false
}
removePowerup("invincibility")
}
}
Timer {
id: speedBoostTimer
interval: balance.speedBoostMs
running: isSpeedBoostActive && !paused
repeat: false
onTriggered: {
playerSpeed = balance.playerSensitivity
isSpeedBoostActive = false
removePowerup("speedBoost")
}
onRunningChanged: {
if (running && !paused) {
addPowerupBar("speedBoost", balance.speedBoostMs, "#FFFF00", "#8B8B00")
}
}
}
Timer {
id: scoreMultiplierTimer
interval: balance.scoreMultiplierMs
running: scoreMultiplier > 1.0 && !paused
repeat: false
onTriggered: {
scoreMultiplier = 1.0
removePowerup("scoreMultiplier")
}
onRunningChanged: {
if (running && !paused) {
addPowerupBar("scoreMultiplier", balance.scoreMultiplierMs, "#00CC00", "#006600")
}
}
}
Timer {
id: slowMoTimer
interval: balance.slowMoMs
running: isSlowMoActive && !paused
repeat: false
onTriggered: {
scrollSpeed = preSlowSpeed
savedScrollSpeed = preSlowSpeed
isSlowMoActive = false
removePowerup("slowMo")
}
onRunningChanged: {
if (running && !paused) {
addPowerupBar("slowMo", balance.slowMoMs, "#00FFFF", "#008B8B")
}
}
}
Timer {
id: shrinkTimer
interval: 100
running: isShrinkActive && !paused
repeat: true
property real elapsed: 0
onTriggered: {
elapsed += interval
var progress = Math.min(1.0, elapsed / balance.shrinkMs)
player.width = dimsFactor * 5 + (dimsFactor * 10 - dimsFactor * 5) * progress
player.height = dimsFactor * 5 + (dimsFactor * 10 - dimsFactor * 5) * progress
playerHitbox.width = dimsFactor * 7 + (dimsFactor * 14 - dimsFactor * 7) * progress
playerHitbox.height = dimsFactor * 7 + (dimsFactor * 14 - dimsFactor * 7) * progress
if (elapsed >= balance.shrinkMs) {
isShrinkActive = false
elapsed = 0
removePowerup("shrink")
stop()
}
}
onRunningChanged: {
if (!running && !paused) {
elapsed = 0
}
if (running && !paused) {
addPowerupBar("shrink", balance.shrinkMs, "#FFA500", "#8B5A00")
}
}
}
Timer {
id: calibrationCountdownTimer
interval: 1000
running: calibrating
repeat: true
property bool initializationDone: false
onTriggered: {
calibrationTimer--
if (calibrationTimer <= 0 && initializationDone) {
baselineX = accelerometer.reading.x
calibrating = false
showingNow = true
feedback.play()
preGame.playNow()
introTimer.phase = 1
introTimer.start()
}
}
}
Timer {
id: introTimer
interval: 1000
running: showingNow || showingSurvive
repeat: true
property int phase: showingNow ? 1 : showingSurvive ? 2 : 0
onTriggered: {
if (phase === 1) {
showingNow = false
showingSurvive = true
preGame.playSurvive()
phase = 2
} else if (phase === 2) {
showingSurvive = false
phase = 0
stop()
}
}
onRunningChanged: {
if (!running) {
phase = 0
}
}
}
Timer {
id: comboTimer
interval: balance.comboWindowMs
running: comboActive && !paused
repeat: false
onTriggered: {
comboCount = 0
comboActive = false
}
}
Timer {
id: autoFireTimer
interval: balance.autoFireMs / balance.autoFireShots
running: isAutoFireActive && !paused
repeat: true
property int shotCount: 0
onTriggered: {
if (shotCount < balance.autoFireShots) {
var shot = autoFireShotComponent.createObject(gameArea, {
"x": playerContainer.x + playerHitbox.x + playerHitbox.width / 2 - dimsFactor * 0.5,
"y": playerContainer.y + playerHitbox.y
})
activeShots.push(shot)
shotCount++
}
if (shotCount >= balance.autoFireShots) {
isAutoFireActive = false
shotCount = 0
stop()
removePowerup("autoFire")
}
}
onRunningChanged: {
if (running && !paused) {
addPowerupBar("autoFire", balance.autoFireMs, "#800080", "#4B004B")
shotCount = 0
}
}
}
// Drives the DeathShader 0→1 over 520ms matching Tile.qml death timing
NumberAnimation {
id: deathAnim
target: root
property: "deathProgress"
from: 0.0
to: 1.0
duration: 1000
easing.type: Easing.InCubic
onStopped: {
gameOver = true
playerDying = false
}
}
// Decelerates the field to a halt as the shader plays out
NumberAnimation {
id: deathScrollAnim
target: root
property: "scrollSpeed"
to: 0
duration: 1000
easing.type: Easing.OutCubic
}
Component {
id: comboParticleComponent
Text {
id: particleText
property int points: 1
text: "+" + points
color: {
if (points <= 10) return "#00CC00"
if (points <= 20) {
var t1 = (points - 10) / 10
var r = Math.round(0x00 + t1 * (0xFF - 0x00))
var g = Math.round(0xCC + t1 * (0xD7 - 0xCC))
var b = Math.round(0x00 + t1 * (0x00 - 0x00))
return Qt.rgba(r / 255, g / 255, b / 255, 1)
}
if (points <= 40) {
var t2 = (points - 20) / 20
var r = Math.round(0xFF + t2 * (0xFF - 0xFF))
var g = Math.round(0xD7 + t2 * (0x69 - 0xD7))
var b = Math.round(0x00 + t2 * (0xB4 - 0x00))
return Qt.rgba(r / 255, g / 255, b / 255, 1)
}
return "#FF69B4"
}
font.pixelSize: {
if (points <= 10) return dimsFactor * 4
if (points <= 20) {
var t1 = (points - 10) / 10
return (dimsFactor * 4 + t1 * (dimsFactor * 5 - dimsFactor * 4))
}
if (points <= 40) {
var t2 = (points - 20) / 20
return (dimsFactor * 5 + t2 * (dimsFactor * 6 - dimsFactor * 5))
}
if (points <= 100) {
var t3 = (points - 40) / 60
return (dimsFactor * 6 + t3 * (dimsFactor * 7 - dimsFactor * 6))
}
return dimsFactor * 7
}
z: 3
opacity: 1
SequentialAnimation {
id: particleAnimation
running: true
ParallelAnimation {
NumberAnimation {
target: particleText
property: "x"
to: x + (x < playerContainer.x ? -dimsFactor * 8 : dimsFactor * 8)
duration: 400
easing.type: Easing.OutCubic
}
NumberAnimation {
target: particleText
property: "y"
to: y - dimsFactor * 7
duration: 400
easing.type: Easing.OutCubic
}
}
ParallelAnimation {
NumberAnimation {
target: particleText
property: "y"
to: y + dimsFactor * 11
duration: 600
easing.type: Easing.Linear
}
NumberAnimation {
target: particleText
property: "opacity"
from: 1
to: 0
duration: 600
easing.type: Easing.Linear
}
}
onStopped: {
var index = activeParticles.indexOf(particleText)
if (index !== -1) {
activeParticles.splice(index, 1)
}
particleText.destroy()
}
}
Component.onCompleted: {
activeParticles.push(particleText)
if (activeParticles.length > 4) {
var oldestParticle = activeParticles.shift()
if (oldestParticle) {
oldestParticle.destroy()
}
}
}
}
}
Component {
id: laserSwipeComponent
Rectangle {
id: laserRect
width: root.width
height: dimsFactor * 1
color: "red"
x: 0
y: playerContainer ? playerContainer.y : root.height * 0.75
z: 2
visible: true
PropertyAnimation {
id: laserAnimation
target: laserRect
property: "y"
from: laserRect.y
to: -laserRect.height
duration: 1000
running: true
onStopped: {
if (root.activeLaser === laserRect) {
root.activeLaser = null
}
destroyTimer.start()
}
}
Timer {
id: destroyTimer
interval: 1
repeat: false
onTriggered: {
parent.destroy()
}
}
}
}
Component {
id: autoFireShotComponent
Rectangle {
width: dimsFactor * 1
height: dimsFactor * 5
color: "#800080"
z: 2
visible: true
property real speed: scrollSpeed * 5
}
}
Item {
id: gameArea
anchors.fill: parent
Rectangle {
anchors.fill: parent
color: "black"
}
Rectangle {
id: flashOverlay
anchors.fill: parent
color: flashColor ? flashColor : "transparent"
opacity: 0
visible: opacity > 0
property string flashColor: ""
function triggerFlash(color) {
flashColor = color
opacity = 0
flashAnimation.stop()
flashAnimation.start()
}
NumberAnimation {
id: flashAnimation
target: flashOverlay
property: "opacity"
from: 0.5
to: 0
duration: flashOverlay.flashColor === "#8B6914" || flashOverlay.flashColor === "#00FFFF" ? 6000 : 500
easing.type: Easing.OutQuad
}
}
Item {
id: gameContent
anchors.fill: parent
Item {
id: largeAsteroidContainer
width: parent.width
height: parent.height
z: 0
visible: !inPreGame
}
Item {
id: objectContainer
width: parent.width
height: parent.height
z: 0
visible: !inPreGame
}
Item {
id: playerContainer
x: root.width / 2
y: root.height * 0.75
z: 1
visible: !inPreGame
Image {
id: player
width: dimsFactor * 10
height: dimsFactor * 10
source: "file:///usr/share/asteroid-launcher/watchfaces-img/asteroid-logo.svg"
anchors.centerIn: parent
opacity: playerDying ? Math.max(0, 1.0 - deathProgress * 1.4) : 1.0
SequentialAnimation on opacity {
running: (isGraceActive || isInvincibleActive) && !root.paused
loops: Animation.Infinite
NumberAnimation { from: 1.0; to: 0.2; duration: 500; easing.type: Easing.InOutSine }
NumberAnimation { from: 0.2; to: 1.0; duration: 500; easing.type: Easing.InOutSine }
onStopped: {
player.opacity = 1.0
}
}
opacity: 1.0
SequentialAnimation on rotation {
running: speedBoostTimer.running && !root.paused
loops: Animation.Infinite
NumberAnimation { from: -5; to: 5; duration: 200; easing.type: Easing.InOutSine }
NumberAnimation { from: 5; to: -5; duration: 200; easing.type: Easing.InOutSine }
onStopped: {
player.rotation = 0
}
}
}
DeathShader {
id: deathShader
width: player.width * 5
height: player.height * 5
anchors.centerIn: parent
deathProgress: root.deathProgress
ringColor: "#FF4400"
}
Shape {
id: playerHitbox
width: dimsFactor * 14
height: dimsFactor * 14
anchors.centerIn: parent
visible: false
ShapePath {
strokeWidth: -1
fillColor: "transparent"
startX: dimsFactor * 7; startY: 0
PathLine { x: dimsFactor * 14; y: dimsFactor * 7 }
PathLine { x: dimsFactor * 7; y: dimsFactor * 14 }
PathLine { x: 0; y: dimsFactor * 7 }
PathLine { x: dimsFactor * 7; y: 0 }
}
}
Shape {
id: comboHitbox
width: dimsFactor * 40
height: dimsFactor * 40
anchors.centerIn: parent
visible: comboActive
opacity: 0.2
ShapePath {
strokeWidth: dimsFactor * 1
strokeColor: "#00CC00"
fillColor: "transparent"
startX: dimsFactor * 20; startY: dimsFactor * 10
PathLine { x: dimsFactor * 30; y: dimsFactor * 20 }
PathLine { x: dimsFactor * 20; y: dimsFactor * 30 }
PathLine { x: dimsFactor * 10; y: dimsFactor * 20 }
PathLine { x: dimsFactor * 20; y: dimsFactor * 10 }
}
SequentialAnimation on opacity {
id: comboHitboxAnimation
running: scoreMultiplierTimer.running && !root.paused
loops: Animation.Infinite
NumberAnimation { from: 0.2; to: 0.4; duration: 500; easing.type: Easing.InOutSine }
NumberAnimation { from: 0.4; to: 0.2; duration: 500; easing.type: Easing.InOutSine }
onStopped: {
comboHitbox.opacity = 0.2
}
}
}
}
Item {
id: progressBarsContainer
anchors {
top: parent.top
horizontalCenter: parent.horizontalCenter
topMargin: dimsFactor * 6
}
z: 4
visible: !gameOver && !inPreGame
Item {
id: levelProgressBar
width: dimsFactor * 28
height: dimsFactor * 2
anchors.horizontalCenter: parent.horizontalCenter
Rectangle {
width: parent.width
height: parent.height
radius: dimsFactor * 1
color: "#45220A"
}
Rectangle {
id: progressFill
width: (asteroidCount / asteroidsPerLevel) * parent.width
height: parent.height
color: "#FFD700"
radius: dimsFactor * 1
}
}
Column {
id: powerupBars
anchors {
top: levelProgressBar.bottom
topMargin: dimsFactor * 1
horizontalCenter: parent.horizontalCenter
}
spacing: dimsFactor * 1
}
}
Text {
id: levelNumber
text: level
color: "#dddddd"
font {
pixelSize: dimsFactor * 9
family: "Fyodor"
}
anchors {
top: root.top
horizontalCenter: parent.horizontalCenter
}
z: 4
visible: !gameOver && !inPreGame
}
Item {
id: shieldProgressBar
anchors {
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
bottomMargin: dimsFactor * 4
}
width: dimsFactor * 28
height: dimsFactor * 2
visible: !gameOver && !inPreGame
z: 4
Rectangle {
width: parent.width
height: parent.height
radius: dimsFactor * 1
color: "#002346"
}
Rectangle {
id: shieldFill
width: (shield / balance.maxShield) * parent.width
height: parent.height
color: "#0087FF"
radius: dimsFactor * 1
}
}
Text {
id: shieldText
text: shield === 1 ? "❤️" : shield
color: shield === 1 ? "red" : "#FFFFFF"
font {
pixelSize: dimsFactor * 8
family: "Fyodor"
}
anchors {
bottom: parent.bottom
horizontalCenter: parent.horizontalCenter
}
z: 4
visible: !gameOver && !inPreGame
}
Item {
id: scoreArea
z: 2
visible: !gameOver && !inPreGame
x: playerContainer.x + playerContainer.width / 2 - scoreText.width / 2
y: playerContainer.y + playerContainer.height + dimsFactor * 6
Rectangle {
id: comboMeter
property int maxWidth: dimsFactor * 13
height: dimsFactor * 1
width: 0
color: "green"
radius: height / 2
x: (scoreText.width - width) / 2
y: -height + dimsFactor * 1
SequentialAnimation {
id: comboMeterAnimation
running: comboActive && !root.paused
NumberAnimation {
target: comboMeter
property: "width"
from: 0
to: comboMeter.maxWidth
duration: 50
easing.type: Easing.Linear
}
NumberAnimation {
target: comboMeter
property: "width"
from: comboMeter.maxWidth
to: 0
duration: balance.comboWindowMs - 50
easing.type: Easing.Linear
}
onStopped: {
comboMeter.width = 0
}
}
}
Text {
id: scoreText
text: score
color: scoreMultiplierTimer.running ? "#00CC00" : "#dddddd"
font {
pixelSize: dimsFactor * 5
bold: scoreMultiplierTimer.running
}
}
}
// ── Pre-game screens (difficulty selection + calibration) ─────────
PreGamePage {
id: preGame
anchors.fill: parent
z: 4
dimsFactor: root.dimsFactor
goScale: root.goScale
selectingDifficulty: root.selectingDifficulty
calibrating: root.calibrating
calibrationTimer: root.calibrationTimer
showingNow: root.showingNow
showingSurvive: root.showingSurvive
onDieNowClicked: function(difficultyName) {
applyDifficulty(difficultyName)
root.calibrationTimer = 2
root.selectingDifficulty = false
root.calibrating = true
}
}
// ── Pause & Debug ─────────────────────────────────────────────────
Rectangle {
anchors.fill: parent
color: "black"
opacity: paused && !gameOver ? 0.65 : 0
visible: opacity > 0
Behavior on opacity {
NumberAnimation { duration: 250; easing.type: Easing.InOutQuad }
}
}
Text {
id: pauseText
text: "Paused"
color: "white"
font {
pixelSize: dimsFactor * 22
family: "Fyodor"
}
anchors.centerIn: parent
opacity: 0
visible: !gameOver && !inPreGame
Behavior on opacity {
NumberAnimation {
duration: 250
easing.type: Easing.InOutQuad
}
}
MouseArea {
anchors.fill: parent
enabled: !gameOver && !inPreGame
onClicked: {
paused = !paused
pauseText.opacity = paused ? 1.0 : 0.0
}
}
}