Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Issue#17/music #53

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# REFLEXIO
A web game based on reflection written purely in HTML5 and Javascript.

Background music by <nosoapradio.us>, used under a Creative Commons Attribution License.

### Play Online!
The game is live on:
>[ketangupta.in/reflexio]
Expand Down
10 changes: 7 additions & 3 deletions scripts/mainmenu.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
function mainMenu()
{
gameArena.clearRect(0,0, width, height);
bgm.pause();

gameArena.clearRect(0,0, width, height);
drawMovingSpace();

var hoverCheck = 0;
var colorCheck;

Expand Down Expand Up @@ -87,7 +88,10 @@ function mainMenu_click()
clearInterval(gameTimer);
update();
lastClickCounter = 0;
if(volume) menu_click.play();
if(volume) {
menu_click.play();
nextBGM();
}
}
if(mousex >= midx-200*(width/1220) && mousex <= midx+200*(width/1220) && mousey >= midy-20*(width/1220) && mousey <= midy+50*(width/1220))
{
Expand Down
22 changes: 21 additions & 1 deletion scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@ var volume = 1;
var particles = 1;
var runtime1 = 0;


var menu_click = new Audio(); // why loading ??
menu_click.onload = function() {
loading++;
}
menu_click.src = "sounds/sound1.wav";

availBGM = [
"bgm1.mp3",
"bgm2.mp3",
"bgm3.mp3"
];

var bgm = new Audio();
var bgmIterator = -1;

bgm.addEventListener('ended', function() {
nextBGM();
});

var mainShip = new Image();
mainShip.onload = function() {
loading++;
Expand Down Expand Up @@ -454,3 +466,11 @@ function drawRightRoundedRectangle(x, y, width, height, color, lineWidth)
gameArena.lineTo(x, y);
gameArena.stroke();
}

function nextBGM() {
if (volume) {
bgmIterator = (bgmIterator + 1) % availBGM.length;
bgm.src = "sounds/" + availBGM[bgmIterator];
bgm.play();
}
}
Binary file added sounds/bgm1.mp3
Binary file not shown.
Binary file added sounds/bgm2.mp3
Binary file not shown.
Binary file added sounds/bgm3.mp3
Binary file not shown.