Skip to content

Commit

Permalink
3.5.1.2 (10COM 3.5! 10/07/2024)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuayabR authored Jul 10, 2024
1 parent b8ff283 commit 3659c26
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 26 deletions.
86 changes: 76 additions & 10 deletions BeatzGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* Title: Beatz
* Author: Victor//GuayabR
* Date: 16/05/2024
* Version: 10COM 3.5.0.1 test (release.version.subversion.bugfix)
* Version: 10COM 3.5.1.2 test (release.version.subversion.bugfix)
**/

// CONSTANTS

const VERSION = "10COM 3.5.0.1 (Codename.Release.Version.Subversion.Bugfix)";
const PUBLICVERSION = "3.3! (GitHub Port)";
const VERSION = "10COM 3.5.1.2 (Codename.Release.Version.Subversion.Bugfix)";
const PUBLICVERSION = "3.5! (GitHub Port)";
console.log("Version: " + VERSION);

const canvas = document.getElementById("myCanvas");
Expand Down Expand Up @@ -421,6 +421,7 @@ function preloadSongs() {
const songListContainer = document.getElementById("songList");
const songButton = document.createElement("button");
songButton.className = "song-button";
const currentIndex = songList.indexOf(songPath) + 1; // Assuming songList is a zero-based array
songButton.textContent = `Song ${currentIndex}: ${songTitle}, by ${getArtist(songTitle)}`;
songButton.dataset.path = songPath; // Store song path as a data attribute
songListContainer.appendChild(songButton);
Expand Down Expand Up @@ -505,7 +506,7 @@ const songConfigs = {
"Resources/Songs/ARCANGEL.mp3": { BPM: 124, noteSpeed: 14 },
"Resources/Songs/TELEKINESIS.mp3": { BPM: 166, noteSpeed: 12 },
"Resources/Songs/Bleed it out.mp3": { BPM: 140, noteSpeed: 0 },
"Resources/Songs/Grenade.mp3": { BPM: 110, noteSpeed: 12 },
"Resources/Songs/Grenade.mp3": { BPM: 110, noteSpeed: 0 },
"Resources/Songs/24K Magic.mp3": { BPM: 107, noteSpeed: 15 },
"Resources/Songs/Finesse.mp3": { BPM: 105, noteSpeed: 22 },
};
Expand Down Expand Up @@ -555,6 +556,12 @@ function getDynamicSpeed(songSrc) {
{ timestamp: 157.4, noteSpeed: 18, notes: [] },
{ timestamp: 163.25, noteSpeed: 18, endScreenDrawn: true },
],
Grenade: [
{
timestamp: 3.95,
noteSpeed: 12,
},
],
Finesse: [{ timestamp: 4.85, noteSpeed: 14 }],
};

