Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
jcponce committed Jul 30, 2024
1 parent f44957a commit f7f7fd6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
19 changes: 19 additions & 0 deletions sketches/my-pond/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@
<script src="Food.js"></script>
<script src="mySketch.js"></script>

<script>
// Function to toggle full screen mode
function toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(err => {
console.error(`Error attempting to enable full-screen mode: ${err.message} (${err.name})`);
});
} else {
document.exitFullscreen();
}
}

// Event listener for keydown event
document.addEventListener('keydown', (event) => {
if (event.key === 'f' || event.key === 'F') {
toggleFullScreen();
}
});
</script>

</body>

Expand Down
8 changes: 4 additions & 4 deletions sketches/my-pond/mySketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function draw() {
if (random() < 0.5) {
dropSound1.play(0, 1, vol, kind, 1);
} else {
dropSound2.play(0, 1, vol, kind, 1);
dropSound2.play(0, 1, vol*0.45, kind, 1);
}
}

Expand All @@ -162,7 +162,7 @@ function draw() {
// Update and draw ripples
for (let i = ripples.length - 1; i >= 0; i--) {
let r = ripples[i];
stroke(`rgba(198, 217, 236, ${1 - r.radius / r.maxRadius})`); // Spring Green with fading effect
stroke(`rgba(198, 217, 236, ${1 - r.radius / r.maxRadius})`); // Fading effect
push();
noFill();
ellipse(r.x, r.y, r.radius * 2);
Expand All @@ -180,10 +180,10 @@ function draw() {

let playSounds = false;
function keyPressed() {
if (key === 'p') {
if (key === 'p' || key === 'P' ) {
playSounds = true;
}
if (key === 's') {
if (key === 's' || key === 's' ) {
playSounds = false;
}
}
Expand Down

0 comments on commit f7f7fd6

Please sign in to comment.