Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions DudgeUp/.gitignore
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions DudgeUp/DodgeUp.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="core" level="project" />
<orderEntry type="library" exported="" name="mysql-connector-j-8.0.33" level="project" />
<orderEntry type="library" exported="" name="sound" level="project" />
</component>
</module>
50 changes: 50 additions & 0 deletions DudgeUp/DodgeUp.sql
Original file line number Diff line number Diff line change
@@ -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
Binary file added DudgeUp/images/background1.jpg
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 DudgeUp/images/background2.jpg
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 DudgeUp/images/background3.jpg
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 DudgeUp/images/brick-wall1.jpg
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 DudgeUp/images/brick-wall2.jpg
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 DudgeUp/images/brick-wall3.jpg
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 DudgeUp/images/heart.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 DudgeUp/images/star.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 DudgeUp/images/stickMan.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 DudgeUp/libs/Core.Processing/core.jar
Binary file not shown.
Binary file not shown.
Binary file added DudgeUp/libs/Sound/javamp3-1.0.4.jar
Binary file not shown.
Binary file added DudgeUp/libs/Sound/jsyn-17.1.0.jar
Binary file not shown.
Binary file added DudgeUp/libs/Sound/sound.jar
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/BackGround.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/Brick.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/Database.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/DodgeUP.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/Heart.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/Sound.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/Star.class
Binary file not shown.
Binary file added DudgeUp/out/production/DodgeUp/StickMan.class
Binary file not shown.
Binary file added DudgeUp/sounds/bitQuest.wav
Binary file not shown.
Binary file added DudgeUp/sounds/click.wav
Binary file not shown.
Binary file added DudgeUp/sounds/gameOver.wav
Binary file not shown.
Binary file added DudgeUp/sounds/getHit.wav
Binary file not shown.
Binary file added DudgeUp/sounds/hover.wav
Binary file not shown.
Binary file added DudgeUp/sounds/score.wav
Binary file not shown.
Binary file added DudgeUp/sounds/win.wav
Binary file not shown.
52 changes: 52 additions & 0 deletions DudgeUp/src/BackGround.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
132 changes: 132 additions & 0 deletions DudgeUp/src/Brick.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
54 changes: 54 additions & 0 deletions DudgeUp/src/Database.java
Original file line number Diff line number Diff line change
@@ -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();
}

}


}
Loading