Skip to content

Commit

Permalink
add new image, add toggle audio
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneMoreWare committed Jul 22, 2024
1 parent 57c6c37 commit 0fe96c1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions Clock Time.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ let posXTotalTimeText = 1330;
let posYTotalTimeText = 70;
let posXTotalLivesText = 1480;
let posYTotalLivesText = 70;

let audioIcon;
let dimXAudioIcon = 70;
let dimYAudioIcon = 70;
let posXAudioIcon = 1500;
let posYAudioIcon = 150;
let audioOn = true;
function preload(){

background = loadImage('background.png');
Expand All @@ -111,7 +116,8 @@ function preload(){
marioJump = loadImage('mario_jump1.png');
coin = loadImage('coin.png');
goomba = loadImage('goomba.png');



marioFont = loadFont('Super Plumber Brothers.ttf');

marioJumpSound = loadSound('mario_jump_sound.mp3');
Expand Down Expand Up @@ -147,9 +153,32 @@ function setup(){
marioJump.resize(dimXMarioJump * factorScale, dimYMarioJump * factorScale);
coin.resize(dimXCoin * factorScale, dimYCoin * factorScale);
goomba.resize(dimXGoomba * factorScale, dimYGoomba * factorScale);

addIframe();
addAudioIcon();

}

function toggleAudio(){
if(audioOn){
audioIcon.remove();
audioIcon = createImg('noAudio.png');
} else {
audioIcon.remove();
audioIcon = createImg('Audio.png');
}
audioIcon.position(posXAudioIcon*factorScale,posYAudioIcon*factorScale);
audioIcon.attribute('onclick','toggleAudio()');
audioIcon.style('width',dimXAudioIcon*factorScale);
audioIcon.style('height',dimYAudioIcon*factorScale);
audioOn = !audioOn;
}

function addAudioIcon(){
audioIcon = createImg('audio.png');
audioIcon.position(posXAudioIcon*factorScale,posYAudioIcon*factorScale);
audioIcon.attribute('onclick','toggleAudio()');
audioIcon.style('width',dimXAudioIcon*factorScale);
audioIcon.style('height',dimYAudioIcon*factorScale);
}

function draw(){
Expand Down Expand Up @@ -186,6 +215,7 @@ function draw(){
addScoreText(textSizeScores,factorScale,marioFont,"TIME",totalTime,posXTotalTimeText,posYTotalTimeText);
addScoreText(textSizeScores,factorScale,marioFont,"LIVES","7",posXTotalLivesText,posYTotalLivesText);


}

function addScoreText(fontSize,factorScale,font,title,value,posX,posY){
Expand Down Expand Up @@ -237,7 +267,7 @@ function marioAnimation(){

if (lastSecond !== second() ) {
if (lastSecond !== -1){
marioJumpSound.play();
if(audioOn) marioJumpSound.play();
totalTime = totalTime + 1;
}
lastSecond = second();
Expand Down
Binary file added audio.png
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 noAudio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0fe96c1

Please sign in to comment.