2
2
* Title: Beatz
3
3
* Author: Victor//GuayabR
4
4
* Date: 16/05/2024
5
- * Version: MOBILE 4.3.3.3 test (release.version.subversion.bugfix)
5
+ * Version: MOBILE 4.3.5.5 test (release.version.subversion.bugfix)
6
6
* GitHub Repository: https://github.com/GuayabR/Beatz
7
7
**/
8
8
9
9
// CONSTANTS
10
10
11
11
const userDevice = detectDeviceType ( ) ;
12
12
13
- const VERSION = "MOBILE 4.3.3.3 " ;
13
+ const VERSION = "MOBILE 4.3.5.5 " ;
14
14
var PUBLICVERSION = `4.3! (${ userDevice } Port)` ;
15
15
console . log ( "Version: " + VERSION ) ;
16
16
@@ -609,7 +609,8 @@ function preloadSongs() {
609
609
"https://guayabr.github.io/Beatz/Resources/Songs/VVV.mp3" ,
610
610
"https://guayabr.github.io/Beatz/Resources/Songs/Magic Touch.mp3" ,
611
611
"https://guayabr.github.io/Beatz/Resources/Songs/Uptown Funk.mp3" ,
612
- "https://guayabr.github.io/Beatz/Resources/Songs/Lunar Abyss.mp3"
612
+ "https://guayabr.github.io/Beatz/Resources/Songs/Lunar Abyss.mp3" ,
613
+ "https://guayabr.github.io/Beatz/Resources/Songs/Lost.mp3"
613
614
] ;
614
615
} else {
615
616
console . log ( `Loading songs locally, fetching: ${ useFetch } ` ) ;
@@ -721,6 +722,7 @@ function preloadSongs() {
721
722
"Resources/Songs/Magic Touch.mp3" ,
722
723
"Resources/Songs/Uptown Funk.mp3" ,
723
724
"Resources/Songs/Lunar Abyss.mp3" ,
725
+ "Resources/Songs/Lost.mp3" ,
724
726
725
727
"Resources/Songs/testingsong.mp3"
726
728
] ;
@@ -953,6 +955,7 @@ const songConfigs = {
953
955
"Magic Touch" : { BPM : 127 , noteSpeed : 12 } ,
954
956
"Uptown Funk" : { BPM : 115 , noteSpeed : 12 } ,
955
957
"Lunar Abyss" : { BPM : 138 , noteSpeed : 10 } ,
958
+ Lost : { BPM : 105 , noteSpeed : 12 } ,
956
959
957
960
// Song Versions
958
961
"Finesse (feat. Cardi B)" : { BPM : 105 , noteSpeed : 22 } ,
@@ -1224,6 +1227,7 @@ function getDynamicSpeed(songSrc) {
1224
1227
{ timestamp : 222 , noteSpeed : 8 , notes : [ ] } ,
1225
1228
{ timestamp : 222.72 , noteSpeed : 8 , endScreenDrawn : true }
1226
1229
] ,
1230
+ Lost : [ { timestamp : 187.545 , noteSpeed : 12 , endScreenDrawn : true } ] ,
1227
1231
testingsong : [
1228
1232
{ timestamp : 1 , noteSpeed : 10 } ,
1229
1233
{ timestamp : 2 , noteSpeed : 10 , BPM : BPM * 2 } ,
@@ -1348,6 +1352,7 @@ const songToAlbumMap = {
1348
1352
"Magic Touch" : "Magic Touch" ,
1349
1353
"Uptown Funk" : "Uptown Special" ,
1350
1354
"Lunar Abyss" : "Lunar Abyss" ,
1355
+ Lost : "Meteora 20'" ,
1351
1356
1352
1357
// Song Versions
1353
1358
@@ -1447,6 +1452,7 @@ function preloadImages() {
1447
1452
"Resources/Covers/Magic Touch.jpg" ,
1448
1453
"Resources/Covers/Uptown Special.jpg" ,
1449
1454
"Resources/Covers/Lunar Abyss.jpg" ,
1455
+ "Resources/Covers/Meteora 20'.jpg" ,
1450
1456
1451
1457
// Song Versions
1452
1458
@@ -1673,8 +1679,16 @@ function filterSongs() {
1673
1679
let resultsCount = 0 ;
1674
1680
let firstVisibleButton = null ; // To store the first visible song button
1675
1681
1676
- // Find the last song index
1677
- const lastSongIndex = songList . length ;
1682
+ // Check if the last song in the songList is "Resources/Songs/testingsong.mp3"
1683
+ let lastSongIndex ;
1684
+
1685
+ // If the last song is "Resources/Songs/testingsong.mp3", set lastSongIndex to songList.length - 1
1686
+ if ( songList [ songList . length - 1 ] === "Resources/Songs/testingsong.mp3" ) {
1687
+ lastSongIndex = songList . length - 1 ;
1688
+ } else {
1689
+ // Otherwise, set lastSongIndex to songList.length
1690
+ lastSongIndex = songList . length ;
1691
+ }
1678
1692
1679
1693
songButtons . forEach ( ( button ) => {
1680
1694
const songText = button . textContent . toLowerCase ( ) ;
@@ -1883,12 +1897,12 @@ document.getElementById("closeKeywordListModal").onclick = function () {
1883
1897
1884
1898
// Global cooldown management
1885
1899
let lastFunctionCallTime = 0 ;
1886
- const COOLDOWN_PERIOD = 100 ; // Cooldown period in milliseconds
1900
+ const COOLDOWN_PERIOD = 150 ; // Cooldown period in milliseconds
1887
1901
1888
1902
function canActivate ( ) {
1889
1903
const currentTime = Date . now ( ) ;
1890
1904
if ( currentTime - lastFunctionCallTime < COOLDOWN_PERIOD ) {
1891
- console . log ( "Cooldown in effect. Please wait before calling another function." ) ;
1905
+ logNotice ( "Cooldown in effect. Please wait before calling another function." , "" , 2250 ) ;
1892
1906
return false ;
1893
1907
}
1894
1908
lastFunctionCallTime = currentTime ;
@@ -2281,6 +2295,7 @@ function getArtist(songSrc) {
2281
2295
"Magic Touch" : "Romos" ,
2282
2296
"Uptown Funk" : "Mark Ronson, Bruno Mars" ,
2283
2297
"Lunar Abyss" : "Lchavasse" ,
2298
+ Lost : "Linkin Park" ,
2284
2299
2285
2300
// Song Versions
2286
2301
@@ -2491,6 +2506,8 @@ window.onload = function () {
2491
2506
} ) ;
2492
2507
} ;
2493
2508
2509
+ let canvasScalingInterval ;
2510
+
2494
2511
function togglePause ( ) {
2495
2512
if ( ! endScreenDrawn ) {
2496
2513
gamePaused = ! gamePaused ;
@@ -2499,6 +2516,7 @@ function togglePause() {
2499
2516
currentSong . pause ( ) ;
2500
2517
playSoundEffect ( "Resources/SFX/clickBtn2.mp3" , 0.5 ) ;
2501
2518
canvasUpdating = false ;
2519
+ clearInterval ( canvasScalingInterval ) ;
2502
2520
console . log ( "Game Paused" ) ;
2503
2521
} else {
2504
2522
let pauseDuration = Date . now ( ) - songPausedTime ;
@@ -2507,11 +2525,77 @@ function togglePause() {
2507
2525
lastTime += pauseDuration ; // Adjust lastTime to prevent jump in timeDelta
2508
2526
canvasUpdating = true ;
2509
2527
updateCanvas ( globalTimestamp ) ;
2528
+
2529
+ manageCanvasScalingInterval ( true ) ; // Start interval when game is unpaused
2530
+
2510
2531
console . log ( "Game Unpaused" ) ;
2511
2532
}
2512
2533
}
2513
2534
}
2514
2535
2536
+ function fallbackPause ( ) {
2537
+ if ( ! endScreenDrawn ) {
2538
+ currentSong . pause ( ) ;
2539
+ playSoundEffect ( "Resources/SFX/hoverBtn.mp3" , 0.5 ) ;
2540
+ canvasUpdating = false ;
2541
+ clearInterval ( canvasScalingInterval ) ;
2542
+ }
2543
+ }
2544
+
2545
+ function manageCanvasScalingInterval ( startInterval ) {
2546
+ clearInterval ( canvasScalingInterval ) ; // Clear any existing interval
2547
+
2548
+ if ( startInterval && pulseOnBPM ) {
2549
+ let scaleUpDuration , scaleDownDuration , waitTime ;
2550
+
2551
+ // Determine animation durations based on BPM
2552
+ if ( BPM < 200 ) {
2553
+ scaleUpDuration = 0.11 ; // Scaling up duration for BPM < 200
2554
+ scaleDownDuration = 0.18 ; // Scaling down duration for BPM < 200
2555
+ waitTime = 4.2 ;
2556
+ } else if ( BPM >= 200 && BPM < 250 ) {
2557
+ scaleUpDuration = 0.15 ; // Scaling up duration for 200 <= BPM < 250
2558
+ scaleDownDuration = 0.2 ; // Scaling down duration for 200 <= BPM < 250
2559
+ waitTime = 2.2 ;
2560
+ } else if ( BPM >= 250 ) {
2561
+ scaleUpDuration = 0.1 ; // Scaling up duration for BPM >= 250
2562
+ scaleDownDuration = 0.15 ; // Scaling down duration for BPM >= 250
2563
+ waitTime = 3 ;
2564
+ }
2565
+
2566
+ const img = document . getElementById ( "songCoverImage" ) ;
2567
+ const musicIco = document . getElementById ( "bouncingIcon" ) ;
2568
+
2569
+ // Create a new interval for scaling the canvas and pulsing the title color
2570
+ canvasScalingInterval = setInterval ( ( ) => {
2571
+ // Apply cubic-bezier easing for scaling up
2572
+ title . style . transition = `transform ${ scaleUpDuration } s cubic-bezier(0.17, 0.71, 0.51, 0.94), color ${ MILLISECONDS_PER_BEAT / 25000 } s` ;
2573
+ title . style . transform = "scale(1.03)" ;
2574
+ title . style . color = getRandomColor ( ) ; // Change to a random color
2575
+
2576
+ img . style . transition = `transform ${ scaleUpDuration } s cubic-bezier(0.17, 0.71, 0.51, 0.94)` ;
2577
+ img . style . transform = "scale(1.025)" ;
2578
+
2579
+ musicIco . style . transition = `transform ${ scaleUpDuration } s cubic-bezier(0.17, 0.71, 0.51, 0.94)` ;
2580
+ musicIco . style . transform = "scale(1.4)" ;
2581
+
2582
+ // Set a timeout to scale back down after the up animation
2583
+ setTimeout ( ( ) => {
2584
+ // Apply ease-in easing for scaling down
2585
+ title . style . transition = `transform ${ scaleDownDuration } s ease-in, color ${ MILLISECONDS_PER_BEAT / 1000 } s` ;
2586
+ title . style . transform = "scale(1)" ;
2587
+ title . style . color = "white" ;
2588
+
2589
+ img . style . transition = `transform ${ scaleDownDuration } s ease-in` ;
2590
+ img . style . transform = "scale(1)" ;
2591
+
2592
+ musicIco . style . transition = `transform ${ scaleDownDuration } s ease-in` ;
2593
+ musicIco . style . transform = "scale(1)" ;
2594
+ } , MILLISECONDS_PER_BEAT / waitTime ) ; // Wait to scale down
2595
+ } , MILLISECONDS_PER_BEAT ) ;
2596
+ }
2597
+ }
2598
+
2515
2599
function formatTimestampDS ( seconds ) {
2516
2600
if ( seconds < 60 ) {
2517
2601
// Format as SS.ss for timestamps less than 60 seconds
@@ -2630,64 +2714,7 @@ function startGame(index, versionPath, setIndex) {
2630
2714
right : [ ]
2631
2715
} ;
2632
2716
2633
- let scaleUp = true ; // Variable to track scaling direction
2634
-
2635
- // Clear any existing interval if there is one
2636
- if ( typeof canvasScalingInterval !== "undefined" ) {
2637
- clearInterval ( canvasScalingInterval ) ;
2638
- }
2639
-
2640
- // Only proceed if pulseOnBPM is true
2641
- if ( pulseOnBPM ) {
2642
- // Determine animation durations based on BPM
2643
- let scaleUpDuration , scaleDownDuration , waitTime ;
2644
- if ( BPM < 200 ) {
2645
- scaleUpDuration = 0.11 ; // Scaling up duration for BPM < 200
2646
- scaleDownDuration = 0.18 ; // Scaling down duration for BPM < 200
2647
- waitTime = 4.2 ;
2648
- } else if ( BPM >= 200 && BPM < 250 ) {
2649
- scaleUpDuration = 0.15 ; // Scaling up duration for 200 <= BPM < 250
2650
- scaleDownDuration = 0.2 ; // Scaling down duration for 200 <= BPM < 250
2651
- waitTime = 2.2 ;
2652
- } else if ( BPM >= 250 ) {
2653
- scaleUpDuration = 0.1 ; // Scaling up duration for BPM >= 250
2654
- scaleDownDuration = 0.15 ; // Scaling down duration for BPM >= 250
2655
- waitTime = 3 ;
2656
- }
2657
-
2658
- const img = document . getElementById ( "songCoverImage" ) ;
2659
- const musicIco = document . getElementById ( "bouncingIcon" ) ;
2660
-
2661
- // Create a new interval for scaling the canvas and pulsing the title color
2662
- canvasScalingInterval = setInterval ( ( ) => {
2663
- if ( scaleUp ) {
2664
- // Apply cubic-bezier easing for scaling up
2665
- title . style . transition = `transform ${ scaleUpDuration } s cubic-bezier(0.17, 0.71, 0.51, 0.94), color ${ MILLISECONDS_PER_BEAT / 25000 } s` ;
2666
- title . style . transform = "scale(1.03)" ;
2667
- title . style . color = getRandomColor ( ) ; // Change to a random color
2668
-
2669
- img . style . transition = `transform ${ scaleUpDuration } s cubic-bezier(0.17, 0.71, 0.51, 0.94)` ;
2670
- img . style . transform = "scale(1.025)" ;
2671
-
2672
- musicIco . style . transition = `transform ${ scaleUpDuration } s cubic-bezier(0.17, 0.71, 0.51, 0.94)` ;
2673
- musicIco . style . transform = "scale(1.4)" ;
2674
-
2675
- // Set a timeout to scale back down after the up animation
2676
- setTimeout ( ( ) => {
2677
- // Apply ease-in easing for scaling down
2678
- title . style . transition = `transform ${ scaleDownDuration } s ease-in, color ${ MILLISECONDS_PER_BEAT / 1000 } s` ;
2679
- title . style . transform = "scale(1)" ;
2680
- title . style . color = "white" ;
2681
-
2682
- img . style . transition = `transform ${ scaleDownDuration } s ease-in` ;
2683
- img . style . transform = "scale(1)" ;
2684
-
2685
- musicIco . style . transition = `transform ${ scaleDownDuration } s ease-in` ;
2686
- musicIco . style . transform = "scale(1)" ;
2687
- } , MILLISECONDS_PER_BEAT / waitTime ) ; // Wait to scale down
2688
- }
2689
- } , MILLISECONDS_PER_BEAT ) ;
2690
- }
2717
+ manageCanvasScalingInterval ( true ) ;
2691
2718
2692
2719
const songTitle = getSongTitle ( currentSongPath ) ;
2693
2720
const songConfig = getDynamicSpeed ( currentSongPath ) ;
@@ -2801,7 +2828,7 @@ function startGame(index, versionPath, setIndex) {
2801
2828
2802
2829
// Update the page title
2803
2830
indexToDisplay = setIndex >= 0 ? setIndex : currentSongIndex ;
2804
- document . title = `Song ${ indexToDisplay + 1 } : ${ getSongTitle ( currentSongPath ) } | Beatz Testing 4.3!` ;
2831
+ document . title = `Song ${ indexToDisplay + 1 } : ${ getSongTitle ( currentSongPath ) } | Beatz 4.3!` ;
2805
2832
2806
2833
console . log ( `indexToDisplay converted in startGame: ${ indexToDisplay } ` ) ;
2807
2834
} ;
@@ -3120,7 +3147,6 @@ function updateCanvas(timestamp, setIndex) {
3120
3147
3121
3148
if ( gamePaused ) {
3122
3149
// Calculate the time difference between frames
3123
- let timeDelta = ( timestamp - lastTime ) / 1000 ; // timeDelta in seconds
3124
3150
lastTime = timestamp ;
3125
3151
3126
3152
if ( ! pausedTextDrawn ) {
@@ -3337,6 +3363,40 @@ function updateCanvas(timestamp, setIndex) {
3337
3363
drawTapBoxes ( ) ;
3338
3364
}
3339
3365
3366
+ if ( getDynamicSpeed ( currentSongPath ) === null && nextSpeedChange !== "No speed changes." ) {
3367
+ // Fallback for overlapping dynamic speeds with no dynamic speed data.
3368
+ clearInterval ( speedUpdater ) ;
3369
+ console . log ( `Dynamic speeds encountered an "Overlap//Null" error. Speed updater cleared.` ) ;
3370
+ logError ( `Overlap//Null, Speed updater cleared.` ) ;
3371
+ } else {
3372
+ const dynamicSpeedsForSong = getDynamicSpeed ( currentSongPath ) ;
3373
+
3374
+ if ( dynamicSpeedsForSong !== null && nextSpeedChange === "No speed changes." ) {
3375
+ // If dynamic speeds are found for this song but next speed change is not recognized
3376
+ const nextSpeedExistsInDynamicSpeeds = dynamicSpeedsForSong . some ( ( speedObj ) => speedObj . noteSpeed === nextSpeedChange ) ;
3377
+
3378
+ if ( ! nextSpeedExistsInDynamicSpeeds ) {
3379
+ // Mismatch in dynamic speeds detected
3380
+ clearInterval ( speedUpdater ) ;
3381
+ console . log ( `Dynamic speeds encountered a "Mismatch//FoundNotCorrect" error. Pausing updates.` ) ;
3382
+ logError ( "Mismatch//FoundNotCorrect, Pausing updates and restarting song." , 10000 ) ;
3383
+ logNotice ( "Please notify @GuayabR on twitter for this error. https://x.com/@GuayabR " , "" , 10000 ) ;
3384
+ logNotice ( "Please specify what song you were playing and if this happened at the start of the song or at a specific timestamp." , "" , 10000 ) ;
3385
+ logNotice ( `Song: ${ getSongTitle ( currentSongPath ) } , Index: ${ currentSongIndex } ` , "" , 10000 ) ;
3386
+ logNotice ( `Dynamic speeds for ${ getSongTitle ( currentSongPath ) } : ${ dynamicSpeedInfo } ` , "" , 10000 ) ;
3387
+ logNotice ( "Would be greatly appreciated! Thanks for playing Beatz!" , "" , 10000 ) ;
3388
+
3389
+ // Stop canvas updates for 1 second
3390
+ setTimeout ( ( ) => {
3391
+ // Restart the song after 1 second
3392
+ restartSong ( ) ;
3393
+ } , 1000 ) ;
3394
+
3395
+ fallbackPause ( ) ; // Exit to avoid further canvas updates
3396
+ }
3397
+ }
3398
+ }
3399
+
3340
3400
if ( FPS <= 32 ) {
3341
3401
PERFECT_HIT_RANGE_MIN = 534 ;
3342
3402
PERFECT_HIT_RANGE_MAX = 576 ;
0 commit comments