Skip to content

Commit

Permalink
duplicate, correct one
Browse files Browse the repository at this point in the history
  • Loading branch information
GusGt committed Apr 23, 2024
1 parent 5102181 commit 116546d
Show file tree
Hide file tree
Showing 12 changed files with 66 additions and 25 deletions.
Binary file added BugSerial/Assets/DOH.mp3
Binary file not shown.
Binary file added BugSerial/Assets/endSong.mp3
Binary file not shown.
Binary file added BugSerial/Assets/gameOver.mp3
Binary file not shown.
Binary file added BugSerial/Assets/menu.mp3
Binary file not shown.
Binary file added BugSerial/Assets/menuTrim.mp3
Binary file not shown.
Binary file added BugSerial/Assets/squish.wav
Binary file not shown.
Binary file added BugSerial/Assets/start.mp3
Binary file not shown.
Binary file added BugSerial/Assets/start2.mp3
Binary file not shown.
Binary file added BugSerial/Assets/theme.mp3
Binary file not shown.
4 changes: 2 additions & 2 deletions BugSerial/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">

Expand All @@ -10,7 +9,8 @@
<link rel="stylesheet" type="text/css" href="style.css">

<script src="libraries/p5.min.js"></script>
<script src="libraries/p5.sound.min.js"></script>
<!--script src="libraries/p5.sound.min.js"></script> -->
<script src="libraries/Tone.js"></script>
<script src="https://p5play.org/v3/planck.min.js"></script>
<script src="https://p5play.org/v3/p5play.js"></script>
</head>
Expand Down
3 changes: 3 additions & 0 deletions BugSerial/libraries/Tone.js

Large diffs are not rendered by default.

84 changes: 61 additions & 23 deletions BugSerial/sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ let resetButton;
let end = false;
let start = false;

//sounds
let squishS = new Tone.Player("Assets/squish.wav").toDestination();
squishS.loop = false;

let missedNoise = new Tone.Player("Assets/DOH.mp3").toDestination();
missedNoise.loop = false;
missedNoise.volume.value = -10;
missedNoise.playbackRate = 1.2;

let ThemeSong = new Tone.Player("Assets/theme.mp3").toDestination();
ThemeSong.loop = true;
ThemeSong.volume.value = -6

let EndSong = new Tone.Player("Assets/endSong.mp3").toDestination();
EndSong.loop = true;
EndSong.volume.value = -6

let loserSong = new Tone.Player("Assets/gameOver.mp3").toDestination();
loserSong.loop = true;
loserSong.volume.value = -6

let startNoise = new Tone.Player("Assets/start2.mp3").toDestination();
startNoise.loop = false;

let menuSong = new Tone.Player("Assets/menuTrim.mp3").toDestination();
menuSong.loop = true;
menuSong.autostart = true;
menuSong.volume.value = -6

function preload(){

Expand All @@ -25,17 +53,14 @@ function setup() {
startButton = createButton('Start Game');
startButton.size(200,50)
startButton.position(width/2-100,height/2);




startButton.mousePressed(() => {

startButton.remove(); //remove button


startButton.mousePressed(() => {
startButton.remove(); //remove button
startNoise.start();
GameStart();

menuSong.stop();
ThemeSong.start();

amount.forEach((character) => {

character.move();
Expand All @@ -44,26 +69,30 @@ function setup() {

})


}



function mousePressed(){


let clicked = false;
for(let i = 0; i < count; i++){
let dead = amount[i].contains(mouseX, mouseY);
if(dead){
amount[i].squish();
clicked = true;
}


}
//miss noise check and start
if(!clicked){
missedNoise.start();
}


}

function GameStart(){

start = true;

let animations = {
run: {row:0 , frames: 2},
die: {row:1, frames: 1}
Expand All @@ -72,9 +101,6 @@ function GameStart(){
for(i = 0; i < count; i++){
amount[i] = (new roach(random(1,800),random(1,800),100,100,spritesheet,animations));
}



}

function time(){
Expand Down Expand Up @@ -121,17 +147,28 @@ function draw() {
text("You scored: "+ score , width/2-80, height/2 -45);
end = true;
}


if(end){
ThemeSong.stop();
squishS.dispose();
missedNoise.dispose();
if(score == 0){
loserSong.start();
}
else{
EndSong.start();
}
}

amount.forEach((character) => {

if (character.sprite.x + 20 > width) {
character.walkLeft();
}
else if (character.sprite.x - 20 < 0) {
else if (character.sprite.x - 20 < 0 || (character.sprite.x -20 < 190 && character.sprite.y < 90)) {
character.walkRight();
}
else if (character.sprite.y - 20 < 0 ){
else if (character.sprite.y - 20 < 0 || (character.sprite.y -20 < 80 && character.sprite.x < 170) ){
character.walkDown();
}
else if (character.sprite.y + 20 > height){
Expand All @@ -147,7 +184,7 @@ function draw() {


class roach {

constructor(x,y,width,height,spriteSheet,animations) {
this.sprite = new Sprite(x,y,width,height);
this.sprite.spriteSheet = spriteSheet;
Expand Down Expand Up @@ -188,13 +225,14 @@ squish(){
this.sprite.vel.y = 0;
this.sprite.vel.x = 0;
this.sprite.changeAni('die')
squishS.start();

if(!this.checked){
score++;
this.checked = true;
speed++; //increases speed of each bug once hitting wall
ThemeSong.playbackRate += 0.01; //makes song faster
}

}

stop(){
Expand Down

0 comments on commit 116546d

Please sign in to comment.