diff --git a/DudgeUp/.gitignore b/DudgeUp/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/DudgeUp/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/DudgeUp/DodgeUp.iml b/DudgeUp/DodgeUp.iml new file mode 100644 index 0000000..a799a56 --- /dev/null +++ b/DudgeUp/DodgeUp.iml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DudgeUp/DodgeUp.sql b/DudgeUp/DodgeUp.sql new file mode 100644 index 0000000..6715472 --- /dev/null +++ b/DudgeUp/DodgeUp.sql @@ -0,0 +1,50 @@ +-- MySQL dump 10.13 Distrib 8.0.33, for Win64 (x86_64) +-- +-- Host: localhost Database: dodgeup +-- ------------------------------------------------------ +-- Server version 8.0.33 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `score` +-- + +DROP TABLE IF EXISTS `score`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `score` ( + `highScore` bigint NOT NULL, + PRIMARY KEY (`highScore`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `score` +-- + +LOCK TABLES `score` WRITE; +/*!40000 ALTER TABLE `score` DISABLE KEYS */; +INSERT INTO `score` VALUES (0); +/*!40000 ALTER TABLE `score` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2023-06-07 21:21:16 diff --git a/DudgeUp/images/background1.jpg b/DudgeUp/images/background1.jpg new file mode 100644 index 0000000..e53ace1 Binary files /dev/null and b/DudgeUp/images/background1.jpg differ diff --git a/DudgeUp/images/background2.jpg b/DudgeUp/images/background2.jpg new file mode 100644 index 0000000..be3ee8f Binary files /dev/null and b/DudgeUp/images/background2.jpg differ diff --git a/DudgeUp/images/background3.jpg b/DudgeUp/images/background3.jpg new file mode 100644 index 0000000..b1e4211 Binary files /dev/null and b/DudgeUp/images/background3.jpg differ diff --git a/DudgeUp/images/brick-wall1.jpg b/DudgeUp/images/brick-wall1.jpg new file mode 100644 index 0000000..c7070f6 Binary files /dev/null and b/DudgeUp/images/brick-wall1.jpg differ diff --git a/DudgeUp/images/brick-wall2.jpg b/DudgeUp/images/brick-wall2.jpg new file mode 100644 index 0000000..f988473 Binary files /dev/null and b/DudgeUp/images/brick-wall2.jpg differ diff --git a/DudgeUp/images/brick-wall3.jpg b/DudgeUp/images/brick-wall3.jpg new file mode 100644 index 0000000..619755f Binary files /dev/null and b/DudgeUp/images/brick-wall3.jpg differ diff --git a/DudgeUp/images/heart.png b/DudgeUp/images/heart.png new file mode 100644 index 0000000..6a2ad79 Binary files /dev/null and b/DudgeUp/images/heart.png differ diff --git a/DudgeUp/images/star.png b/DudgeUp/images/star.png new file mode 100644 index 0000000..affe339 Binary files /dev/null and b/DudgeUp/images/star.png differ diff --git a/DudgeUp/images/stickMan.png b/DudgeUp/images/stickMan.png new file mode 100644 index 0000000..f7f41d6 Binary files /dev/null and b/DudgeUp/images/stickMan.png differ diff --git a/DudgeUp/libs/Core.Processing/core.jar b/DudgeUp/libs/Core.Processing/core.jar new file mode 100644 index 0000000..770d19a Binary files /dev/null and b/DudgeUp/libs/Core.Processing/core.jar differ diff --git a/DudgeUp/libs/Database/mysql-connector-j-8.0.33.jar b/DudgeUp/libs/Database/mysql-connector-j-8.0.33.jar new file mode 100644 index 0000000..3f741f5 Binary files /dev/null and b/DudgeUp/libs/Database/mysql-connector-j-8.0.33.jar differ diff --git a/DudgeUp/libs/Sound/javamp3-1.0.4.jar b/DudgeUp/libs/Sound/javamp3-1.0.4.jar new file mode 100644 index 0000000..dbc3217 Binary files /dev/null and b/DudgeUp/libs/Sound/javamp3-1.0.4.jar differ diff --git a/DudgeUp/libs/Sound/jsyn-17.1.0.jar b/DudgeUp/libs/Sound/jsyn-17.1.0.jar new file mode 100644 index 0000000..8193b3f Binary files /dev/null and b/DudgeUp/libs/Sound/jsyn-17.1.0.jar differ diff --git a/DudgeUp/libs/Sound/sound.jar b/DudgeUp/libs/Sound/sound.jar new file mode 100644 index 0000000..7605246 Binary files /dev/null and b/DudgeUp/libs/Sound/sound.jar differ diff --git a/DudgeUp/out/production/DodgeUp/BackGround.class b/DudgeUp/out/production/DodgeUp/BackGround.class new file mode 100644 index 0000000..ac3398f Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/BackGround.class differ diff --git a/DudgeUp/out/production/DodgeUp/Brick.class b/DudgeUp/out/production/DodgeUp/Brick.class new file mode 100644 index 0000000..1441662 Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/Brick.class differ diff --git a/DudgeUp/out/production/DodgeUp/Database.class b/DudgeUp/out/production/DodgeUp/Database.class new file mode 100644 index 0000000..6170d15 Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/Database.class differ diff --git a/DudgeUp/out/production/DodgeUp/DodgeUP.class b/DudgeUp/out/production/DodgeUp/DodgeUP.class new file mode 100644 index 0000000..329168f Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/DodgeUP.class differ diff --git a/DudgeUp/out/production/DodgeUp/Heart.class b/DudgeUp/out/production/DodgeUp/Heart.class new file mode 100644 index 0000000..7b0abeb Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/Heart.class differ diff --git a/DudgeUp/out/production/DodgeUp/Sound.class b/DudgeUp/out/production/DodgeUp/Sound.class new file mode 100644 index 0000000..35161ca Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/Sound.class differ diff --git a/DudgeUp/out/production/DodgeUp/Star.class b/DudgeUp/out/production/DodgeUp/Star.class new file mode 100644 index 0000000..6578c47 Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/Star.class differ diff --git a/DudgeUp/out/production/DodgeUp/StickMan.class b/DudgeUp/out/production/DodgeUp/StickMan.class new file mode 100644 index 0000000..44ec5c6 Binary files /dev/null and b/DudgeUp/out/production/DodgeUp/StickMan.class differ diff --git a/DudgeUp/sounds/bitQuest.wav b/DudgeUp/sounds/bitQuest.wav new file mode 100644 index 0000000..84bdb0f Binary files /dev/null and b/DudgeUp/sounds/bitQuest.wav differ diff --git a/DudgeUp/sounds/click.wav b/DudgeUp/sounds/click.wav new file mode 100644 index 0000000..8045121 Binary files /dev/null and b/DudgeUp/sounds/click.wav differ diff --git a/DudgeUp/sounds/gameOver.wav b/DudgeUp/sounds/gameOver.wav new file mode 100644 index 0000000..0674173 Binary files /dev/null and b/DudgeUp/sounds/gameOver.wav differ diff --git a/DudgeUp/sounds/getHit.wav b/DudgeUp/sounds/getHit.wav new file mode 100644 index 0000000..9a5db30 Binary files /dev/null and b/DudgeUp/sounds/getHit.wav differ diff --git a/DudgeUp/sounds/hover.wav b/DudgeUp/sounds/hover.wav new file mode 100644 index 0000000..dfa0b80 Binary files /dev/null and b/DudgeUp/sounds/hover.wav differ diff --git a/DudgeUp/sounds/score.wav b/DudgeUp/sounds/score.wav new file mode 100644 index 0000000..753c631 Binary files /dev/null and b/DudgeUp/sounds/score.wav differ diff --git a/DudgeUp/sounds/win.wav b/DudgeUp/sounds/win.wav new file mode 100644 index 0000000..b62f38c Binary files /dev/null and b/DudgeUp/sounds/win.wav differ diff --git a/DudgeUp/src/BackGround.java b/DudgeUp/src/BackGround.java new file mode 100644 index 0000000..1fd4c26 --- /dev/null +++ b/DudgeUp/src/BackGround.java @@ -0,0 +1,52 @@ +import processing.core.PImage; + +import java.util.Random; + +public class BackGround { + + public static PImage backgroundImage1; + private static PImage backgroundImage2; + + + + public static void loadBackgrounds () { + Random random = new Random(); + int index1 = random.nextInt(1,4); + int index2 = random.nextInt(1,4); + + + if (index1 == 1) { + backgroundImage1 = DodgeUP.processing.loadImage("images/background1.jpg"); + } + else if (index1 == 2) { + backgroundImage1 = DodgeUP.processing.loadImage("images/background2.jpg"); + } + else if (index1 == 3) { + backgroundImage1 = DodgeUP.processing.loadImage("images/background3.jpg"); + } + + + if (index2 == 1) { + backgroundImage2 = DodgeUP.processing.loadImage("images/brick-wall1.jpg"); + } + else if (index2 == 2) { + backgroundImage2 = DodgeUP.processing.loadImage("images/brick-wall2.jpg"); + } + else if (index2 == 3) { + backgroundImage2 = DodgeUP.processing.loadImage("images/brick-wall3.jpg"); + } + + + + + } + + + public static void showBackground1() { + DodgeUP.processing.image(backgroundImage1, 0, 0, 700, 600); + } + + public static void showBackground2() { + DodgeUP.processing.image(backgroundImage2, 0, 600, 700, 450); + } +} diff --git a/DudgeUp/src/Brick.java b/DudgeUp/src/Brick.java new file mode 100644 index 0000000..c538777 --- /dev/null +++ b/DudgeUp/src/Brick.java @@ -0,0 +1,132 @@ +import java.util.ArrayList; +import java.util.Random; + +public class Brick { + + + public static int speed; + + private static final int brickWidth = 60; + private static final int brickHeight = 30; + + + private final int brickX; + private int brickY; + private final int brickColorR; + private final int brickColorG; + private final int brickColorB; + + public Brick(int brickX, int brickY, int brickColorR, int brickColorG, int brickColorB) { + this.brickX = brickX; + this.brickY = brickY; + this.brickColorR = brickColorR; + this.brickColorG = brickColorG; + this.brickColorB = brickColorB; + } + + public static void makeBricks() { + Random random = new Random(); + DodgeUP.bricks = new ArrayList<>(); + int speedY = -100; + for (int i=0 ; i<10 ; i++) { + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + DodgeUP.bricks.add(new Brick(random.nextInt(30, 651), speedY, random.nextInt(253), random.nextInt(253), random.nextInt(253))); + speedY -= 100; + } + } + + public static void showBricks() { + for (Brick b: DodgeUP.bricks) { + DodgeUP.processing.noStroke(); + DodgeUP.processing.fill(b.brickColorR, b.brickColorG, b.brickColorB); + DodgeUP.processing.rect(b.brickX, b.brickY, Brick.brickWidth, Brick.brickHeight); + } + } + + public static void moveBricks() { + + for (Brick b: DodgeUP.bricks) { + b.brickY += speed; + } + } + + + + public static boolean checkCrash() { + for (Brick b: DodgeUP.bricks) { + + if (DodgeUP.processing.mouseX >= b.brickX && DodgeUP.processing.mouseX <= b.brickX + Brick.brickWidth && + 530 >= b.brickY && 530 <= b.brickY + Brick.brickHeight) { + + Sound.startHitSound(); + DodgeUP.bricks.remove(b); + return true; + } + + else if (DodgeUP.processing.mouseX+25 >= b.brickX && DodgeUP.processing.mouseX+25 <= b.brickX + Brick.brickWidth && + 530 >= b.brickY && 530 <= b.brickY + Brick.brickHeight) { + + Sound.startHitSound(); + DodgeUP.bricks.remove(b); + return true; + } + + else if (DodgeUP.processing.mouseX-25 >= b.brickX && DodgeUP.processing.mouseX-25 <= b.brickX + Brick.brickWidth && + 530 >= b.brickY && 530 <= b.brickY + Brick.brickHeight) { + + Sound.startHitSound(); + DodgeUP.bricks.remove(b); + return true; + } + + else if (DodgeUP.processing.mouseX-25 >= b.brickX && DodgeUP.processing.mouseX-25 <= b.brickX + Brick.brickWidth && + 565 >= b.brickY && 565 <= b.brickY + Brick.brickHeight) { + + Sound.startHitSound(); + DodgeUP.bricks.remove(b); + return true; + } + + else if (DodgeUP.processing.mouseX+25 >= b.brickX && DodgeUP.processing.mouseX+25 <= b.brickX + Brick.brickWidth && + 565 >= b.brickY && 565 <= b.brickY + Brick.brickHeight) { + + Sound.startHitSound(); + DodgeUP.bricks.remove(b); + return true; + } + + else if (DodgeUP.processing.mouseX >= b.brickX && DodgeUP.processing.mouseX <= b.brickX + Brick.brickWidth && + 600 >= b.brickY && 600 <= b.brickY + Brick.brickHeight) { + + Sound.startHitSound(); + DodgeUP.bricks.remove(b); + return true; + } + + } + + return false; + } + + + public int getBrickY() { + return brickY; + } +} diff --git a/DudgeUp/src/Database.java b/DudgeUp/src/Database.java new file mode 100644 index 0000000..1ec2681 --- /dev/null +++ b/DudgeUp/src/Database.java @@ -0,0 +1,54 @@ +import java.sql.*; + + +public abstract class Database { + + + public static long popHighScore() { + long highScore = 0; + try { + String url = "jdbc:mysql://localhost:3306/dodgeup"; + String user = "root"; + String pass = "@Javadss3"; + + Connection connection = DriverManager.getConnection(url, user, pass); + + Statement statement = connection.createStatement(); + ResultSet resultSet = statement.executeQuery("select * from score"); + + while (resultSet.next()) { + highScore = resultSet.getLong(1); + } + + + } catch (Exception e) { + e.printStackTrace(); + } + + return highScore; + } + + public static void pushHighScore(long newHighScore) { + + try { + String url = "jdbc:mysql://localhost:3306/dodgeup"; + String user = "root"; + String pass = "@Javadss3"; + + Connection connection = DriverManager.getConnection(url, user, pass); + + PreparedStatement statement = connection.prepareStatement("update score set highScore =?"); + + statement.setLong(1, newHighScore); + statement.executeUpdate(); + + + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + +} \ No newline at end of file diff --git a/DudgeUp/src/DodgeUP.java b/DudgeUp/src/DodgeUP.java new file mode 100644 index 0000000..d7fbc69 --- /dev/null +++ b/DudgeUp/src/DodgeUP.java @@ -0,0 +1,457 @@ +import processing.core.PApplet; +import processing.core.PFont; + + +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + + +public class DodgeUP extends PApplet{ + + public static PApplet processing; + + public static List bricks = new ArrayList<>(); + public static List stars = new ArrayList<>(); + + public static long score = 0; + public static long highScore = Database.popHighScore(); + + public static boolean gameOverSound; + public static boolean winSound; + public static boolean hoverSound; + + + public static boolean startOver = false; + public static boolean retryOver = false; + public static boolean exitOver = false; + public static boolean mainMenuOver = false; + public static boolean startChecker = false; + + + public static Color startColor; + public static Color exitColor; + public static Color mainMenuColor; + + public static boolean startMenuActivator = true; + public static boolean endMenuActivator = false; + + + + + public static void main(String[] args) { + + PApplet.main("DodgeUP" ,args); + + } + + + + @Override + public void setup() { + + processing = this; + + gameOverSound = true; + winSound = true; + + BackGround.loadBackgrounds(); + Sound.loadSounds(); + Sound.startMainSound(); + + + Brick.makeBricks(); + Heart.loadHeart(); + StickMan.loadStickMan(); + Star.loadStar(); + Brick.speed = 5; + } + + @Override + public void settings() { + size(700, 700); + smooth(8); + + } + + @Override + public void draw() { + + + startMenu(); + updateCoordinates(); + + if (startChecker) { + BackGround.showBackground1(); + + Brick.showBricks(); + Brick.moveBricks(); + + Star.showStar(); + Star.moveStar(); + + StickMan.showStickMan(); + + if (Brick.checkCrash()) { + Heart.lives--; + } + + if (Star.checkCrash()) { + score += 20; + } + + + increaseSpeed(); + showScore(); + Heart.showHeart(); + BackGround.showBackground2(); + + } + else { + frameCount = 0; + } + + + + gameOver(); + win(); + + } + + + + + + public void startMenu() { + + image(BackGround.backgroundImage1, 0, 0, 700, 700); + mouseHover(); + + PFont font = createFont("Serif.bold", 30); + textFont(font); + + fill(startColor); + text("Start",320, 320); + + fill(exitColor); + text("Exit",325, 400); + + fill(252, 244, 3); + textSize(60); + text("DodgeUP!", 225, 150); + + fill(8, 36, 252); + font = createFont("Serif.bolditalic", 30); + textFont(font); + text("Created By ShadowJavad...", 185, 600); + + } + + public void endMenu() { + + mouseHover(); + + PFont font = createFont("Serif.bold", 30); + textFont(font); + + fill(startColor); + text("Retry",318, 320); + + fill(mainMenuColor); + text("Main Menu",280, 410); + + fill(exitColor); + text("Exit",325, 500); + + + fill(252, 244, 3); + textSize(30); + text("Your Score : " + score, 255, 215); + textSize(20); + text("High Score : " + highScore, 290, 245); + + + + } + + + public void win() { + + if (bricks.size() == 0 && Heart.lives > 0) { + Sound.stopMainSound(); + + if (winSound) { + Sound.startWinSound(); + winSound = false; + } + + + startChecker = false; + endMenuActivator = true; + + background(0); + + PFont font = createFont("Serif.bold", 60); + textFont(font); + fill(7, 252, 3); + text("You Won!", 220, 150); + + endMenu(); + } + + } + + public void gameOver() { + + if (Heart.lives == 0) { + Sound.stopMainSound(); + + if (gameOverSound) { + Sound.startLoseSound(); + gameOverSound = false; + } + + + startChecker = false; + endMenuActivator = true; + + background(0); + + PFont font = createFont("Serif.bold", 60); + textFont(font); + fill(252, 3, 3); + textSize(60); + text("GameOver!", 200, 150); + + endMenu(); + } + + } + + + + public void showScore() { + DodgeUP.processing.noStroke(); + + for (int i=0 ; i= 600) { + bricks.remove(bricks.get(i)); + score++; + } + } + + if (score > highScore) { + highScore = score; + Database.pushHighScore(highScore); + } + + fill(0); + PFont font = createFont("Serif.bold", 30); + textFont(font); + text("Score : " + score, 0, 30); + textSize(20); + text("High Score : " + highScore, 0, 60); + } + + + public void updateCoordinates() { + + if (startMenuActivator) { + if ( overStart(320, 300, 63, 20) ) { + startOver = true; + exitOver = false; + } + + else if ( overExit(328, 380, 49, 20) ) { + startOver = false; + exitOver = true; + } + else { + startOver = exitOver = false; + } + + } + + else if (endMenuActivator) { + if (overRetry(321, 300, 68, 20)) { + exitOver = false; + retryOver = true; + } + + else if ( overMainMenu(283, 390, 145, 20) ) { + exitOver = false; + retryOver = false; + mainMenuOver = true; + } + + else if ( overExit(328, 480, 49, 20) ) { + exitOver = true; + retryOver = false; + mainMenuOver = false; + } + else { + exitOver = retryOver = mainMenuOver = false; + } + } + + + } + + + public void mousePressed() { + + if (startMenuActivator) { + if (startOver) { + Sound.startClickSound(); + startChecker = true; + startMenuActivator = false; + } + else if (exitOver) { + Sound.startClickSound(); + exit(); + } + } + + + else if (endMenuActivator) { + if (retryOver) { + Sound.startClickSound(); + Sound.stopLoseSound(); + Sound.stopWinSound(); + + startChecker = true; + endMenuActivator = false; + restart(); + } + + else if (mainMenuOver) { + Sound.startClickSound(); + Sound.stopLoseSound(); + Sound.stopWinSound(); + + endMenuActivator = false; + startMenuActivator = true; + restart(); + } + + else if (exitOver) { + Sound.startClickSound(); + exit(); + } + } + } + + public void mouseHover() { + + if (endMenuActivator) { + if (retryOver) { + startColor = new Color(7, 252, 3); + if (hoverSound) { + Sound.startHoverSound(); + hoverSound = false; + } + } + else { + startColor = new Color(252, 252, 252); + } + + if (mainMenuOver) { + if (hoverSound) { + Sound.startHoverSound(); + hoverSound = false; + } + mainMenuColor = new Color(8, 36, 252); + } + else { + mainMenuColor = new Color(252, 252, 252); + } + + if (exitOver) { + if (hoverSound) { + Sound.startHoverSound(); + hoverSound = false; + } + exitColor = new Color(252, 3, 3); + } + else { + exitColor = new Color(252, 252, 252); + } + + if (!exitOver && !retryOver && !mainMenuOver) { + hoverSound = true; + } + + + } + + else if(startMenuActivator){ + if (startOver) { + startColor = new Color(7, 252, 3); + if (hoverSound) { + Sound.startHoverSound(); + hoverSound = false; + } + } + else { + startColor = new Color(0, 0, 0); + } + + if (exitOver) { + exitColor = new Color(252, 3, 3); + if (hoverSound) { + Sound.startHoverSound(); + hoverSound = false; + } + } + else { + exitColor = new Color(0, 0, 0); + } + + if (!exitOver && !startOver) { + hoverSound = true; + } + + + } + + + + + } + + + public boolean overMainMenu(int x, int y,int width, int height) { + return mouseX >= x && mouseX <= x + width && + mouseY >= y && mouseY <= y + height; + } + public boolean overRetry(int x, int y,int width, int height) { + return mouseX >= x && mouseX <= x + width && + mouseY >= y && mouseY <= y + height; + } + public boolean overExit(int x, int y, int width, int height) { + return mouseX >= x && mouseX <= x + width && + mouseY >= y && mouseY <= y + height; + } + + public boolean overStart(int x, int y,int width, int height) { + return mouseX >= x && mouseX <= x + width && + mouseY >= y && mouseY <= y + height; + } + + private void fill(Color color) { + fill(color.getRGB()); + } + + public void restart() { + score = 0; + setup(); + } + + public void increaseSpeed() { + + if (frameCount % 600 == 0) { + Brick.speed ++; + } + + } +} \ No newline at end of file diff --git a/DudgeUp/src/Heart.java b/DudgeUp/src/Heart.java new file mode 100644 index 0000000..22f65ba --- /dev/null +++ b/DudgeUp/src/Heart.java @@ -0,0 +1,29 @@ +import processing.core.PImage; + +public class Heart { + + private static PImage heart; + public static int lives = 3; + + public static void loadHeart() { + lives = 3; + heart = DodgeUP.processing.loadImage("images/heart.png"); + } + public static void showHeart() { + DodgeUP.processing.noStroke(); + + if (lives == 3) { + DodgeUP.processing.image(heart, 645,10, 50,50); + DodgeUP.processing.image(heart, 590,10, 50,50); + DodgeUP.processing.image(heart, 535,10, 50,50); + } + else if (lives == 2) { + DodgeUP.processing.image(heart, 645,10, 50,50); + DodgeUP.processing.image(heart, 590,10, 50,50); + } + else { + DodgeUP.processing.image(heart, 645,10, 50,50); + } + + } +} diff --git a/DudgeUp/src/Sound.java b/DudgeUp/src/Sound.java new file mode 100644 index 0000000..4a5f16b --- /dev/null +++ b/DudgeUp/src/Sound.java @@ -0,0 +1,68 @@ +import processing.sound.SoundFile; + +public class Sound { + private static SoundFile mainSound; + private static SoundFile clickSound; + private static SoundFile hoverSound; + private static SoundFile hitSound; + private static SoundFile scoreSound; + private static SoundFile winSound; + private static SoundFile loseSound; + + + public static void loadSounds() { + mainSound = new SoundFile(DodgeUP.processing, "sounds/bitQuest.wav"); + clickSound = new SoundFile(DodgeUP.processing, "sounds/click.wav"); + hoverSound = new SoundFile(DodgeUP.processing, "sounds/hover.wav"); + hitSound = new SoundFile(DodgeUP.processing, "sounds/getHit.wav"); + scoreSound = new SoundFile(DodgeUP.processing, "sounds/score.wav"); + winSound = new SoundFile(DodgeUP.processing, "sounds/win.wav"); + loseSound = new SoundFile(DodgeUP.processing, "sounds/gameOver.wav"); + } + + public static void startMainSound() { + mainSound.play(); + mainSound.loop(); + } + public static void startClickSound() { + clickSound.play(); + } + public static void startHoverSound() { + hoverSound.play(); + } + public static void startHitSound() { + hitSound.play(); + } + public static void startScoreSound() { + scoreSound.play(); + } + public static void startWinSound() { + if (!winSound.isPlaying()) { + winSound.play(); + } + } + public static void startLoseSound() { + if (!loseSound.isPlaying()) { + loseSound.play(); + } + } + + + + public static void stopMainSound() { + if (mainSound.isPlaying()) { + mainSound.stop(); + } + } + public static void stopLoseSound() { + if (loseSound.isPlaying()) { + loseSound.stop(); + } + } + public static void stopWinSound() { + if (winSound.isPlaying()) { + winSound.stop(); + } + } + +} diff --git a/DudgeUp/src/Star.java b/DudgeUp/src/Star.java new file mode 100644 index 0000000..21b8771 --- /dev/null +++ b/DudgeUp/src/Star.java @@ -0,0 +1,100 @@ +import processing.core.PImage; + +import java.util.ArrayList; +import java.util.Random; + +public class Star { + + private static PImage star; + public static int width = 40; + public static int height = 40; + + private final int starX; + private int starY; + + + public Star(int starX, int starY) { + this.starX = starX; + this.starY = starY; + } + + public static void loadStar() { + + star = DodgeUP.processing.loadImage("images/star.png"); + Random random = new Random(); + DodgeUP.stars = new ArrayList<>(); + for (int i=0 ; i<30 ; i++) { + DodgeUP.stars.add(new Star(random.nextInt(10, 650), random.nextInt(-10000, -100 ))); + } + } + public static void showStar() { + + for (Star s:DodgeUP.stars) { + DodgeUP.processing.image(star, s.starX, s.starY, Star.width, Star.height); + } + + } + + public static void moveStar() { + for (Star s:DodgeUP.stars) { + s.starY += 5; + } + } + + public static boolean checkCrash() { + for (Star s: DodgeUP.stars) { + + if (DodgeUP.processing.mouseX >= s.starX && DodgeUP.processing.mouseX <= s.starX + Star.width && + 530 >= s.starY && 530 <= s.starY + Star.height) { + + Sound.startScoreSound(); + DodgeUP.stars.remove(s); + return true; + } + else if (DodgeUP.processing.mouseX+25 >= s.starX && DodgeUP.processing.mouseX+25 <= s.starX + Star.width && + 530 >= s.starY && 530 <= s.starY + Star.height) { + + Sound.startScoreSound(); + DodgeUP.stars.remove(s); + return true; + } + else if (DodgeUP.processing.mouseX-25 >= s.starX && DodgeUP.processing.mouseX-25 <= s.starX + Star.width && + 530 >= s.starY && 530 <= s.starY + Star.height) { + + Sound.startScoreSound(); + DodgeUP.stars.remove(s); + return true; + } + + else if (DodgeUP.processing.mouseX-25 >= s.starX && DodgeUP.processing.mouseX-25 <= s.starX + Star.width && + 565 >= s.starY && 565 <= s.starY + Star.height) { + + Sound.startScoreSound(); + DodgeUP.stars.remove(s); + return true; + } + + else if (DodgeUP.processing.mouseX+25 >= s.starX && DodgeUP.processing.mouseX+25 <= s.starX + Star.width && + 565 >= s.starY && 556 <= s.starY + Star.height) { + + Sound.startScoreSound(); + DodgeUP.stars.remove(s); + return true; + } + + else if (DodgeUP.processing.mouseX >= s.starX && DodgeUP.processing.mouseX <= s.starX + Star.width && + 600 >= s.starY && 600 <= s.starY + Star.height) { + + Sound.startScoreSound(); + DodgeUP.stars.remove(s); + return true; + } + + } + + return false; + } + + + +} diff --git a/DudgeUp/src/StickMan.java b/DudgeUp/src/StickMan.java new file mode 100644 index 0000000..38c3be6 --- /dev/null +++ b/DudgeUp/src/StickMan.java @@ -0,0 +1,19 @@ +import processing.core.PImage; + +public class StickMan { + + + private static PImage stickMan; + + public static void loadStickMan() { + stickMan = DodgeUP.processing.loadImage("images/stickMan.png"); + } + public static void showStickMan() { + int directionX = DodgeUP.processing.mouseX - 25; + + DodgeUP.processing.image(stickMan, directionX,530, 50,70); + + } + + +}