Expand Down Expand Up @@ -658,19 +665,76 @@ function preloadImages() {
const selectedSongModal = document.getElementById("selectedSongModal");
const songListModal = document.getElementById("songListModal");

function saveRecentSong(songPath, songTitle, songIndex, songArtist) {
localStorage.setItem("recentSongPath", songPath);
localStorage.setItem("recentSongTitle", songTitle);
localStorage.setItem("recentSongIndex", songIndex);
localStorage.setItem("recentSongArtist", songArtist);
}

// Load the most recent song from localStorage
function loadRecentSong() {
const recentSongPath = localStorage.getItem("recentSongPath");
const recentSongTitle = localStorage.getItem("recentSongTitle");
const recentSongIndex = localStorage.getItem("recentSongIndex");
const recentSongArtist = localStorage.getItem("recentSongArtist");
if (recentSongPath && recentSongTitle && recentSongIndex && recentSongArtist) {
return {
path: recentSongPath,
title: recentSongTitle,
index: recentSongIndex,
artist: recentSongArtist,
};
}
return null;
}

// Update the "Play most recent song" button text
function updateRecentSongButton() {
const recentSong = loadRecentSong();
const mostRecentButton = document.getElementById("mostRecent");
if (recentSong) {
mostRecentButton.textContent = `Play most recent song: #${recentSong.index}: ${recentSong.title}, by ${recentSong.artist}`;
mostRecentButton.style.display = "inline-block";
} else {
mostRecentButton.style.display = "none";
}
}

// Play the most recent song
function playRecentSong() {
const recentSong = loadRecentSong();
if (recentSong) {
const index = songList.findIndex(s => s === recentSong.path);
startGame(index);
songListModal.style.display = "none";
activateKeybinds();
} else {
alert("No recent song found.");
}
}

// Event listener for "Play most recent song" button
document.getElementById("mostRecent").addEventListener("click", playRecentSong);

// Update the recent song button on page load
window.addEventListener("load", updateRecentSongButton);

function openSelectedSongModal(songPath, songTitle) {
const song = songList.find(s => s === songPath);
if (song) {
const songIndex = songList.indexOf(songPath) + 1; // Assuming songList is a zero-based array
const songArtist = getArtist(songTitle);
document.getElementById("songTitle").textContent = songTitle;
document.getElementById("songArtist").textContent = getArtist(songTitle);
document.getElementById("songArtist").textContent = songArtist;
document.getElementById("songBPM").textContent = songConfigs[songPath]?.BPM || "BPM not available";

// Display cover image
const coverImageElement = document.getElementById("songCoverImage");
if (loadedImages.hasOwnProperty(songTitle)) {
coverImageElement.src = loadedImages[songTitle].src;
} else {
coverImageElement.src = "Resources/Covers/noCover.png"; // Default cover image path or placeholder
coverImageElement.src = "Resources/Covers/noCover.png"; // Placeholder cover image path
}

// Check if dynamic speeds are defined for the song
Expand All @@ -697,6 +761,8 @@ function openSelectedSongModal(songPath, songTitle) {
startGame(index);
document.getElementById("selectedSongModal").style.display = "none"; // Close modal after starting the game
activateKeybinds();
saveRecentSong(songPath, songTitle, songIndex, songArtist); // Save the recent song
updateRecentSongButton(); // Update the button text
});
}
}
Expand Down Expand Up @@ -1210,7 +1276,7 @@ function startGame(index) {
const nextConfig = songConfig[currentConfigIndex];
if (currentTime >= nextConfig.timestamp) {
noteSpeed = nextConfig.noteSpeed;
console.log(`Updated note speed to: ${noteSpeed} at timestamp: ${nextConfig.timestamp}`);
console.log(`Updated note speed to: ${noteSpeed} at timestamp: ${nextConfig.timestamp}`); // This logs, and speed still changes
if (nextConfig.notes) {
notes = nextConfig.notes;
console.log(`Updated notes at timestamp: ${nextConfig.timestamp}`);
Expand All @@ -1233,9 +1299,9 @@ function startGame(index) {
}
}, 1);
} else {
console.log(`No dynamic speed configuration for "${songTitle}"`);
dynamicSpeedInfo = "No dynamic speed configuration found.";
nextSpeedChange = "No speed changes.";
console.log(`No dynamic speed configuration for "${songTitle}"`); // This logs
dynamicSpeedInfo = "No dynamic speed configuration found."; // This does appear as not found
nextSpeedChange = "No speed changes."; // This does not reset
}

currentSong.play(); // Start playing the song immediately
Expand Down
3 changes: 2 additions & 1 deletion BeatzGameTesting.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ <h3>Note that i am NOT making any money on this game, i just code occasionally f
<h1 class="modal-title">Song List</h1>
</div>
<label for="songSearchInput">Search songs by keyword, index or artist.</label><br /><br />
<input type="text" id="songSearchInput" placeholder="Search..." />
<input type="text" id="songSearchInput" placeholder="Search..." /><br /><br />
<button type="button" id="mostRecent" class="most-recent-button" style="display: none">Play most recent song</button>
<div class="modal-body" id="songList">
<!-- Song buttons will be dynamically inserted here -->
</div>
Expand Down
86 changes: 76 additions & 10 deletions BeatzGameTesting.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* Title: Beatz
* Author: Victor//GuayabR
* Date: 16/05/2024
* Version: 10COM 3.5.0.1 test (release.version.subversion.bugfix)
* Version: 10COM 3.5.1.2 test (release.version.subversion.bugfix)
**/

// CONSTANTS

const VERSION = "10COM 3.5.0.1 (Codename.Release.Version.Subversion.Bugfix)";
const PUBLICVERSION = "3.3! (GitHub Port)";
const VERSION = "10COM 3.5.1.2 (Codename.Release.Version.Subversion.Bugfix)";
const PUBLICVERSION = "3.5! (GitHub Port)";
console.log("Version: " + VERSION);

