diff --git a/Board (Vishwa) b/Board (Vishwa) deleted file mode 100644 index 1d85ee6..0000000 --- a/Board (Vishwa) +++ /dev/null @@ -1,91 +0,0 @@ -class Board { - Sword[] swords; - //int score; - boolean clear; - String diff; - int lev = 0; - float robotAngle = 0; - float robotSpeed = 0.01; - - Board(int swordCount /*might need parameters for level to display level text*/) { - swords = new Sword[swordCount]; - score = 0; - clear = false; - - for (int i=0; i < swordCount; i++) - swords[i]=new Sword(); - } - - int getScore() { - return score; - } - - - void Reset() { - //Also need to display score screen - score=0; - clear = false; - } - - void SetDifficulty(String difficulty) { - diff=difficulty; - } - - void IncreaseLev() { - if (clear) { - lev++; - //Display level text - } - } - - void placeBomb() { - //Need to check if previous sword has hit the robot. If it has, you can place a new sword. - for (int i=0; i < swords.length; i++) { - if (swords[i].getHit()) { - swords[i].rotateSword(); - } - } - } - - void displayBoard(PImage img) { - background(level); - pushMatrix(); - rotate(robotAngle); - imageMode(CENTER); - image(img, 0, 0); - robotAngle += robotSpeed; - popMatrix(); - } - - void clicked(int c) { - swords[c].shoot(); - //Temporary score counter for now; need to first check for collisions. - score+=1; - } - - void collisionCheck() { - for (int i = 0; i < swords.length; i++) { - if (swords[clickCount].getHit() && swords[i].getHit() && (i != clickCount)) { - System.out.println("Current sword placed coordinates: X - " + swords[clickCount].getX() + ", Y - " + swords[clickCount].getY()); - System.out.println("Checking sword at i: X - " + swords[i].getX() + ", Y - " + swords[i].getY()); - System.out.println("Distance: " + dist(swords[i].getX(), swords[i].getY(), swords[clickCount].getX(), swords[clickCount].getY())); - if (collided(swords[i].getX(), swords[i].getY(), swords[clickCount].getX(), swords[clickCount].getY())) { - println("COLLIDED!"); - clear = true; - //background(level); - } - } - } - } - - boolean collided(float x1, float y1, float x2, float y2) { - if (dist(x1, y1, x2, y2) <= 1) { - //System.out.println("Distance: " + dist(x1, y1, x2, y2)); - System.out.println("COLLIDED!"); - return true; - } - println(x1, x2 ,y1,y2); - - return false; - } -} diff --git a/Board.pde b/Board.pde new file mode 100644 index 0000000..7ac46f6 --- /dev/null +++ b/Board.pde @@ -0,0 +1,183 @@ +class Board { + Bomb[] bombs; + //int score; + boolean clear; + String difficulty; + + int finalScore; + int highScore; + + int bombCount; + float robotSpeed; + + int remainingBombs; + int wave = 1; + float robotAngle = PI/4; + + boolean lose = false; + boolean mute = false; + + //Constructor + /*Constructor parameters accept randomly generated values for number of bombs and robot speed, + and uses those values to make a new array of bombs and set their speed */ + Board(int _bombCount, float _robotSpeed) { + bombCount = _bombCount; + robotSpeed = _robotSpeed; + bombs = new Bomb[bombCount]; + score = 0; + clear = false; + + for (int i=0; i < bombCount; i++) + bombs[i]=new Bomb(robotSpeed); + } + + //Displays board + /*This function takes in the board image as a parameter and rotates it according to the robot speed, + it also calculates the stats of the game and calls the function which displays them*/ + void displayBoard(PImage img) { + PFont f = createFont("Architype Font.otf", 128); + textFont(f); + pushMatrix(); + rotate(robotAngle); + imageMode(CENTER); + image(img, 0, 0); + robotAngle += robotSpeed; + popMatrix(); + + remainingBombs = bombs.length - clickCount; + remainingBombs = Math.max(0, remainingBombs); + + //Extra backround + fill(17, 10, 97); + boardText(-377, -172, 123, 313, -70, 55); + fill(255); //Fill color of bomb + boardText(-380, -175, 120, 310, -75, 50); + } + + //Bomb Placement + /*This function controls the color of the bombs, and determines which bombs have hit the board and thus need to be rotated*/ + void placeBomb() { + fill(158, 9, 146); + + for (int i=0; i < bombs.length; i++) { + if (bombs[i].getHit()) + bombs[i].rotateBomb(); + fill(158, 9, 146); + } + } + + //Reset board for next level + /*This is a reset function for each wave, it determines a new robot speed, + a new background, makes a new array of bombs, and increments the wave*/ + void ResetNextLevel() { + clear = true; + clickCount = 0; + wave++; + clear = false; + if (easyMode) { + robotSpeed = random(0.025, 0.075); + } else if (hardMode) { + robotSpeed = random(-0.076, 0.1); + } + + index = (int) random(0, 5); + background(waves[index]); + //robotSpeed = random(0.025, 0.075); + println("Robot Speed: " + robotSpeed); + int bombCount = int (random(7, 15)); + bombs = new Bomb[bombCount]; + for (int i=0; i < bombCount; i++) + bombs[i]=new Bomb(robotSpeed); + } +/*This is the reset function for the whole game, and is called if the game is lost. +It resets the stats, makes a new robot speed, and a new array of bombs*/ + void ResetAfterLose() { + lose=false; + score=0; + clear = true; + clickCount = 0; + wave=1; + if (easyMode) { + bombCount = int (random(7, 15)); + robotSpeed = random(0.025, 0.075); + } else if (hardMode) { + bombCount = int (random(10, 30)); + robotSpeed = random(-0.076, 0.1); + } + bombs = new Bomb[bombCount]; + for (int i=0; i < bombCount; i++) + bombs[i]=new Bomb(robotSpeed); + } + +/*The score is incremented within this function, along with the clicking sound. +Additionally, the shoot function is called here, which controls the movement of the bomb until it reaches the board*/ + void clicked(int c, SoundFile hit) { + bombs[c].shoot(); + if (!mute) + hit.play(); + if (!lose) + if (easyMode) + score+=1; + else if (hardMode) + score+=2; + } + + /*Lose condition*/ + /*Check if a collision occured between two bombs by taking into account the distance between them. + If the distance is less than 36 (radius+stroke of two circles), the lose condition is set to true*/ + void collisionCheck() { + for (int i = 0; i < bombs.length; i++) { + if (bombs[clickCount].getHit() && bombs[i].getHit() && (i != clickCount)) { + if (dist(bombs[i].x, bombs[i].y, bombs[clickCount].x, bombs[clickCount].y) <= 36) { + println("COLLIDED!"); + lose = true; + clear = true; + } + } + } + } +/*Formatting the text for the stats, such as coordinates and text size*/ + void boardText(int x1, int x2, int x3, int x4, int x5, int x6/*, int x7, int x8*/) { + textSize(25); + text("REMAINING BOMBS: ", x1, -360); + text(" " + remainingBombs, x2, -360); + text("CURRENT SCORE: ", x3, -360); + text(" " + score, x4, -360); + + textSize(40); + text("WAVE ", x5, -260); //Change to x7 + text(wave, x6, -260); //Change to x8 + } +/*This function takes in an image as a parameter to set the image for the endscreen. +The highscore is calculated, and formatting is done to show the text for the stats such as text size, and coordinates*/ + void displayEndScreen(PImage p) { + background(p); + finalScore = score; + if (highScore < finalScore) { + highScore = finalScore; + } + PFont end; + end = createFont("Architype Font.otf", 128); + textFont(end); + textSize(90); + fill(255); + //Bombs placed + if (easyMode) { + text( " " + score, -75, 15); + } + else if (hardMode) { + text( " " + score/2, -75, 15); + } + textSize(30); + //Total Score + text( " "+ score, 30, 140); + text( " "+ (wave-1), 30, 185); + + if (highScore!=0) { + text( " " + highScore, 30, 235); + } + else { + text( " " + score, 30, 235); + } + } +} diff --git a/Board.pde (Aayesha) b/Board.pde (Aayesha) deleted file mode 100644 index 4e042df..0000000 --- a/Board.pde (Aayesha) +++ /dev/null @@ -1,110 +0,0 @@ - -class Board { - Sword[] swords; - int score; - boolean clear; - String diff; - int lev = 1; - float robotAngle = 0; - float robotSpeed = 0.1; - int remBomb; - int scorefinal=0; - int scoredis=0; - - Board(int swordCount /*might need parameters for level to display level text*/) { - swords = new Sword[swordCount]; - score = 0; - clear = false; - - for (int i=0; i < swordCount; i++) - swords[i]=new Sword(); - } - - int getScore() { - return score; - } - - void addScore(boolean b) { - if (b) - score+=1; - } - - void Reset() { - //Also need to display score screen - //score=0; - // scoredis+=scorefinal; - b.IncreaseLev(); - clear = false; - int swordCount= int (random(7,15)); - swords = new Sword[swordCount]; - for (int i=0; i < swordCount; i++) - swords[i]=new Sword(); - - } - - void SetDifficulty(String difficulty) { - diff=difficulty; - } - - void IncreaseLev() { - if (clear) { - lev++; - //Display level text - } - } - - void placeBomb() { - for (int i=0; i < swords.length; i++) { - if (swords[i].getHit()) { - swords[i].rotateSword(); - } - } - } - - void displayBoard(PImage img) { - background(level); - pushMatrix(); - rotate(robotAngle); - imageMode(CENTER); - image(img, 0, 0); - robotAngle += robotSpeed; - popMatrix(); - } - - void clicked(int c) { - swords[c].shoot(); - score++; - } - void display() { - PFont mono; - mono = createFont("gamerfont3.otf", 128); - textFont(mono); - b.remBomb = b.swords.length - clickCount; - b.remBomb = Math.max(0, b.remBomb); - - - textSize(40); - text("Remaining Bombs: ", -380, -360); - text("Level ", -100, -260); - text("Current Score: ", 60, -360); - - textSize(40); - text(remBomb, -60, -360); - - text(lev, 50, -260); - text(score, 340, -360); - //score = clickCount; - /* - if(b.remBomb == 0){ - score = b.swords.length; - scorefinal = score; - println(scorefinal); - }*/ - // println(score); - - - } - int getremainingb(){ - return remBomb; - } -} diff --git a/Circular Rotating Robot.png b/Circular Rotating Robot.png deleted file mode 100644 index d5bab54..0000000 Binary files a/Circular Rotating Robot.png and /dev/null differ diff --git a/FPAhmedSword b/FPAhmedSword deleted file mode 100644 index 79240a1..0000000 --- a/FPAhmedSword +++ /dev/null @@ -1,41 +0,0 @@ -class Sword { - float speed; - float pos; - boolean hit; - float circleAngle = 0; - float circleSpeed = 0.1; - - Sword() { - speed = 20; - pos = 350; - hit = false; - - } - - void shoot() { - while (pos >= 200) { - strokeWeight(3); - stroke(255, 187, 51); - fill(0, 255, 255); - ellipse(0, pos, 30, 30); - pos -= speed; - } - setHit(true); - } - - void setHit(boolean b) { - hit=b; - } - - boolean getHit() { - return hit; - } - - void rotateSword() { - pushMatrix(); - rotate(circleAngle); - circleAngle += circleSpeed; - ellipse(60, 200, 30, 30); - popMatrix(); - } -} diff --git a/FPAhmedboard b/FPAhmedboard deleted file mode 100644 index e31f420..0000000 --- a/FPAhmedboard +++ /dev/null @@ -1,88 +0,0 @@ -class Board { - Sword[] swords; - int score; - boolean clear; - String diff; - int lev = 0; - float robotAngle = 0; - float robotSpeed = 0.1; - int remBomb; - - Board(int swordCount /*might need parameters for level to display level text*/) { - swords = new Sword[swordCount]; - score = 0; - clear = false; - - for (int i=0; i < swordCount; i++) - swords[i]=new Sword(); - } - - int getScore() { - return score; - } - - void addScore(boolean b) { - if (b) - score+=1; - } - - void Reset() { - //Also need to display score screen - score=0; - clear = false; - } - - void SetDifficulty(String difficulty) { - diff=difficulty; - } - - void IncreaseLev() { - if (clear) { - lev++; - //Display level text - } - } - - void placeBomb() { - for (int i=0; i < swords.length; i++) { - if (swords[i].getHit()) { - swords[i].rotateSword(); - } - } - } - - void displayBoard(PImage img) { - background(level); - pushMatrix(); - rotate(robotAngle); - imageMode(CENTER); - image(img, 0, 0); - robotAngle += robotSpeed; - popMatrix(); - } - - void clicked(int c) { - swords[c].shoot(); - } - void display() { - b.remBomb = b.swords.length - clickCount; - b.remBomb = Math.max(0, b.remBomb); - - - textSize(30); - text("Remaining Bombs Left: ", -380, -360); - text("Current Score ", -380, -260); - - textSize(65); - text(remBomb, -70, -350); - - text(score, -70, -250); - score = clickCount; - if(b.remBomb == 0){ - score = b.swords.length; - } - println(score); - - - } -} diff --git a/FinalProject.pde b/FinalProject.pde index b1a21dd..297161e 100644 --- a/FinalProject.pde +++ b/FinalProject.pde @@ -1,81 +1,208 @@ +//Sound files import processing.sound.*; SoundFile file; SoundFile hitsound; +SoundFile mouseClick; +SoundFile robotSound; +SoundFile laserSound; +SoundFile explosionSound; +Sound volume; -PImage robot; -PImage level; -Sword s; -Sword s2; -Board b; -float sp=20; -boolean click=false; -float robotAngle = 0; -float robotSpeed = 0.1; -float coor; -float r=0; -float x; -float y; +//Images +PImage easyRobot; +PImage hardRobot; +PImage menuScreen; +PImage waveBackground; +PImage helpScreen; +PImage modesScreen; +PImage hardEndScreen; +PImage easyEndScreen; +PImage[] waves = new PImage[6]; +PImage waveBackdrop1; +PImage waveBackdrop2; +PImage waveBackdrop3; +PImage waveBackdrop4; +PImage waveBackdrop5; +PImage waveBackdrop6; + +//Board-related items +Modes easy = new Modes("easy"); +Modes hard = new Modes("hard"); +//Board b; +int clickCount; +int score; + +int easyHighScore; +int hardHighScore; + +//Background booleans +boolean modeMenu; +boolean gameModes; +boolean gameStart; +boolean help; +boolean easyMode; +boolean hardMode; +boolean gameEnd; + +//Miscellaneous +int index; +boolean firstDisplayed = false; -int clickCount = 0; void setup() { size(800, 800); - s = new Sword(); - s2 = new Sword(); - frameRate(10); - level = loadImage("Level Background.png"); - robot = loadImage("Circular Rotating Robot.png"); - background(level); - - //file = new SoundFile(this, "Dystopian_Synthwave_Retrowave_-_Lost_City_Royalty_Free_Copyright_Safe_Music.mp3"); - //file.loop(); - hitsound = new SoundFile(this, "Hard_Hit_Sound_Effect.mp3"); + frameRate(32); + + volume = new Sound(this); + volume.volume(0.05); + file = new SoundFile(this, "AVA Background Music.wav"); + file.loop(); + hitsound = new SoundFile(this, "Hard Hit Sound.mp3"); + mouseClick = new SoundFile(this, "Click Sound.wav"); + robotSound = new SoundFile(this, "Robot Sound.wav"); + laserSound = new SoundFile(this, "Laser Sound.wav"); + explosionSound = new SoundFile(this, "Explosion Sound.wav"); - // noLoop(); + //b = new Board(int(random(7, 15))); //Create a new board object of random number of bombs from 5 - 25 + clickCount = 0; + score = 0; + + easyRobot = loadImage("Easy Robot.png"); + hardRobot = loadImage("Hard Robot.png"); + menuScreen = loadImage("Menu Screen.png"); + helpScreen = loadImage("Help Screen.png"); + modesScreen = loadImage("Gamemodes Screen.png"); + easyEndScreen = loadImage("Easy End Screen.png"); + hardEndScreen = loadImage("Hard End Screen.png"); + waveBackdrop1 = loadImage("Level Backdrop 1.png"); + waveBackdrop2 = loadImage("Level Backdrop 2.png"); + waveBackdrop3 = loadImage("Level Backdrop 3.png"); + waveBackdrop4 = loadImage("Level Backdrop 4.png"); + waveBackdrop4 = loadImage("Level Backdrop 5.png"); + waveBackdrop5 = loadImage("Level Backdrop 6.png"); + + waves[0] = waveBackdrop1; + waves[1] = waveBackdrop2; + waves[2] = waveBackdrop3; + waves[3] = waveBackdrop4; + waves[4] = waveBackdrop5; + waves[5] = waveBackdrop6; + + + modeMenu = true; + gameStart = false; + gameModes = false; + help = false; + easyMode = false; + hardMode = false; + + index = (int) random(0, 5); } void draw() { - background(level); - pushMatrix(); - translate(width/2, height/2); - rotate(robotAngle); - imageMode(CENTER); - image(robot, 0, 0); - robotAngle += robotSpeed; - popMatrix(); - - if (s.getHit()) { + if (modeMenu) { + setBackground(menuScreen); + } + else if (help) { + setBackground(helpScreen); + } + else if (gameModes) { + setBackground(modesScreen); + } + else if (easyMode) { + gameStart = true; + setBackground(waves[index]); translate(width/2, height/2); - rotate(robotAngle); - //println("Sword 1 angle: " + robotAngle); - ellipseMode(CORNER); - ellipse(0, 200, 30, 30); - //rotate(robotAngle); + easy.runningGame(easyRobot); } - - if (s2.getHit()) { - //translate(width/2, height/2); - rotate(robotAngle); - //println("Sword 2 angle: " + robotAngle); - //ellipseMode(CORNER); - ellipse(0, 200, 30, 30); - rotate(robotAngle); + else if (hardMode) { + gameStart = true; + setBackground(waves[index]); + translate(width/2, height/2); + hard.runningGame(hardRobot); } - - } - +/*This functions deals with user interaction, and calls the respective +Modes objects and its functions depending on whether the user selects easy or hard node. +*/ void mousePressed() { - clickCount++; - println("Current click count: " + clickCount); - //click=!click; - s.shoot(); - s.setHit(true); - - if (clickCount == 2) { - s2.shoot(); - s2.setHit(true); + //If the game has started, keep track of click count and number of bombs + if (gameStart && easyMode) { + easy.clickCountCheck(); + } + else if (gameStart && hardMode) { + hard.clickCountCheck(); + } + else if (gameEnd==true && mouseX>=277 && mouseX<=447 && mouseY>=691 && mouseY<=740) { + mouseClick.play(); + if(easyMode){ + easy.restart=true; + } + else if (hardMode){ + hard.restart=true; + } } + else { + options(); + } +} - //s.shoot(); +void setBackground(PImage img) { + background(img); +} + +/*This function controls the menu functionality with the use of booleans. The specific coordinates of buttons trigger +the changing the state of the respective booleans which will then trigger functionality such as background change, game reset, etc*/ +void options() { + if (modeMenu) { + //START BUTTON -> Goes to modes + if (mouseX>=248 && mouseX<=550 && mouseY>=360 && mouseY<=430) { + mouseClick.play(); + modeMenu=false; + gameModes = true; + } + //HELP BUTTON + else if (mouseX>=242 && mouseX<=555 && mouseY>=456 && mouseY<=520) { + mouseClick.play(); + modeMenu = false; + gameModes = false; + help=true; + } + //QUIT BUTTON + else if (mouseX>=242 && mouseX<=550 && mouseY>=540 && mouseY<=596) { + mouseClick.play(); + exit(); + } + } + else if (gameModes) { + //EASY BUTTON + if (mouseX<=391 && mouseX>=33 && mouseY>=365 &&mouseY<=431) { + mouseClick.play(); + modeMenu = false; + gameModes = false; + easyMode = true; + hardMode = false; + } + //HARD BUTTON + else if (mouseX <=780 && mouseX >=416 && mouseY >=365 && mouseY <=431) { + mouseClick.play(); + modeMenu = false; + gameModes = false; + easyMode = false; + hardMode = true; + } + //BACK BUTTON + else if (mouseX>=271 && mouseX<=550 && mouseY>=470 && mouseY<=525) { + mouseClick.play(); + gameModes = false; + modeMenu = true; + } + } + else if (help) { + //BACK BUTTON + if (mouseX>=240 && mouseX<=524 && mouseY>=678 && mouseY<=735) { + mouseClick.play(); + help=false; + modeMenu = true; + } + } } -//Class circle diff --git a/FinalProjectAayesha.pde b/FinalProjectAayesha.pde deleted file mode 100644 index 7deff50..0000000 --- a/FinalProjectAayesha.pde +++ /dev/null @@ -1,73 +0,0 @@ -import processing.sound.*; -SoundFile file; -SoundFile hitsound; - -PImage robot; -PImage level; -PImage menu; -boolean modeMenu; -boolean gameStart; -Board b; -int clickCount; - -void setup() { - size(800, 800); - clickCount = 0; - b = new Board(8); - frameRate(10); - level = loadImage("level.png"); - robot = loadImage("Circular_Rotating_Robot.png"); - menu = loadImage("Menu Screen.png"); - //background(level); - modeMenu=true; - gameStart=false; - //file = new SoundFile(this, "Dystopian_Synthwave_Retrowave_-_Lost_City_Royalty_Free_Copyright_Safe_Music.mp3"); - //file.loop(); - hitsound = new SoundFile(this, "Hard_Hit_Sound_Effect.mp3"); -} -void draw() { -// println(mouseX,mouseY); - if(modeMenu){ - setbg(menu); - } - else{ - gameStart=true; - setbg(level); - translate(width/2, height/2); - - b.displayBoard(robot); - - //Goes through array and checks if a bomb has not been placed at the current index. - b.placeBomb(); - b.display(); - if(b.getremainingb()==0){ - b.clear=true; - clickCount=0; - b.Reset(); - //b.IncreaseLev(); - } - //println("lev",b.lev); - } -} - -void setbg(PImage img){ -background(img); -} -void mousePressed() { - if(modeMenu){ - if(mouseX>=248 && mouseX<=550 && mouseY>=360 && mouseY<=430){ - modeMenu=false; - } - else if (mouseX>=242 && mouseX<=550 && mouseY>=540 && mouseY<=596){ - exit(); - } - } - if(modeMenu==false && gameStart==true){ - if (clickCount < b.swords.length) { - println("Current click count: " + clickCount); - b.clicked(clickCount); - } - - clickCount++; - } -} diff --git a/Main (Vishwa) b/Main (Vishwa) deleted file mode 100644 index 6da8192..0000000 --- a/Main (Vishwa) +++ /dev/null @@ -1,61 +0,0 @@ -import processing.sound.*; -SoundFile file; -SoundFile hitsound; - -PImage robot; -PImage level; -PImage menu; - -Board b; -int clickCount; -int score; - -boolean setMainMenu = false; - -void setup() { - size(800, 800); - clickCount = 0; - score = 0; - b = new Board(int(random(5, 25))); //Create a new board object of random number of bombs from 5 - 25 - frameRate(32); - level = loadImage("Level Background.png"); - robot = loadImage("Circular Rotating Robot.png"); - background(level); - - //file = new SoundFile(this, "Dystopian_Synthwave_Retrowave_-_Lost_City_Royalty_Free_Copyright_Safe_Music.mp3"); - //file.loop(); - hitsound = new SoundFile(this, "Hard_Hit_Sound_Effect.mp3"); -} -void draw() { - background(level); - translate(width/2, height/2); - - b.displayBoard(robot); - - //Goes through array and checks if a bomb has not been placed at the current index. - b.placeBomb(); - - if (setMainMenu) { - background(level); - exit(); - } -} - - -void mousePressed() { - if (clickCount < b.swords.length) { - println("Click Count: " + clickCount); - b.clicked(clickCount); - b.collisionCheck(); - if (b.clear) { - setMainMenu = true; - } - if (b.swords[clickCount].getHit()) { - hitsound.play(); - } - clickCount++; - println("Click Count: " + clickCount); - println("Current Score: " + b.getScore()); - } - //After every level, clickCount has to be reset to 0 -} diff --git a/Modes.pde b/Modes.pde new file mode 100644 index 0000000..4e609d6 --- /dev/null +++ b/Modes.pde @@ -0,0 +1,73 @@ +class Modes { + int easyHighScore = 0; + int hardHighScore; + Board b; + boolean easy; + boolean hard; + boolean restart; + boolean explosionPlayed = false; +/*Constructor takes in the mode as a parameter. +Based on that, it sets the easy or hard booleans for the board and makes a new board object with a randomized number of bombs and robot speed, +if the mode is hard, the number of bombs and robot speed is significantly higher.*/ + Modes(String mode) { + if (mode == "easy") { + easy = true; + hard = false; + b = new Board((int(random(7, 15))), random(0.025, 0.075)); + } + else if (mode == "hard") { + easy = false; + hard = true; + b = new Board((int(random(10, 30))), random(0.076, 0.1)); + } + } +/*This function is called when the game starts. It displays the board along with rotation, places the bombs that have been shot, +checks whether the game is in a win or lose state, and continues or restarts the game based on those booleans*/ + void runningGame(PImage robot) { + b.displayBoard(robot); + println("Robot Speed: " + b.robotSpeed); + + b.placeBomb(); //Goes through array and checks if a bomb has not been placed at the current index. + if (b.remainingBombs == 0 && easy) { + robotSound.play(); + b.ResetNextLevel(); + } + else if (b.remainingBombs == 0 && hard) { + laserSound.play(); + b.ResetNextLevel(); + } + else if (b.lose) { + if (!explosionPlayed) { + explosionSound.play(); + } + + explosionPlayed = true; + gameEnd = true; + if (easy){ + b.displayEndScreen(easyEndScreen); + } + else if (hard){ + b.displayEndScreen(hardEndScreen); + } + gameStart = false; + + if (restart) { + modeMenu= true; + gameModes = false; + easyMode= false; + help = false; + b.ResetAfterLose(); + restart=false; + explosionPlayed = false; + } + } + } +/*Increments clickcount while there are bombs left, checks for collisions, and calls clicked which has shooting and user interaction functionality*/ + void clickCountCheck() { + if (clickCount < b.bombs.length) { + b.clicked(clickCount, hitsound); + b.collisionCheck(); + clickCount++; + } + } +} diff --git a/Sword (Vishwa) b/Sword (Vishwa) deleted file mode 100644 index 828a331..0000000 --- a/Sword (Vishwa) +++ /dev/null @@ -1,68 +0,0 @@ -class Sword { - float speed; - float pos; - boolean hit; - float circleAngle = 0; - float circleSpeed = 0.01; - float x = 0; - float y = 200; - - Sword() { - speed = 20; - pos = 350; - hit = false; - } - - void shoot() { //Might also need shoot sound effect and hit sound effect - while (pos >= 200) { - strokeWeight(3); - stroke(255, 187, 51); //Outline of bomb - //fill(0, 255, 255); //Bomb color - fill(0); - ellipse(0, pos, 30, 30); - pos -= speed; - } - setHit(true); - } - - - void setHit(boolean b) { - hit=b; - } - - boolean getHit() { - return hit; - } - - void rotateSword() { - pushMatrix(); - rotate(circleAngle); - - circleAngle += circleSpeed; - if(circleSpeed==0.1){ - x += cos(circleAngle); - y += sin(circleAngle); - ellipse(0, 200, 30, 30); - - } - else if(circleSpeed==0.01){ - x += sin(circleAngle); - y += cos(circleAngle); - ellipse(-42, 200, 30, 30); - - - } - //ellipse(0, 200, 30, 30); - - //println("X-coord: " + x + ", Y-Coord: " + y * sin(circleAngle)); - popMatrix(); - } - - float getX() { - return x; - } - - float getY() { - return y; - } -} diff --git a/Sword.pde b/Sword.pde index 6ab538c..9ee9cea 100644 --- a/Sword.pde +++ b/Sword.pde @@ -1,28 +1,52 @@ -class Sword { - float speed; +class Bomb { + float shootSpeed; float pos; boolean hit; - float circleAngle = 0; - float circleSpeed = 0.1; + float circleAngle = PI/4; + float circleSpeed; + float x = 0; + float y = 200; - Sword() { - speed = 20; +/*Constructor takes in rotation speed as a parameter*/ + Bomb(float tempCircleSpeed) { + shootSpeed = 20; pos = 350; hit = false; + circleSpeed = (tempCircleSpeed)/2.0; } - - void shoot() { +/*Draws and Controls movement of each bomb from when it is first shor until +it reaches the board and sets the corresponding booleans*/ + void shoot() { while (pos >= 200) { strokeWeight(3); - stroke(255, 187, 51); - fill(0, 255, 255); + stroke(255, 187, 51); //Outline of bomb + + fill(158, 9, 146); ellipse(0, pos, 30, 30); - pos -= speed; + pos -= shootSpeed; } setHit(true); } +/*Rotates the bombs with the board by Rotating coordinates to coordinates with respect to the entire screen*/ + void rotateBomb() { + pushMatrix(); + translate(width/2, height/2); + rotate(circleAngle); + popMatrix(); + //200 is the robot radius + float tempX = 200 * cos(circleAngle); + float tempY = 200 * sin(circleAngle); - + //Rotate coordinates to coordinates with respect to entire screen + x = tempX * cos(circleAngle) - tempY * sin(circleAngle); + y = tempX * sin(circleAngle) + tempY * cos(circleAngle); + + //println(clickCount + ": Global X: " + x + ", Global Y: " + y); + + ellipse(x, y, 30, 30); + circleAngle += circleSpeed; + } +/*Setter and getter for the hit boolean of each bomb*/ void setHit(boolean b) { hit=b; } @@ -30,13 +54,4 @@ class Sword { boolean getHit() { return hit; } - - void rotateSword() { - pushMatrix(); - rotate(circleAngle); - circleAngle += circleSpeed; - ellipse(0, 200, 30, 30); - popMatrix(); - } } - diff --git a/fpa b/fpa deleted file mode 100644 index 98515dd..0000000 --- a/fpa +++ /dev/null @@ -1,48 +0,0 @@ -import processing.sound.*; -SoundFile file; -SoundFile hitsound; -PImage robot; -PImage level; -PImage menu; - -Board b; -int clickCount; - -void setup() { - size(800, 800); - clickCount = 0; - b = new Board(int (random(5, 10)));//changes total number of shots available - frameRate(10); - level = loadImage("Level Background.png"); - robot = loadImage("Circular Rotating Robot.png"); - background(level); - - file = new SoundFile(this, "Dystopian_Synthwave_Retrowave_-_Lost_City_Royalty_Free_Copyright_Safe_Music.wav"); - file.loop(); - hitsound = new SoundFile(this, "Hard_Hit_Sound_Effect.mp3"); -} -void draw() { - background(level); - - translate(width/2, height/2); - - b.displayBoard(robot); - - //Goes through array and checks if a bomb has not been placed at the current index. - b.placeBomb(); - b.display(); -} - - -void mousePressed() { - if (clickCount < b.swords.length) { - println("Current click count: " + clickCount); - b.clicked(clickCount); - - if (b.swords[clickCount].getHit()) { - - hitsound.play(); - } - } - clickCount++; -}