diff --git a/Java/Simple Games/Color Game/.idea/.gitignore b/Java/Simple Games/Color Game/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/Java/Simple Games/Color Game/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Java/Simple Games/Color Game/.idea/ant.xml b/Java/Simple Games/Color Game/.idea/ant.xml new file mode 100644 index 00000000..a2a47698 --- /dev/null +++ b/Java/Simple Games/Color Game/.idea/ant.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java/Simple Games/Color Game/.idea/libraries/lib.xml b/Java/Simple Games/Color Game/.idea/libraries/lib.xml new file mode 100644 index 00000000..15482f41 --- /dev/null +++ b/Java/Simple Games/Color Game/.idea/libraries/lib.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Java/Simple Games/Color Game/.idea/misc.xml b/Java/Simple Games/Color Game/.idea/misc.xml new file mode 100644 index 00000000..e208459b --- /dev/null +++ b/Java/Simple Games/Color Game/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Java/Simple Games/Color Game/.idea/modules.xml b/Java/Simple Games/Color Game/.idea/modules.xml new file mode 100644 index 00000000..780be430 --- /dev/null +++ b/Java/Simple Games/Color Game/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Java/Simple Games/Color Game/ColorTrapGame-master.iml b/Java/Simple Games/Color Game/ColorTrapGame-master.iml new file mode 100644 index 00000000..fb8e8667 --- /dev/null +++ b/Java/Simple Games/Color Game/ColorTrapGame-master.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Java/Simple Games/Color Game/build.xml b/Java/Simple Games/Color Game/build.xml new file mode 100644 index 00000000..08679cbe --- /dev/null +++ b/Java/Simple Games/Color Game/build.xml @@ -0,0 +1,53 @@ + + Builds, tests, and runs the project WordColorGame. + + + diff --git a/Java/Simple Games/Color Game/manifest.mf b/Java/Simple Games/Color Game/manifest.mf new file mode 100644 index 00000000..328e8e5b --- /dev/null +++ b/Java/Simple Games/Color Game/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/Java/Simple Games/Color Game/nbproject/build-impl.xml b/Java/Simple Games/Color Game/nbproject/build-impl.xml new file mode 100644 index 00000000..618c1d00 --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/build-impl.xml @@ -0,0 +1,1421 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Java/Simple Games/Color Game/nbproject/configs/Run_as_WebStart.properties b/Java/Simple Games/Color Game/nbproject/configs/Run_as_WebStart.properties new file mode 100644 index 00000000..670fff03 --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/configs/Run_as_WebStart.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run as WebStart diff --git a/Java/Simple Games/Color Game/nbproject/configs/Run_in_Browser.properties b/Java/Simple Games/Color Game/nbproject/configs/Run_in_Browser.properties new file mode 100644 index 00000000..f2a5a657 --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/configs/Run_in_Browser.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run in Browser diff --git a/Java/Simple Games/Color Game/nbproject/genfiles.properties b/Java/Simple Games/Color Game/nbproject/genfiles.properties new file mode 100644 index 00000000..3c09d27e --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=12c55782 +build.xml.script.CRC32=fcede4e3 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=12c55782 +nbproject/build-impl.xml.script.CRC32=2c4783c5 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/Java/Simple Games/Color Game/nbproject/jfx-impl.xml b/Java/Simple Games/Color Game/nbproject/jfx-impl.xml new file mode 100644 index 00000000..575cf06e --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/jfx-impl.xml @@ -0,0 +1,4049 @@ + + + + + JavaFX-specific Ant calls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${cssfileslist} + + + + + + + + + + + + + + + + + + + + + + + + self.addMappedName( + (source.indexOf("jfxrt.jar") >= 0) || + (source.indexOf("deploy.jar") >= 0) || + (source.indexOf("javaws.jar") >= 0) || + (source.indexOf("plugin.jar") >= 0) + ? "" : source + ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Java/Simple Games/Color Game/nbproject/project.properties b/Java/Simple Games/Color Game/nbproject/project.properties new file mode 100644 index 00000000..5bf83e1e --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/project.properties @@ -0,0 +1,113 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=WordColorGame +application.vendor=rdrgz +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +compile.on.save=true +compile.on.save.unsupported.javafx=true +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/WordColorGame.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects +jar.archive.disabled=true +jar.compress=false +javac.classpath=\ + ${javafx.classpath.extension} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +javafx.application.implementation.version=1.0 +javafx.binarycss=false +javafx.classpath.extension=\ + ${java.home}/lib/javaws.jar:\ + ${java.home}/lib/deploy.jar:\ + ${java.home}/lib/plugin.jar +javafx.deploy.allowoffline=true +# If true, application update mode is set to 'background', if false, update mode is set to 'eager' +javafx.deploy.backgroundupdate=false +javafx.deploy.embedJNLP=true +javafx.deploy.includeDT=true +# Set true to prevent creation of temporary copy of deployment artifacts before each run (disables concurrent runs) +javafx.disable.concurrent.runs=false +# Set true to enable multiple concurrent runs of the same WebStart or Run-in-Browser project +javafx.enable.concurrent.external.runs=false +# This is a JavaFX project +javafx.enabled=true +javafx.fallback.class=com.javafx.main.NoJavaFXFallback +# Main class for JavaFX +javafx.main.class=wordcolorgame.ColorTrap +javafx.preloader.class= +# This project does not use Preloader +javafx.preloader.enabled=false +javafx.preloader.jar.filename= +javafx.preloader.jar.path= +javafx.preloader.project.path= +javafx.preloader.type=none +# Set true for GlassFish only. Rebases manifest classpaths of JARs in lib dir. Not usable with signed JARs. +javafx.rebase.libs=false +javafx.run.height=600 +javafx.run.width=800 +# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects +jnlp.enabled=false +# Main class for Java launcher +main.class=com.javafx.main.Main +# For improved security specify narrower Codebase manifest attribute to prevent RIAs from being repurposed +manifest.custom.codebase=* +# Specify Permissions manifest attribute to override default (choices: sandbox, all-permissions) +manifest.custom.permissions= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${dist.jar}:\ + ${javac.classpath}:\ + ${build.classes.dir} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/Java/Simple Games/Color Game/nbproject/project.xml b/Java/Simple Games/Color Game/nbproject/project.xml new file mode 100644 index 00000000..2e31e2b1 --- /dev/null +++ b/Java/Simple Games/Color Game/nbproject/project.xml @@ -0,0 +1,25 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + + + + + + + + WordColorGame + + + + + + + + + diff --git a/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/ColorTrap.class b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/ColorTrap.class new file mode 100644 index 00000000..8b3de51f Binary files /dev/null and b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/ColorTrap.class differ diff --git a/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/ColorsEnum.class b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/ColorsEnum.class new file mode 100644 index 00000000..6f7e7029 Binary files /dev/null and b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/ColorsEnum.class differ diff --git a/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/correct.png b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/correct.png new file mode 100644 index 00000000..74930cd4 Binary files /dev/null and b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/correct.png differ diff --git a/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/wrong.png b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/wrong.png new file mode 100644 index 00000000..5f2f8eb3 Binary files /dev/null and b/Java/Simple Games/Color Game/out/production/ColorTrapGame-master/wordcolorgame/wrong.png differ diff --git a/Java/Simple Games/Color Game/readme.md b/Java/Simple Games/Color Game/readme.md new file mode 100644 index 00000000..fc84a5f5 --- /dev/null +++ b/Java/Simple Games/Color Game/readme.md @@ -0,0 +1,7 @@ +Rules: + +See the color of the text in the top of the screen. + +Match it with the text showing that color + +![alt text](https://raw.githubusercontent.com/sushant-sinha/Programming-Basics/0ddd984dd3a56fa1a170bee0e9299fc5aec92227/Java/Simple%20Games/Color%20Game/ss.PNG) \ No newline at end of file diff --git a/Java/Simple Games/Color Game/src/wordcolorgame/ColorTrap.java b/Java/Simple Games/Color Game/src/wordcolorgame/ColorTrap.java new file mode 100644 index 00000000..d61a522f --- /dev/null +++ b/Java/Simple Games/Color Game/src/wordcolorgame/ColorTrap.java @@ -0,0 +1,212 @@ +package wordcolorgame; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.application.Application; +import static javafx.application.Application.launch; +import javafx.geometry.Insets; +import javafx.geometry.Orientation; +import javafx.stage.Stage; +import javafx.scene.Scene; +import javafx.scene.layout.*; +import javafx.scene.text.*; +import javafx.scene.text.Font; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +import javafx.scene.paint.Color; +import javafx.util.Duration; + + +public class ColorTrap extends Application +{ + private Scene scene; + private BorderPane borderPane; + private Text txtCountDown; + private Text trap; + private String rColor; + private Text choice; + private Text scoreT; + private int score; + private final ColorsEnum colors[] = ColorsEnum.values(); + private final List list = new ArrayList(Arrays.asList(colors)); + private final Text opt[] = new Text[list.size()]; + private ImageView img = new ImageView(); + private final Image check = new Image("wordcolorgame/correct.png"); + private final Image x = new Image("wordcolorgame/wrong.png"); + + private Timeline timeline; + + private final int TIMER = 15; + private int count = 0; + + @Override + public void start(Stage primaryStage) + { + borderPane = new BorderPane(); + borderPane.setStyle("-fx-background-color: lightgrey"); + scene = new Scene(borderPane, 800, 800); + primaryStage.setMinHeight(300); + primaryStage.setMinWidth(600); + initializeGame(); + startPlay(); + + primaryStage.setTitle("Color Confuser"); + primaryStage.setScene(scene); + primaryStage.show(); + } + + public void startPlay() + { + chooseTrapWordAndColor(); + colorNameOptions(); + + count = TIMER; + txtCountDown.setText(TIMER + ""); + timeline = new Timeline(new KeyFrame( + Duration.millis(1000), e -> { + + + if(count >= 0) + { + txtCountDown.setText(count + ""); + count--; + } + else + { + endOfGame(); } + })); + timeline.setCycleCount(TIMER + 2); + timeline.play(); + + } + + public void endOfGame() + { + borderPane.getChildren().clear(); + Text fScore = new Text("Your score: " + score); + fScore.setFont(Font.font("Marker Felt", 40)); + + Button play = new Button("Play again"); + play.setOnAction(e -> { + score = 0; + initializeGame(); + startPlay(); + }); + + VBox end = new VBox(20,fScore, play); + end.setAlignment(Pos.CENTER); + borderPane.setCenter(end); + } + + + public void checkChoice(Text choice) + { + if(this.choice.getText().equals(rColor)){ + score++; + scoreT.setText("Score: " + score); + img.setImage(check); + } + else{ + img.setImage(x); + } + chooseTrapWordAndColor(); + colorNameOptions(); + } + + public void chooseTrapWordAndColor() + { + Random rando = new Random(); + int size = colors.length; + int n = rando.nextInt(colors.length); + + trap.setText(colors[n].name()); + + rColor = colors[rando.nextInt(size)].name(); + trap.setFill(Color.valueOf(rColor)); + } + + public void colorNameOptions() + { + Collections.shuffle(list); + for(int i = 0; i < colors.length; i++){ + opt[i].setText(String.valueOf(list.get(i))); + } + Collections.shuffle(list); + for(int i = 0; i < colors.length; i++){ + opt[i].setFill(Color.valueOf(String.valueOf(list.get(i)))); + } + + for (Text opt1 : opt) { + String s = opt1.getText(); + choice = new Text(); + opt1.setOnMouseClicked((MouseEvent e) -> { + choice.setText(s); + checkChoice(choice); + }); + } + } + + public void initializeGame() + { + trap = new Text(); + trap.setFont(Font.font("Marker Felt", 60)); + + borderPane.setTop(trap); + BorderPane.setAlignment(trap, Pos.CENTER); + + + + FlowPane optionHolder = new FlowPane(Orientation.HORIZONTAL, 10, 10); + optionHolder.setAlignment(Pos.CENTER); + + for(int i = 0; i < list.size(); i++){ + String s = String.valueOf(list.get(i)); + opt[i] = new Text(s); + opt[i].setFont(Font.font("Marker Felt", 40)); + optionHolder.getChildren().add(opt[i]); + } + + borderPane.setCenter(optionHolder); + BorderPane.setAlignment(optionHolder, Pos.CENTER); + BorderPane.setMargin(optionHolder, new Insets(0,80,0,80)); + + + + scoreT = new Text("Score: " + score); + scoreT.setFont(Font.font(20)); + + Region region1 = new Region(); + HBox.setHgrow(region1, Priority.ALWAYS); + + img = new ImageView(); + img.setFitWidth(30); + img.setFitHeight(30); + + Region region2 = new Region(); + HBox.setHgrow(region2, Priority.ALWAYS); + + Text t = new Text("Time: "); + t.setFont(Font.font(20)); + txtCountDown = new Text(); + txtCountDown.setFont(Font.font(20)); + HBox right = new HBox(t, txtCountDown); + + HBox statusbar = new HBox(scoreT, region1, img, region2, right); + + borderPane.setBottom(statusbar); + BorderPane.setAlignment(statusbar, Pos.CENTER); + } + public static void main(String[] args) + { + launch(args); + } +} \ No newline at end of file diff --git a/Java/Simple Games/Color Game/src/wordcolorgame/ColorsEnum.java b/Java/Simple Games/Color Game/src/wordcolorgame/ColorsEnum.java new file mode 100644 index 00000000..5c46d9de --- /dev/null +++ b/Java/Simple Games/Color Game/src/wordcolorgame/ColorsEnum.java @@ -0,0 +1,6 @@ +package wordcolorgame; + +public enum ColorsEnum +{ + ORANGE, PURPLE, BLACK, BLUE, YELLOW, RED, BROWN; +} diff --git a/Java/Simple Games/Color Game/src/wordcolorgame/correct.png b/Java/Simple Games/Color Game/src/wordcolorgame/correct.png new file mode 100644 index 00000000..74930cd4 Binary files /dev/null and b/Java/Simple Games/Color Game/src/wordcolorgame/correct.png differ diff --git a/Java/Simple Games/Color Game/src/wordcolorgame/wrong.png b/Java/Simple Games/Color Game/src/wordcolorgame/wrong.png new file mode 100644 index 00000000..5f2f8eb3 Binary files /dev/null and b/Java/Simple Games/Color Game/src/wordcolorgame/wrong.png differ diff --git a/Java/Simple Games/Color Game/ss.PNG b/Java/Simple Games/Color Game/ss.PNG new file mode 100644 index 00000000..21e4a549 Binary files /dev/null and b/Java/Simple Games/Color Game/ss.PNG differ