const canvas = document.getElementById("myCanvas");
Expand Down Expand Up @@ -421,6 +421,7 @@ function preloadSongs() {
const songListContainer = document.getElementById("songList");
const songButton = document.createElement("button");
songButton.className = "song-button";
const currentIndex = songList.indexOf(songPath) + 1; // Assuming songList is a zero-based array
songButton.textContent = `Song ${currentIndex}: ${songTitle}, by ${getArtist(songTitle)}`;
songButton.dataset.path = songPath; // Store song path as a data attribute
songListContainer.appendChild(songButton);
Expand Down Expand Up @@ -505,7 +506,7 @@ const songConfigs = {
"Resources/Songs/ARCANGEL.mp3": { BPM: 124, noteSpeed: 14 },
"Resources/Songs/TELEKINESIS.mp3": { BPM: 166, noteSpeed: 12 },
"Resources/Songs/Bleed it out.mp3": { BPM: 140, noteSpeed: 0 },
"Resources/Songs/Grenade.mp3": { BPM: 110, noteSpeed: 12 },
"Resources/Songs/Grenade.mp3": { BPM: 110, noteSpeed: 0 },
"Resources/Songs/24K Magic.mp3": { BPM: 107, noteSpeed: 15 },
"Resources/Songs/Finesse.mp3": { BPM: 105, noteSpeed: 22 },
};
Expand Down Expand Up @@ -555,6 +556,12 @@ function getDynamicSpeed(songSrc) {
{ timestamp: 157.4, noteSpeed: 18, notes: [] },
{ timestamp: 163.25, noteSpeed: 18, endScreenDrawn: true },
],
Grenade: [
{
timestamp: 3.95,
noteSpeed: 12,
},
],
Finesse: [{ timestamp: 4.85, noteSpeed: 14 }],
};

Expand Down Expand Up @@ -658,19 +665,76 @@ function preloadImages() {
const selectedSongModal = document.getElementById("selectedSongModal");
const songListModal = document.getElementById("songListModal");

function saveRecentSong(songPath, songTitle, songIndex, songArtist) {
localStorage.setItem("recentSongPath", songPath);
localStorage.setItem("recentSongTitle", songTitle);
localStorage.setItem("recentSongIndex", songIndex);
localStorage.setItem("recentSongArtist", songArtist);
}

// Load the most recent song from localStorage
function loadRecentSong() {
const recentSongPath = localStorage.getItem("recentSongPath");
const recentSongTitle = localStorage.getItem("recentSongTitle");
const recentSongIndex = localStorage.getItem("recentSongIndex");
const recentSongArtist = localStorage.getItem("recentSongArtist");
if (recentSongPath && recentSongTitle && recentSongIndex && recentSongArtist) {
return {
path: recentSongPath,
title: recentSongTitle,
index: recentSongIndex,
artist: recentSongArtist,
};
}
return null;
}

// Update the "Play most recent song" button text
function updateRecentSongButton() {
const recentSong = loadRecentSong();
const mostRecentButton = document.getElementById("mostRecent");
if (recentSong) {
mostRecentButton.textContent = `Play most recent song: #${recentSong.index}: ${recentSong.title}, by ${recentSong.artist}`;
mostRecentButton.style.display = "inline-block";
} else {
mostRecentButton.style.display = "none";
}
}

// Play the most recent song
function playRecentSong() {
const recentSong = loadRecentSong();
if (recentSong) {
const index = songList.findIndex(s => s === recentSong.path);
startGame(index);
songListModal.style.display = "none";
activateKeybinds();
} else {
alert("No recent song found.");
}
}

// Event listener for "Play most recent song" button
document.getElementById("mostRecent").addEventListener("click", playRecentSong);

// Update the recent song button on page load
window.addEventListener("load", updateRecentSongButton);

function openSelectedSongModal(songPath, songTitle) {
const song = songList.find(s => s === songPath);
if (song) {
const songIndex = songList.indexOf(songPath) + 1; // Assuming songList is a zero-based array
const songArtist = getArtist(songTitle);
document.getElementById("songTitle").textContent = songTitle;
document.getElementById("songArtist").textContent = getArtist(songTitle);
document.getElementById("songArtist").textContent = songArtist;
document.getElementById("songBPM").textContent = songConfigs[songPath]?.BPM || "BPM not available";

// Display cover image
const coverImageElement = document.getElementById("songCoverImage");
if (loadedImages.hasOwnProperty(songTitle)) {
coverImageElement.src = loadedImages[songTitle].src;
} else {
coverImageElement.src = "Resources/Covers/noCover.png"; // Default cover image path or placeholder
coverImageElement.src = "Resources/Covers/noCover.png"; // Placeholder cover image path
}

// Check if dynamic speeds are defined for the song
Expand All @@ -697,6 +761,8 @@ function openSelectedSongModal(songPath, songTitle) {
startGame(index);
document.getElementById("selectedSongModal").style.display = "none"; // Close modal after starting the game
activateKeybinds();
saveRecentSong(songPath, songTitle, songIndex, songArtist); // Save the recent song
updateRecentSongButton(); // Update the button text
});
}
}
Expand Down Expand Up @@ -1210,7 +1276,7 @@ function startGame(index) {
const nextConfig = songConfig[currentConfigIndex];
if (currentTime >= nextConfig.timestamp) {
noteSpeed = nextConfig.noteSpeed;
console.log(`Updated note speed to: ${noteSpeed} at timestamp: ${nextConfig.timestamp}`);
console.log(`Updated note speed to: ${noteSpeed} at timestamp: ${nextConfig.timestamp}`); // This logs, and speed still changes
if (nextConfig.notes) {
notes = nextConfig.notes;
console.log(`Updated notes at timestamp: ${nextConfig.timestamp}`);
Expand All @@ -1233,9 +1299,9 @@ function startGame(index) {
}
}, 1);
} else {
console.log(`No dynamic speed configuration for "${songTitle}"`);
dynamicSpeedInfo = "No dynamic speed configuration found.";
nextSpeedChange = "No speed changes.";
console.log(`No dynamic speed configuration for "${songTitle}"`); // This logs
dynamicSpeedInfo = "No dynamic speed configuration found."; // This does appear as not found
nextSpeedChange = "No speed changes."; // This does not reset
}

