diff --git a/.gradle/7.5.1/checksums/checksums.lock b/.gradle/7.5.1/checksums/checksums.lock new file mode 100644 index 0000000..f7f877f Binary files /dev/null and b/.gradle/7.5.1/checksums/checksums.lock differ diff --git a/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock new file mode 100644 index 0000000..ed2f2f6 Binary files /dev/null and b/.gradle/7.5.1/dependencies-accessors/dependencies-accessors.lock differ diff --git a/.gradle/7.5.1/dependencies-accessors/gc.properties b/.gradle/7.5.1/dependencies-accessors/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/7.5.1/executionHistory/executionHistory.bin b/.gradle/7.5.1/executionHistory/executionHistory.bin new file mode 100644 index 0000000..6c3fa1b Binary files /dev/null and b/.gradle/7.5.1/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.5.1/executionHistory/executionHistory.lock b/.gradle/7.5.1/executionHistory/executionHistory.lock new file mode 100644 index 0000000..8da2413 Binary files /dev/null and b/.gradle/7.5.1/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.5.1/fileChanges/last-build.bin b/.gradle/7.5.1/fileChanges/last-build.bin new file mode 100644 index 0000000..f76dd23 Binary files /dev/null and b/.gradle/7.5.1/fileChanges/last-build.bin differ diff --git a/.gradle/7.5.1/fileHashes/fileHashes.bin b/.gradle/7.5.1/fileHashes/fileHashes.bin new file mode 100644 index 0000000..658f29f Binary files /dev/null and b/.gradle/7.5.1/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.5.1/fileHashes/fileHashes.lock b/.gradle/7.5.1/fileHashes/fileHashes.lock new file mode 100644 index 0000000..f42a244 Binary files /dev/null and b/.gradle/7.5.1/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.5.1/fileHashes/resourceHashesCache.bin b/.gradle/7.5.1/fileHashes/resourceHashesCache.bin new file mode 100644 index 0000000..50bfc86 Binary files /dev/null and b/.gradle/7.5.1/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/7.5.1/gc.properties b/.gradle/7.5.1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock new file mode 100644 index 0000000..a428af2 Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties new file mode 100644 index 0000000..f6fbb74 --- /dev/null +++ b/.gradle/buildOutputCleanup/cache.properties @@ -0,0 +1,2 @@ +#Fri Feb 24 01:06:16 PST 2023 +gradle.version=7.5.1 diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin new file mode 100644 index 0000000..925e47f Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe new file mode 100644 index 0000000..a8faf55 Binary files /dev/null and b/.gradle/file-system.probe differ diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties new file mode 100644 index 0000000..e69de29 diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml new file mode 100644 index 0000000..c370431 --- /dev/null +++ b/.idea/checkstyle-idea.xml @@ -0,0 +1,16 @@ + + + + 10.5.0 + JavaOnly + true + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..2aa056d --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..dd3a117 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..fdc392f --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__junit_junit_4_13_1.xml b/.idea/libraries/Gradle__junit_junit_4_13_1.xml new file mode 100644 index 0000000..f28cdec --- /dev/null +++ b/.idea/libraries/Gradle__junit_junit_4_13_1.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_apiguardian_apiguardian_api_1_1_2.xml b/.idea/libraries/Gradle__org_apiguardian_apiguardian_api_1_1_2.xml new file mode 100644 index 0000000..ec7423e --- /dev/null +++ b/.idea/libraries/Gradle__org_apiguardian_apiguardian_api_1_1_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..8262f72 --- /dev/null +++ b/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_api_5_8_1.xml b/.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_api_5_8_1.xml new file mode 100644 index 0000000..e4ec376 --- /dev/null +++ b/.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_api_5_8_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_engine_5_8_1.xml b/.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_engine_5_8_1.xml new file mode 100644 index 0000000..4da4781 --- /dev/null +++ b/.idea/libraries/Gradle__org_junit_jupiter_junit_jupiter_engine_5_8_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_junit_platform_junit_platform_commons_1_8_1.xml b/.idea/libraries/Gradle__org_junit_platform_junit_platform_commons_1_8_1.xml new file mode 100644 index 0000000..ec1b37e --- /dev/null +++ b/.idea/libraries/Gradle__org_junit_platform_junit_platform_commons_1_8_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_junit_platform_junit_platform_engine_1_8_1.xml b/.idea/libraries/Gradle__org_junit_platform_junit_platform_engine_1_8_1.xml new file mode 100644 index 0000000..2940fd5 --- /dev/null +++ b/.idea/libraries/Gradle__org_junit_platform_junit_platform_engine_1_8_1.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_mongodb_bson_4_9_0.xml b/.idea/libraries/Gradle__org_mongodb_bson_4_9_0.xml new file mode 100644 index 0000000..2292b49 --- /dev/null +++ b/.idea/libraries/Gradle__org_mongodb_bson_4_9_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_mongodb_bson_record_codec_4_9_0.xml b/.idea/libraries/Gradle__org_mongodb_bson_record_codec_4_9_0.xml new file mode 100644 index 0000000..9e50e0b --- /dev/null +++ b/.idea/libraries/Gradle__org_mongodb_bson_record_codec_4_9_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_mongodb_mongodb_driver_core_4_9_0.xml b/.idea/libraries/Gradle__org_mongodb_mongodb_driver_core_4_9_0.xml new file mode 100644 index 0000000..f31d4e4 --- /dev/null +++ b/.idea/libraries/Gradle__org_mongodb_mongodb_driver_core_4_9_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_mongodb_mongodb_driver_sync_4_9_0.xml b/.idea/libraries/Gradle__org_mongodb_mongodb_driver_sync_4_9_0.xml new file mode 100644 index 0000000..f15f570 --- /dev/null +++ b/.idea/libraries/Gradle__org_mongodb_mongodb_driver_sync_4_9_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Gradle__org_opentest4j_opentest4j_1_2_0.xml b/.idea/libraries/Gradle__org_opentest4j_opentest4j_1_2_0.xml new file mode 100644 index 0000000..c0ad60c --- /dev/null +++ b/.idea/libraries/Gradle__org_opentest4j_opentest4j_1_2_0.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/library.xml b/.idea/libraries/library.xml new file mode 100644 index 0000000..d7d7f5f --- /dev/null +++ b/.idea/libraries/library.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0d32c34 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..206e6ce --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/bcit.comp2522.project-team-a.project-team-a.iml b/.idea/modules/bcit.comp2522.project-team-a.project-team-a.iml new file mode 100644 index 0000000..511d5da --- /dev/null +++ b/.idea/modules/bcit.comp2522.project-team-a.project-team-a.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/bcit.comp2522.project-team-a.project-team-a.main.iml b/.idea/modules/bcit.comp2522.project-team-a.project-team-a.main.iml new file mode 100644 index 0000000..027a653 --- /dev/null +++ b/.idea/modules/bcit.comp2522.project-team-a.project-team-a.main.iml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/bcit.comp2522.project-team-a.project-team-a.test.iml b/.idea/modules/bcit.comp2522.project-team-a.project-team-a.test.iml new file mode 100644 index 0000000..7be8385 --- /dev/null +++ b/.idea/modules/bcit.comp2522.project-team-a.project-team-a.test.iml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/project-team-a.main.iml b/.idea/modules/project-team-a.main.iml new file mode 100644 index 0000000..22fc826 --- /dev/null +++ b/.idea/modules/project-team-a.main.iml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/project-team-a.test.iml b/.idea/modules/project-team-a.test.iml new file mode 100644 index 0000000..3ba1a8a --- /dev/null +++ b/.idea/modules/project-team-a.test.iml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/src/project-team-a.src.iml b/.idea/modules/src/project-team-a.src.iml new file mode 100644 index 0000000..aa47021 --- /dev/null +++ b/.idea/modules/src/project-team-a.src.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/project-team-a.iml b/.idea/project-team-a.iml new file mode 100644 index 0000000..6f5ad5a --- /dev/null +++ b/.idea/project-team-a.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/A_UML.pdf b/A_UML.pdf new file mode 100644 index 0000000..c7ac1e7 Binary files /dev/null and b/A_UML.pdf differ diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..56eab55 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,15 @@ +# Lines starting with '#' are comments. +# Each line is a file pattern followed by one or more owners. + +# More details are here: https://help.github.com/articles/about-codeowners/ + +# The '*' pattern is global owners. + +# Order is important. The last matching pattern has the most precedence. +# The folders are ordered as follows: + +# In each subsection folders are ordered first by depth, then alphabetically. +# This should make it easy to add new rules without breaking existing ones. + +# Global rule: +* @dlau72 diff --git a/Pitch.md b/Pitch.md new file mode 100644 index 0000000..c090de1 --- /dev/null +++ b/Pitch.md @@ -0,0 +1,38 @@ +Project pitch + +- small game +- pacman +- shooting plane game +- snake.io +- agar.io +- + +Pitch - A top down interactive space shooter game that player object shoots +bullet towards the enemy to gain score. + +Outline - 1. We will use the processing.org library to incorporate the player and the enemy, and all the other objectives will be conducted via this interface. + +2. We will commit, push, and pull regularly to let the teammates to know the process that is happening and let them know what to do + +3. We will use a database to save data of enemy structure and number of scores. + +4. We will have a collection of enemies and when the enemies are hit by a ‘bullet ’of the player, we will delete the enemy from the collection. We will also keep adding enemies in the collection continuously. + +5. We will try our best to make the project and finish it with the best result. + + +Communication policies - Using discord to communicate and have time set up for meeting in-person. + +Roles and responsibilities - + +Architect: you are in charge of the high-level code structuring and organizing. + +Test maker: you are in charge of test coverage that supports other group members. +UI/UX lead: you design and implement the user interface. + +Backend: you design and implement the data structures. + +Every member of the team will be included in every role and work through it together. + + +Milestone - Estimated until week 15 diff --git a/README.md b/README.md index 39f2fd3..8771277 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ## Technical Project Requirements +Hello world The minimum requirements for the project are outlined here to give you a starting point. Meeting the minimum requirements alone will not guarantee you a good mark. You are welcome to meet and exceed the minimum requirements if you have good, creative ideas and would like to discuss them with me. **Requirement 1**: The project must incorporate some visual interface using Processing.org libraries. All user interaction must be conducted via this interface. diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..45d480a --- /dev/null +++ b/build.gradle @@ -0,0 +1,21 @@ +plugins { + id 'java' +} + +group 'bcit.comp2522.project-team-a' +version '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +dependencies { + implementation fileTree(dir: 'library', include: ['*.jar']) + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + implementation 'org.mongodb:mongodb-driver-sync:4.9.0' +} + +test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin new file mode 100644 index 0000000..82885e7 Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..ae04661 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..a69d9cb --- /dev/null +++ b/gradlew @@ -0,0 +1,240 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f127cfd --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,91 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/images/GameOver.png b/images/GameOver.png new file mode 100644 index 0000000..9b2cdd9 Binary files /dev/null and b/images/GameOver.png differ diff --git a/images/background.png b/images/background.png new file mode 100644 index 0000000..e52ddbd Binary files /dev/null and b/images/background.png differ diff --git a/images/backgroundI.png b/images/backgroundI.png new file mode 100644 index 0000000..202d29d Binary files /dev/null and b/images/backgroundI.png differ diff --git a/images/titleImage.png b/images/titleImage.png new file mode 100644 index 0000000..eb669a7 Binary files /dev/null and b/images/titleImage.png differ diff --git a/library/linux-aarch64/libgluegen_rt.so b/library/linux-aarch64/libgluegen_rt.so new file mode 100644 index 0000000..512015b Binary files /dev/null and b/library/linux-aarch64/libgluegen_rt.so differ diff --git a/library/linux-aarch64/libjogl_desktop.so b/library/linux-aarch64/libjogl_desktop.so new file mode 100644 index 0000000..7e98c64 Binary files /dev/null and b/library/linux-aarch64/libjogl_desktop.so differ diff --git a/library/linux-aarch64/libjogl_mobile.so b/library/linux-aarch64/libjogl_mobile.so new file mode 100644 index 0000000..05ad1aa Binary files /dev/null and b/library/linux-aarch64/libjogl_mobile.so differ diff --git a/library/linux-aarch64/libnativewindow_awt.so b/library/linux-aarch64/libnativewindow_awt.so new file mode 100644 index 0000000..6e6de87 Binary files /dev/null and b/library/linux-aarch64/libnativewindow_awt.so differ diff --git a/library/linux-aarch64/libnativewindow_drm.so b/library/linux-aarch64/libnativewindow_drm.so new file mode 100644 index 0000000..482d59f Binary files /dev/null and b/library/linux-aarch64/libnativewindow_drm.so differ diff --git a/library/linux-aarch64/libnativewindow_x11.so b/library/linux-aarch64/libnativewindow_x11.so new file mode 100644 index 0000000..f9232a5 Binary files /dev/null and b/library/linux-aarch64/libnativewindow_x11.so differ diff --git a/library/linux-aarch64/libnewt_drm.so b/library/linux-aarch64/libnewt_drm.so new file mode 100644 index 0000000..74001d3 Binary files /dev/null and b/library/linux-aarch64/libnewt_drm.so differ diff --git a/library/linux-aarch64/libnewt_head.so b/library/linux-aarch64/libnewt_head.so new file mode 100644 index 0000000..e96960f Binary files /dev/null and b/library/linux-aarch64/libnewt_head.so differ diff --git a/library/linux-amd64/libgluegen_rt.so b/library/linux-amd64/libgluegen_rt.so new file mode 100644 index 0000000..6222112 Binary files /dev/null and b/library/linux-amd64/libgluegen_rt.so differ diff --git a/library/linux-amd64/libjogl_desktop.so b/library/linux-amd64/libjogl_desktop.so new file mode 100644 index 0000000..12f3b5a Binary files /dev/null and b/library/linux-amd64/libjogl_desktop.so differ diff --git a/library/linux-amd64/libjogl_mobile.so b/library/linux-amd64/libjogl_mobile.so new file mode 100644 index 0000000..1f941cb Binary files /dev/null and b/library/linux-amd64/libjogl_mobile.so differ diff --git a/library/linux-amd64/libnativewindow_awt.so b/library/linux-amd64/libnativewindow_awt.so new file mode 100644 index 0000000..78e7849 Binary files /dev/null and b/library/linux-amd64/libnativewindow_awt.so differ diff --git a/library/linux-amd64/libnativewindow_drm.so b/library/linux-amd64/libnativewindow_drm.so new file mode 100644 index 0000000..567a4ba Binary files /dev/null and b/library/linux-amd64/libnativewindow_drm.so differ diff --git a/library/linux-amd64/libnativewindow_x11.so b/library/linux-amd64/libnativewindow_x11.so new file mode 100644 index 0000000..6cc0922 Binary files /dev/null and b/library/linux-amd64/libnativewindow_x11.so differ diff --git a/library/linux-amd64/libnewt_drm.so b/library/linux-amd64/libnewt_drm.so new file mode 100644 index 0000000..3fe44f6 Binary files /dev/null and b/library/linux-amd64/libnewt_drm.so differ diff --git a/library/linux-amd64/libnewt_head.so b/library/linux-amd64/libnewt_head.so new file mode 100644 index 0000000..76712a5 Binary files /dev/null and b/library/linux-amd64/libnewt_head.so differ diff --git a/library/linux-arm/libgluegen_rt.so b/library/linux-arm/libgluegen_rt.so new file mode 100644 index 0000000..68bdda7 Binary files /dev/null and b/library/linux-arm/libgluegen_rt.so differ diff --git a/library/linux-arm/libjogl_desktop.so b/library/linux-arm/libjogl_desktop.so new file mode 100644 index 0000000..9413d57 Binary files /dev/null and b/library/linux-arm/libjogl_desktop.so differ diff --git a/library/linux-arm/libjogl_mobile.so b/library/linux-arm/libjogl_mobile.so new file mode 100644 index 0000000..8f016ea Binary files /dev/null and b/library/linux-arm/libjogl_mobile.so differ diff --git a/library/linux-arm/libnativewindow_awt.so b/library/linux-arm/libnativewindow_awt.so new file mode 100644 index 0000000..941697a Binary files /dev/null and b/library/linux-arm/libnativewindow_awt.so differ diff --git a/library/linux-arm/libnativewindow_drm.so b/library/linux-arm/libnativewindow_drm.so new file mode 100644 index 0000000..fba0800 Binary files /dev/null and b/library/linux-arm/libnativewindow_drm.so differ diff --git a/library/linux-arm/libnativewindow_x11.so b/library/linux-arm/libnativewindow_x11.so new file mode 100644 index 0000000..bd249bf Binary files /dev/null and b/library/linux-arm/libnativewindow_x11.so differ diff --git a/library/linux-arm/libnewt_drm.so b/library/linux-arm/libnewt_drm.so new file mode 100644 index 0000000..b8cde98 Binary files /dev/null and b/library/linux-arm/libnewt_drm.so differ diff --git a/library/linux-arm/libnewt_head.so b/library/linux-arm/libnewt_head.so new file mode 100644 index 0000000..87c31ed Binary files /dev/null and b/library/linux-arm/libnewt_head.so differ diff --git a/library/macos-aarch64/libgluegen_rt.dylib b/library/macos-aarch64/libgluegen_rt.dylib new file mode 100644 index 0000000..2813350 Binary files /dev/null and b/library/macos-aarch64/libgluegen_rt.dylib differ diff --git a/library/macos-aarch64/libjogl_desktop.dylib b/library/macos-aarch64/libjogl_desktop.dylib new file mode 100644 index 0000000..9a90c21 Binary files /dev/null and b/library/macos-aarch64/libjogl_desktop.dylib differ diff --git a/library/macos-aarch64/libjogl_mobile.dylib b/library/macos-aarch64/libjogl_mobile.dylib new file mode 100644 index 0000000..90fbcc7 Binary files /dev/null and b/library/macos-aarch64/libjogl_mobile.dylib differ diff --git a/library/macos-aarch64/libnativewindow_awt.dylib b/library/macos-aarch64/libnativewindow_awt.dylib new file mode 100644 index 0000000..a417903 Binary files /dev/null and b/library/macos-aarch64/libnativewindow_awt.dylib differ diff --git a/library/macos-aarch64/libnativewindow_macosx.dylib b/library/macos-aarch64/libnativewindow_macosx.dylib new file mode 100644 index 0000000..0c94974 Binary files /dev/null and b/library/macos-aarch64/libnativewindow_macosx.dylib differ diff --git a/library/macos-aarch64/libnewt_head.dylib b/library/macos-aarch64/libnewt_head.dylib new file mode 100644 index 0000000..b23a557 Binary files /dev/null and b/library/macos-aarch64/libnewt_head.dylib differ diff --git a/library/macos-x86_64/libgluegen_rt.dylib b/library/macos-x86_64/libgluegen_rt.dylib new file mode 100644 index 0000000..ba356f6 Binary files /dev/null and b/library/macos-x86_64/libgluegen_rt.dylib differ diff --git a/library/macos-x86_64/libjogl_desktop.dylib b/library/macos-x86_64/libjogl_desktop.dylib new file mode 100644 index 0000000..0133fe9 Binary files /dev/null and b/library/macos-x86_64/libjogl_desktop.dylib differ diff --git a/library/macos-x86_64/libjogl_mobile.dylib b/library/macos-x86_64/libjogl_mobile.dylib new file mode 100644 index 0000000..bc1e6bc Binary files /dev/null and b/library/macos-x86_64/libjogl_mobile.dylib differ diff --git a/library/macos-x86_64/libnativewindow_awt.dylib b/library/macos-x86_64/libnativewindow_awt.dylib new file mode 100644 index 0000000..f74a89e Binary files /dev/null and b/library/macos-x86_64/libnativewindow_awt.dylib differ diff --git a/library/macos-x86_64/libnativewindow_macosx.dylib b/library/macos-x86_64/libnativewindow_macosx.dylib new file mode 100644 index 0000000..14b4769 Binary files /dev/null and b/library/macos-x86_64/libnativewindow_macosx.dylib differ diff --git a/library/macos-x86_64/libnewt_head.dylib b/library/macos-x86_64/libnewt_head.dylib new file mode 100644 index 0000000..32b507f Binary files /dev/null and b/library/macos-x86_64/libnewt_head.dylib differ diff --git a/library/windows-amd64/fenster.exe b/library/windows-amd64/fenster.exe new file mode 100644 index 0000000..8108d17 Binary files /dev/null and b/library/windows-amd64/fenster.exe differ diff --git a/library/windows-amd64/gluegen_rt.dll b/library/windows-amd64/gluegen_rt.dll new file mode 100644 index 0000000..65b2f6b Binary files /dev/null and b/library/windows-amd64/gluegen_rt.dll differ diff --git a/library/windows-amd64/jogl_desktop.dll b/library/windows-amd64/jogl_desktop.dll new file mode 100644 index 0000000..5c62f78 Binary files /dev/null and b/library/windows-amd64/jogl_desktop.dll differ diff --git a/library/windows-amd64/jogl_mobile.dll b/library/windows-amd64/jogl_mobile.dll new file mode 100644 index 0000000..fc6dfdc Binary files /dev/null and b/library/windows-amd64/jogl_mobile.dll differ diff --git a/library/windows-amd64/nativewindow_awt.dll b/library/windows-amd64/nativewindow_awt.dll new file mode 100644 index 0000000..8c0c64f Binary files /dev/null and b/library/windows-amd64/nativewindow_awt.dll differ diff --git a/library/windows-amd64/nativewindow_win32.dll b/library/windows-amd64/nativewindow_win32.dll new file mode 100644 index 0000000..d5ed2f3 Binary files /dev/null and b/library/windows-amd64/nativewindow_win32.dll differ diff --git a/library/windows-amd64/newt_head.dll b/library/windows-amd64/newt_head.dll new file mode 100644 index 0000000..25c12f0 Binary files /dev/null and b/library/windows-amd64/newt_head.dll differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..95ca13e --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +include 'src' + diff --git a/src/main/java/bcit/comp2522/projectteama/Bullet.java b/src/main/java/bcit/comp2522/projectteama/Bullet.java new file mode 100644 index 0000000..4e6d894 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Bullet.java @@ -0,0 +1,29 @@ +package bcit.comp2522.projectteama; + +import processing.core.PVector; + +import java.awt.*; + +public class Bullet extends Sprite implements Collidable{ + protected int damage; + + public Bullet(PVector position, PVector direction, float width, float height, + float speed, Color color, Window window, Rectangle hitBox, int damage) { + super(position, direction, width, height, speed, color, window, hitBox); + this.damage = damage; + } + + public int getDamage() { + return damage; + } + + @Override + public void handleCollision(Collidable other) { + if (other instanceof Enemy) { + if (this.isCollidingWith(other)) { + // Do something if colliding + window.getBManager().remove(this); + } + } + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/BulletManager.java b/src/main/java/bcit/comp2522/projectteama/BulletManager.java new file mode 100644 index 0000000..62daa7b --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/BulletManager.java @@ -0,0 +1,41 @@ +package bcit.comp2522.projectteama; + +import java.awt.*; +import java.util.ArrayList; +import processing.core.PApplet; +import processing.core.PVector; +import processing.event.KeyEvent; +public class BulletManager extends Manager{ + private Window window; + + private ArrayList bullets = new ArrayList(); + public BulletManager(Window window) { + this.window = window; + } + + public ArrayList getBullets() { + return bullets; + } + + //@Override + public void add(PVector position, PVector direction) { + Bullet bullet = new Bullet(position, direction, 15, 15, + 10, new Color(0, 0, 255), window, + new Rectangle((int) position.x, (int)direction.y, 30, 30), 1); + + bullet.setHitBox(); + bullets.add(bullet); + } + + @Override + public void add() { + + } + + + + //@Override + public void remove(Bullet bullet) { + bullets.remove(bullet); + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/Button.java b/src/main/java/bcit/comp2522/projectteama/Button.java new file mode 100644 index 0000000..3e2ace9 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Button.java @@ -0,0 +1,42 @@ +package bcit.comp2522.projectteama; + +import processing.core.PApplet; +import processing.core.PConstants; + +import java.awt.*; + +public class Button { + + //Variables for button size and content + float x, y, w, h; + String text; + + //Displaying buttons in this window + PApplet parent; + Window window; + + Button(PApplet parent, float x, float y, float w, float h, String text) { + this.parent = parent; + this.x = x; + this.y = y; + this.w = w; + this.h = h; + this.text = text; + } + + //Formatting for the displayed buttons + void display() { + parent.stroke(0); + parent.fill(200); + parent.rect(x, y, w, h); + parent.fill(0); + parent.textSize(20); + parent.textAlign(PConstants.CENTER, PConstants.CENTER); + parent.text(text, x + w / 2, y + h / 2); + } + + public boolean isMouseOver() { + return parent.mouseX >= x && parent.mouseX <= x + w && + parent.mouseY >= y && parent.mouseY <= y + h; + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/Collidable.java b/src/main/java/bcit/comp2522/projectteama/Collidable.java new file mode 100644 index 0000000..fef18b0 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Collidable.java @@ -0,0 +1,20 @@ +package bcit.comp2522.projectteama; + +import java.awt.*; + +public interface Collidable { + Rectangle getHitBox(); + + default boolean isCollidingWith(Collidable other) { + Rectangle thisBox = this.getHitBox(); + Rectangle otherBox = other.getHitBox(); + + return thisBox.getX() < otherBox.getX() + otherBox.getWidth() && + thisBox.getX() + thisBox.getWidth() > otherBox.getX() && + thisBox.getY() < otherBox.getY() + otherBox.getHeight() && + thisBox.getY() + thisBox.getHeight() > otherBox.getY(); + } + + void handleCollision(Collidable other); + +} diff --git a/src/main/java/bcit/comp2522/projectteama/Creature.java b/src/main/java/bcit/comp2522/projectteama/Creature.java new file mode 100644 index 0000000..78f96c0 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Creature.java @@ -0,0 +1,27 @@ +package bcit.comp2522.projectteama; + +import processing.core.PVector; + +import java.awt.*; + + +public abstract class Creature extends Sprite{ + protected int health; + + + public Creature(PVector position, PVector direction, float width, float height, float speed, Color color, Window window, Rectangle hitBox, int health) { + super(position, direction, width, height, speed, color, window, hitBox); + this.health = health; + } + + public int getHealth() { + return health; + } + + public void setHealth(int health) { + this.health = health; + } + + abstract void takeDamage(T object); + +} diff --git a/src/main/java/bcit/comp2522/projectteama/DatabaseHandler.java b/src/main/java/bcit/comp2522/projectteama/DatabaseHandler.java new file mode 100644 index 0000000..f7a1de3 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/DatabaseHandler.java @@ -0,0 +1,56 @@ +package bcit.comp2522.projectteama; + +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.ServerApi; +import com.mongodb.ServerApiVersion; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import com.mongodb.client.MongoDatabase; +import org.bson.Document; + +public class DatabaseHandler { + + MongoDatabase database; + String myCollection; + private Window window; + + /** + * DB handler constructor + * @param username + * @param password + * @param window + */ + public DatabaseHandler(String username, String password, Window window) { + this.window = window; + ConnectionString connectionString = new ConnectionString("mongodb+srv://spaceShoot:spaceshoot@2522project.dtdwv6c.mongodb.net/?retryWrites=true&w=majority"); + MongoClientSettings settings = MongoClientSettings.builder() + .applyConnectionString(connectionString) + .serverApi(ServerApi.builder() + .version(ServerApiVersion.V1) + .build()) + .build(); + MongoClient mongoClient = MongoClients.create(settings); + this.database = mongoClient.getDatabase("Player"); + //this.database = mongoClient.getDatabase("Enemy"); + this.myCollection = "Player_Score"; + try { + this.database.createCollection(this.myCollection); + } catch (Exception e){ + System.out.println("Collection already exists."); + } + + } + + /** + * Stores a key value pair in the database + * @param key + */ + public void put(String key) { + Document document = new Document(); + document.append(key, this.window.getCurrentScore()); + new Thread (() -> database.getCollection(myCollection).insertOne(document)).start(); + } + + +} diff --git a/src/main/java/bcit/comp2522/projectteama/Enemy.java b/src/main/java/bcit/comp2522/projectteama/Enemy.java new file mode 100644 index 0000000..4142eb1 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Enemy.java @@ -0,0 +1,37 @@ +package bcit.comp2522.projectteama; + +import processing.core.PVector; + + +import java.awt.*; + +public class Enemy extends Creature implements Collidable{ + private int scoreGiven; + public Enemy(PVector position, PVector direction, float width, float height, + float speed, Color color, Window window, Rectangle hitBox, int health, int scoreGiven) { + super(position, direction, width, height, speed, color, window, hitBox, health); + } + + @Override + void takeDamage(Bullet bullet) { + health = health - bullet.getDamage(); + if (this.health <= 0) { + window.getEManager().remove(this); + window.setCurrentScore(window.getCurrentScore() + this.scoreGiven); + } + } + + @Override + public Rectangle getHitBox() { + return null; + } + + @Override + public void handleCollision(Collidable other) { + if (other instanceof Bullet) { + if (this.isCollidingWith(other)) { + this.takeDamage((Bullet) other); + } + } + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/EnemyManager.java b/src/main/java/bcit/comp2522/projectteama/EnemyManager.java new file mode 100644 index 0000000..3f3652e --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/EnemyManager.java @@ -0,0 +1,36 @@ +package bcit.comp2522.projectteama; + +import java.awt.*; +import java.util.ArrayList; + +import processing.core.PVector; + +public class EnemyManager extends Manager{ + ArrayList enemies = new ArrayList(); + private Window window; + + public EnemyManager(Window window) { + this.window = window; + } + + public ArrayList getEnemies() { + return enemies; + } + + @Override + public void add() { + Enemy enemy = new Enemy( + new PVector(random(0, window.width), random(0, window.height)), + new PVector(random(-1, 1), random(-1, 1)), + 30, 30, 2, new Color(255, 255, 0), + window, new Rectangle(0, 0, 20, 20), 3, 10); + enemy.setHitBox(); + + enemies.add(enemy); + } + + @Override + public void remove(Enemy enemy) { + enemies.remove(enemy); + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/GameOverMenu.java b/src/main/java/bcit/comp2522/projectteama/GameOverMenu.java new file mode 100644 index 0000000..873a867 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/GameOverMenu.java @@ -0,0 +1,41 @@ +package bcit.comp2522.projectteama; + +public class GameOverMenu { + Window window; + private Button newGameButton1; + private Button startMenuButton1; + private Button quitButton1; + + public GameOverMenu(Window window) { + this.window = window; + GameOverMenuButtons(); + } + + + public Button getNewGameButton1() { + return newGameButton1; + } + + public Button getStartMenuButton1() { + return startMenuButton1; + } + + public Button getQuitButton1() { + return quitButton1; + } + + public void displayMenu() { + newGameButton1.display(); + quitButton1.display(); + startMenuButton1.display(); + } + + public void GameOverMenuButtons() { + float width = window.getWidth() / 2 - 100; + this.newGameButton1 = new Button(window, window.getWidth() / 2 - 330, window.getHeight() / 2 - 50 , 130, 50, "New Game"); + this.quitButton1 = new Button(window, window.getWidth() / 2 + 200, window.getWidth() / 2 - 50, 130, 50, "Quit"); + this.startMenuButton1 = new Button(window, window.getWidth() / 2 + 100, window.getWidth() / 2 - 50, 130, 50, "StartMenu"); + +// TODO magic numbers + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/GameStateManager.java b/src/main/java/bcit/comp2522/projectteama/GameStateManager.java new file mode 100644 index 0000000..fd5932e --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/GameStateManager.java @@ -0,0 +1,36 @@ +package bcit.comp2522.projectteama; + +public class GameStateManager { + public enum GameState { + START_MENU, + IN_GAME, + PAUSE, + GAME_OVER + } + private GameState currentState; + + public GameState getCurrentState() { + return currentState; + } + + public GameStateManager() { + currentState = GameState.START_MENU; + } + + public void setInGameState() { + currentState = GameState.IN_GAME; + } + + public void setGameOverState() { + currentState = GameState.GAME_OVER; + } + + public boolean isPlaying() { + return currentState == GameState.IN_GAME; + } + + public boolean isGameOver() { + return currentState == GameState.GAME_OVER; + } + +} diff --git a/src/main/java/bcit/comp2522/projectteama/Manager.java b/src/main/java/bcit/comp2522/projectteama/Manager.java new file mode 100644 index 0000000..c954911 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Manager.java @@ -0,0 +1,8 @@ +package bcit.comp2522.projectteama; + +import processing.core.PApplet; + +public abstract class Manager extends PApplet { + public abstract void add(); + public abstract void remove(T object); +} diff --git a/src/main/java/bcit/comp2522/projectteama/Player.java b/src/main/java/bcit/comp2522/projectteama/Player.java new file mode 100644 index 0000000..7f1e118 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Player.java @@ -0,0 +1,56 @@ +package bcit.comp2522.projectteama; + +import processing.core.PVector; + +import java.awt.*; + +public class Player extends Creature implements Collidable { + + public Player(PVector position, PVector direction, float width, float height, + float speed, Color color, Window window, Rectangle hitBox, int health) { + super(position, direction, width, height, speed, color, window, hitBox, health); + + } + + /** + * Calculates and returns the current velocity of the sprite based on its direction and speed. + */ + public PVector getVelocity() { + return PVector.mult(direction, speed); + } + + /** + * Sets the velocity of the sprite based on the given velocity vector by updating its direction and speed fields. + */ + public void setVelocity(PVector velocity) { + this.direction = velocity.copy().normalize(); + this.speed = velocity.mag(); + } + + public void doFire() { + window.getBManager().add(this.position, window.getAimDirection()); + } + + public void upgrade(){ + + } + @Override + void takeDamage(Enemy enemy) { + this.health--; + } + + @Override + public Rectangle getHitBox() { + return hitBox; + } + + @Override + public void handleCollision(Collidable other) { + if (other instanceof Enemy) { + if (isCollidingWith(other)) { + takeDamage((Enemy) other); + } + } + } + +} diff --git a/src/main/java/bcit/comp2522/projectteama/PlayerManager.java b/src/main/java/bcit/comp2522/projectteama/PlayerManager.java new file mode 100644 index 0000000..1869d0b --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/PlayerManager.java @@ -0,0 +1,33 @@ +package bcit.comp2522.projectteama; + +import processing.core.PVector; + +import java.awt.*; + +public class PlayerManager extends Manager{ + + private Player player; + private Window window; + + public PlayerManager(Window window) { + this.window = window; + } + + public Player getPlayer() { + return player; + } + + @Override + public void add() { + player = new Player(new PVector(window.width/2 , window.height/2), new PVector(0, 0), + 30, 30, 2, new Color(0, 255, 0), window, + new Rectangle(0, 0, 30, 30), 3); + player.setHitBox(); + } + + @Override + public void remove(Player player) { + window.getGameStateManager().setGameOverState(); + } + +} diff --git a/src/main/java/bcit/comp2522/projectteama/Sprite.java b/src/main/java/bcit/comp2522/projectteama/Sprite.java new file mode 100644 index 0000000..ca4ebd7 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Sprite.java @@ -0,0 +1,116 @@ +package bcit.comp2522.projectteama; + + +import java.awt.*; +import processing.core.PVector; + +/** + * This class is responsible for the most common variables and methods + * that are common for the player, enemy and wall class. + */ +public class Sprite { + protected PVector position; + protected PVector direction; + protected float width; + protected float height; + protected float speed; + protected Color color; + protected Window window; + protected Rectangle hitBox; + + public Sprite(PVector position, PVector direction, float width, float height, float speed, Color color, Window window, Rectangle hitBox) { + this.position = position; + this.direction = direction; + this.width = width; + this.height = height; + this.speed = speed; + this.color = color; + this.window = window; + this.hitBox = hitBox; + } + + /** + * this method draws an ellipse on the window. + */ + public void draw() { + window.pushStyle(); + window.fill(this.color.getRed(), this.color.getGreen(), this.color.getBlue()); + window.ellipse(this.position.x, this.position.y, getRadius(), getRadius()); + window.popStyle(); + } + + public void update() { + this.position = this.getPosition().add(this.direction.copy().mult(speed)); + this.setHitBox(); + } + + public void setPosition(PVector position) { + this.position = position; + } + public PVector getPosition() { + return position.copy(); + } + + + public void setDirection(PVector direction) { + this.direction = direction; + } + + public PVector getDirection() { + return direction.copy(); + } + + public float getWidth() { + return width; + } + + public void setWidth(float width) { + this.width = width; + } + + public float getHeight() { + return height; + } + + public void setHeight(float height) { + this.height = height; + } + + public float getSpeed() { + return speed; + } + + public void setSpeed(float speed) { + this.speed = speed; + } + + public Color getColor() { + return color; + } + + public void setColor(Color color) { + this.color = color; + } + + public Window getWindow() { + return window; + } + + public void setWindow(Window window) { + this.window = window; + } + + public Rectangle getHitBox() { + return hitBox; + } + + public float getRadius() { + return height/2; + } + + + public void setHitBox() { + this.hitBox = new Rectangle((int) getPosition().x, + (int) getPosition().y, (int) getWidth(), (int)getHeight()); + } +} diff --git a/src/main/java/bcit/comp2522/projectteama/StartMenu.java b/src/main/java/bcit/comp2522/projectteama/StartMenu.java new file mode 100644 index 0000000..8ca41c8 --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/StartMenu.java @@ -0,0 +1,59 @@ +package bcit.comp2522.projectteama; + +import java.util.ArrayList; +import processing.core.PApplet; +import processing.core.PImage; +import java.awt.*; + + + +public class StartMenu { + + Window window; + + //Instantiate menu buttons + private Button newGameButton; + private Button quitButton; + private Button settingButton; + private Button scoreButton; + + public Button getNewGameButton() { + return newGameButton; + } + + public Button getQuitButton() { + return quitButton; + } + + public Button getScoreButton() { + return scoreButton; + } + + public Button getSettingButton() { + return settingButton; + } + + //constructor + public StartMenu(Window window) { + this.window = window; + menuButtons(); + } + + public void displayMenu() { + newGameButton.display(); + quitButton.display(); + scoreButton.display(); + settingButton.display(); + } + + public void menuButtons() { + float width = window.getWidth() / 2 - 100; + this.newGameButton = new Button(window, window.getWidth() / 2 - 330, window.getHeight() / 2 - 50 , 130, 50, "New Game"); + this.scoreButton = new Button(window, window.getWidth() / 2 - 150, window.getHeight() / 2 - 50 , 130, 50, "Score"); + this.quitButton = new Button(window, window.getWidth() / 2 + 200, window.getWidth() / 2 - 50, 130, 50, "Quit"); + this.settingButton = new Button(window, window.getWidth() / 2 + 25, window.getWidth() / 2 - 50, 130, 50, "Setting"); +// TODO magic numbers + } + + +} diff --git a/src/main/java/bcit/comp2522/projectteama/Window.java b/src/main/java/bcit/comp2522/projectteama/Window.java new file mode 100644 index 0000000..7c7dbea --- /dev/null +++ b/src/main/java/bcit/comp2522/projectteama/Window.java @@ -0,0 +1,274 @@ +package bcit.comp2522.projectteama; + +import processing.core.PApplet; +import processing.core.PImage; +import processing.core.PVector; + + +public class Window extends PApplet{ + + private EnemyManager enemyManager; + private PlayerManager playerManager; + private BulletManager bulletManager; + private DatabaseHandler databaseHandler; + private GameStateManager gameStateManager; + private PImage backgroundImage; + private PImage backgroundImage2; + private PImage backgroundImage3; + private PVector aimDirection = new PVector(0, -1); + private int currentScore = 0; + StartMenu startMenu; + GameOverMenu gameOverMenu; + /** + * Sets window size + */ + public void settings() { + size(800,800); + + } + + /** + * Initializes all required elements + */ + public void setup() { + this.init(); + surface.setTitle("Shooting Space"); // Constant + backgroundImage = loadImage("images/background.png"); // Move to a constant + backgroundImage.resize(width, height); + backgroundImage2 = loadImage("images/backgroundI.png"); // TODO + backgroundImage2.resize(width, height); + backgroundImage3 = loadImage("images/GameOver.png"); + backgroundImage3.resize(width,height); + setupStartMenu(); + } + + /** + * Sets up the menu. + */ + public void setupStartMenu() { + startMenu = new StartMenu(this); + startMenu.menuButtons(); + } + +// /** +// * Sets up the menu. +// */ +// public void setupGameOverMenu() { +// gameOverMenu = new GameOverMenu(this); +// gameOverMenu.GameOverMenuButtons(); +// } + + /** + * initializes all the elements that are required. + * these include the player and enemy. + */ + public void init() { + playerManager = new PlayerManager(this); + enemyManager = new EnemyManager(this); + bulletManager = new BulletManager(this); + + gameStateManager = new GameStateManager(); + databaseHandler = new DatabaseHandler("spaceShoot", "spaceshoot", this); + + playerManager.add(); + + for (int i = 0; i < 10; i++) { // magic number + enemyManager.add(); + } + } + + /** + * Draws the current state of the window based on game state set + * by gameStateManager + */ + public void draw() { + //When player loses all health + if(playerManager.getPlayer().getHealth() <= 0) { + playerManager.remove(playerManager.getPlayer()); + databaseHandler.put("Score"); + } + + gameStateManager.getCurrentState(); + switch (gameStateManager.getCurrentState()) { + case START_MENU: + background(backgroundImage2); + startMenu.displayMenu(); + break; + case IN_GAME: + background(backgroundImage); + + playerManager.getPlayer().update(); + playerManager.getPlayer().draw(); + + for (Enemy enemy : enemyManager.enemies) { + enemy.update(); + enemy.draw(); + } + for (Bullet bullet : bulletManager.getBullets()) { + bullet.update(); + bullet.draw(); + } + break; + //case PAUSED: + // Draw paused screen + //break; + case GAME_OVER: + background(backgroundImage3); + gameOverMenu.displayMenu(); + //setupGameOverMenu(); + break; + } + } + + /** + * Processes key presses to control the player sprite + */ + @Override + public void keyPressed() { + //Handles movement + if (key == 'a' || key == 'A') { + databaseHandler.put("Score"); + playerManager.getPlayer().setVelocity(new PVector(-3, playerManager.getPlayer().getVelocity().y)); // TODO + } else if (key == 'd' || key == 'D') { + playerManager.getPlayer().setVelocity(new PVector(3, playerManager.getPlayer().getVelocity().y)); + } else if (key == 'w' || key == 'W') { + playerManager.getPlayer().setVelocity(new PVector(playerManager.getPlayer().getVelocity().x, -3)); + } else if (key == 's' || key == 'S') { + playerManager.getPlayer().setVelocity(new PVector(playerManager.getPlayer().getVelocity().x, 3)); + //Handles aiming + } else if (keyCode == LEFT) { + aimDirection = new PVector(-1, 0).normalize(); + } else if (keyCode == RIGHT) { + aimDirection = new PVector(1, 0).normalize(); + } else if (keyCode == UP) { + aimDirection = new PVector(0, -1).normalize(); + } else if (keyCode == DOWN) { + aimDirection = new PVector(0, 1).normalize(); + } + + } + + /** + * Gets the direction the player is currently aiming. + * @return A PVector representing the aim direction + */ + public PVector getAimDirection() { + return aimDirection; + } + + /** + * Sets the current score. + * @param currentScore The new current score value. + */ + public void setCurrentScore(int currentScore) { + this.currentScore = currentScore; + } + + /** + * Gets the current score. + * @return The current score. + */ + public int getCurrentScore() { + return currentScore; + } + + /** + * Gets the height of the game window. + * @return The height of the game window. + */ + public float getHeight() { + return height; + } + + /** + * Gets the width of the game window. + * @return The width of the game window. + */ + public float getWidth() { // put above main + return width; + } + + /** + * Gets the game state manager. + * @return The game state manager. + */ + public GameStateManager getGameStateManager() { + return gameStateManager; + } + + /** + * Gets the bullet manager. + * @return The bullet manager. + */ + public BulletManager getBManager() { + return bulletManager; + } + + /** + * Gets the enemy manager. + * @return The enemy manager. + */ + public EnemyManager getEManager() { + return enemyManager; + } + + /** + * Sets key pressed state back to non-pressed state + */ + @Override + public void keyReleased() { + if ((key == 'a' || key == 'A') && playerManager.getPlayer().getVelocity().x < 0) { + playerManager.getPlayer().setVelocity(new PVector(0, playerManager.getPlayer().getVelocity().y)); + } else if ((key == 'd' || key == 'D') && playerManager.getPlayer().getVelocity().x > 0) { + playerManager.getPlayer().setVelocity(new PVector(0, playerManager.getPlayer().getVelocity().y)); + } else if ((key == 'w' || key == 'W') && playerManager.getPlayer().getVelocity().y < 0) { + playerManager.getPlayer().setVelocity(new PVector(playerManager.getPlayer().getVelocity().x, 0)); + } else if ((key == 's' || key == 'S') && playerManager.getPlayer().getVelocity().y > 0) { + playerManager.getPlayer().setVelocity(new PVector(playerManager.getPlayer().getVelocity().x, 0)); + } + if (key == ' ') { + playerManager.getPlayer().doFire(); + } + } + + /** + * Handles mouse click events + */ + public void mouseClicked() { + if (startMenu.getNewGameButton().isMouseOver()) { + gameStateManager.setInGameState(); + draw(); + } + if (startMenu.getQuitButton().isMouseOver()) { + exit(); + } + if (startMenu.getScoreButton().isMouseOver()) { + exit(); // changed this after the score board implemented; + } + if (startMenu.getSettingButton().isMouseOver()) { + exit(); // changed this after the setting board implemented; + } +// if (gameOverMenu.getStartMenuButton1().isMouseOver()) { +// +// } +// if(gameOverMenu.getNewGameButton1().isMouseOver()) { +//// gameStateManager.setInGameState(); +//// draw(); +// } +// if (gameOverMenu.getQuitButton1().isMouseOver()) { +//// exit(); +// } + } + + /** + * Main function. + * + * @param passedArgs arguments from command line + */ + public static void main(String[] passedArgs) { + String[] appletArgs = new String[]{"shooter"}; + Window shooter = new Window(); + PApplet.runSketch(appletArgs, shooter); + } + +} diff --git a/src/test/java/bcit/comp2522/projectteama/EnemyTest.java b/src/test/java/bcit/comp2522/projectteama/EnemyTest.java new file mode 100644 index 0000000..6490bf9 --- /dev/null +++ b/src/test/java/bcit/comp2522/projectteama/EnemyTest.java @@ -0,0 +1,36 @@ +package bcit.comp2522.projectteama; + + +import org.junit.jupiter.api.Test; +import processing.core.PApplet; +import processing.core.PVector; + +import java.awt.*; + +import static org.junit.jupiter.api.Assertions.*; + +class EnemyTest { + Window shooter2; + + @Test + void handleCollision() { + // Create a new enemy and bullet object + String[] appletArgs = new String[]{"shooter2"}; + shooter2 = new Window(); + PApplet.runSketch(appletArgs, shooter2); + shooter2.init(); + Enemy enemy = new Enemy(new PVector(0, 0), new PVector(0, 0), 50, 50, + 10, new Color(255, 0, 0), shooter2, new Rectangle(0, 0, 50, 50), 2, 10); + Bullet bullet = new Bullet(new PVector(0, 0), new PVector(0, 0), 5, 10, + 10, new Color(0, 255, 0), shooter2, new Rectangle(0, 0, 5, 10), 1); + // Save the enemy's initial health + int initialHealth = enemy.getHealth(); + + // Call the handleCollision method with the bullet object + enemy.handleCollision(bullet); + + // Verify that the enemy's health has been reduced by the bullet's damage + int expectedHealth = initialHealth - bullet.getDamage(); + assertEquals(expectedHealth, enemy.getHealth()); + } +} \ No newline at end of file diff --git a/src/test/java/bcit/comp2522/projectteama/PlayerTest.java b/src/test/java/bcit/comp2522/projectteama/PlayerTest.java new file mode 100644 index 0000000..4fcedad --- /dev/null +++ b/src/test/java/bcit/comp2522/projectteama/PlayerTest.java @@ -0,0 +1,49 @@ +package bcit.comp2522.projectteama; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import processing.core.PVector; + +import java.awt.*; + +import static org.junit.jupiter.api.Assertions.*; + +class PlayerTest { + + private Window window; + private Player player; + + @BeforeEach + public void setUp() { + window = new Window(); + window.settings(); + player = new Player(new PVector(window.getWidth() / 2, window.getHeight() / 2), new PVector(0, 0), + 30, 30, 2, new Color(0, 255, 0), window, new Rectangle(0, 0, 30, 30), 3); + } + + @Test + void getVelocity() { + } + + @Test + void setVelocity() { + } + + @Test + void testDoFire() { + player.doFire(); + + } + + @Test + void takeDamage() { + } + + @Test + void getHitBox() { + } + + @Test + void handleCollision() { + } +} \ No newline at end of file