currentSong.play(); // Start playing the song immediately
Expand Down
Binary file added Resources/Covers/24K Magic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Covers/Finesse.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Covers/Grenade.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Resources/Songs/24K Magic.mp3
Binary file not shown.
Binary file added Resources/Songs/Finesse.mp3
Binary file not shown.
Binary file added Resources/Songs/Grenade.mp3
Binary file not shown.
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ <h4><span id="presetSaved" style="color: white; display: none">Preset has been s
<button id="contactbtn" onclick="email()"><i class="fa-solid fa-envelope"></i> Contact</button>
</div>

<div id="publicToTestToggle"><button id="publicbtn" onclick="toVersion()">Open public game</button><br /><br /></div>
<div id="publicToTestToggle"><button id="publicbtn" onclick="toVersion()">Open testing game</button><br /><br /></div>

<h2>
Background image from:
Expand All @@ -191,7 +191,8 @@ <h3>Note that i am NOT making any money on this game, i just code occasionally f
<h1 class="modal-title">Song List</h1>
</div>
<label for="songSearchInput">Search songs by keyword, index or artist.</label><br /><br />
<input type="text" id="songSearchInput" placeholder="Search..." />
<input type="text" id="songSearchInput" placeholder="Search..." /><br /><br />
<button type="button" id="mostRecent" class="most-recent-button" style="display: none">Play most recent song</button>
<div class="modal-body" id="songList">
<!-- Song buttons will be dynamically inserted here -->
</div>
Expand Down
26 changes: 25 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,34 @@ canvas:-ms-fullscreen {
}

#songListModal .modal-body {
max-height: 675px;
max-height: 600px;
overflow-y: scroll;
}

.most-recent-button {
display: block;
width: 60%;
padding: 15px 15px;
margin-bottom: 25px;
border: 1px solid rgba(255, 255, 255, 0.2);
background-color: rgba(255, 255, 255, 0.1);
color: #fff;
cursor: pointer;
text-align: left;
font-size: 16px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(114, 114, 114, 0.719);
transition:
box-shadow 0.3s ease,
padding 0.3s ease;
}

.most-recent-button:hover {
background-color: rgba(255, 255, 255, 0.2);
box-shadow: 0 0 10px rgba(221, 221, 221, 0.623);
transition: box-shadow 0.3s ease;
}

.song-button {
display: block;
width: 90%;
Expand Down
8 changes: 6 additions & 2 deletions versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -376,5 +376,9 @@ Added a new song list interface!
- Game now only needs 5 songs loaded to initialize.

3.5.0.1 (10COM 3.5! 10/07/2024)
- Fixed dynamic speed index not resetting after a new song is selected.
- Fixed version switching always deploying you to "index.html", the main game.
- Fixed version switching always deploying you to "index.html", the main game.

3.5.1.2 (10COM 3.5! 10/07/2024)
- Added a most recent song button to the song list layer. Plays the most recent song you've selected from the song list.
- Added 3 new songs: Grenade, 24K Magic, and Finesse, all by Bruno Mars.
- Fixed dynamic speed index not resetting after a new song is selected.

0 comments on commit 3659c26

Please sign in to comment.