diff --git a/README.md b/README.md new file mode 100644 index 0000000..581a20d --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# tuyotuyo +Fun blend of puyo puyo and tetris made in Java. +--- +#### Created by David Brooks, Rithwik Pattikonda, and Tristan Prior. + +In this version of Tetris, the rules are similar: +1. Try to remove rows by completing them. +2. Don't let your blocks hit the ceiling. + +The difference is is that this version also includes an element from puyo puyo: If four adjacent blocks are the same color, +they are deleted from the grid, leaving a large hole that you have to fill in. + +**You have been warned, play at your own frustration.** + + + +###### Known Bugs: +- Cannot rotate on right hand side of screen. + - Either stops rotation or forcing it appears to deform the block into either the S or Square block. diff --git a/TuyoTuyo/build.xml b/TuyoTuyo/build.xml new file mode 100644 index 0000000..a39b9ac --- /dev/null +++ b/TuyoTuyo/build.xml @@ -0,0 +1,53 @@ + + Builds, tests, and runs the project TuyoTuyo. + + + diff --git a/TuyoTuyo/build/built-jar.properties b/TuyoTuyo/build/built-jar.properties new file mode 100644 index 0000000..c233a29 --- /dev/null +++ b/TuyoTuyo/build/built-jar.properties @@ -0,0 +1,4 @@ +#Fri, 18 May 2018 16:28:17 -0500 + + +C\:\\Users\\Ursom\\Documents\\NetBeansProjects\\TuyoTuyo= diff --git a/TuyoTuyo/build/classes/tuyotuyo/Block.class b/TuyoTuyo/build/classes/tuyotuyo/Block.class new file mode 100644 index 0000000..bca2b2a Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/Block.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/BlockTester.class b/TuyoTuyo/build/classes/tuyotuyo/BlockTester.class new file mode 100644 index 0000000..386de76 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/BlockTester.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/Grid.class b/TuyoTuyo/build/classes/tuyotuyo/Grid.class new file mode 100644 index 0000000..786a374 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/Grid.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/GridTester$1.class b/TuyoTuyo/build/classes/tuyotuyo/GridTester$1.class new file mode 100644 index 0000000..3adebc8 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/GridTester$1.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/GridTester.class b/TuyoTuyo/build/classes/tuyotuyo/GridTester.class new file mode 100644 index 0000000..ebb3f77 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/GridTester.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/Piece$PieceType.class b/TuyoTuyo/build/classes/tuyotuyo/Piece$PieceType.class new file mode 100644 index 0000000..d9d46a9 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/Piece$PieceType.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/Piece.class b/TuyoTuyo/build/classes/tuyotuyo/Piece.class new file mode 100644 index 0000000..cb79d05 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/Piece.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/PieceTester.class b/TuyoTuyo/build/classes/tuyotuyo/PieceTester.class new file mode 100644 index 0000000..4b348ea Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/PieceTester.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/TuyoFXML.fxml b/TuyoTuyo/build/classes/tuyotuyo/TuyoFXML.fxml new file mode 100644 index 0000000..9474d9c --- /dev/null +++ b/TuyoTuyo/build/classes/tuyotuyo/TuyoFXML.fxml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TuyoTuyo/build/classes/tuyotuyo/TuyoFXMLController.class b/TuyoTuyo/build/classes/tuyotuyo/TuyoFXMLController.class new file mode 100644 index 0000000..356436a Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/TuyoFXMLController.class differ diff --git a/TuyoTuyo/build/classes/tuyotuyo/TuyoTuyo.class b/TuyoTuyo/build/classes/tuyotuyo/TuyoTuyo.class new file mode 100644 index 0000000..627cc49 Binary files /dev/null and b/TuyoTuyo/build/classes/tuyotuyo/TuyoTuyo.class differ diff --git a/TuyoTuyo/dist/TuyoTuyo.html b/TuyoTuyo/dist/TuyoTuyo.html new file mode 100644 index 0000000..7c9a613 --- /dev/null +++ b/TuyoTuyo/dist/TuyoTuyo.html @@ -0,0 +1,45 @@ + + + + + + + +

Test page for TuyoTuyo

+ Webstart: click to launch this app as webstart


+ + +
+ diff --git a/TuyoTuyo/dist/TuyoTuyo.jar b/TuyoTuyo/dist/TuyoTuyo.jar new file mode 100644 index 0000000..a877095 Binary files /dev/null and b/TuyoTuyo/dist/TuyoTuyo.jar differ diff --git a/TuyoTuyo/dist/TuyoTuyo.jnlp b/TuyoTuyo/dist/TuyoTuyo.jnlp new file mode 100644 index 0000000..9ca8e8b --- /dev/null +++ b/TuyoTuyo/dist/TuyoTuyo.jnlp @@ -0,0 +1,18 @@ + + + + TuyoTuyo + rithw + null + + + + + + + + + + + + diff --git a/TuyoTuyo/dist/web-files/dtjava.js b/TuyoTuyo/dist/web-files/dtjava.js new file mode 100644 index 0000000..b77ecd7 --- /dev/null +++ b/TuyoTuyo/dist/web-files/dtjava.js @@ -0,0 +1,3958 @@ +/* + * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/** + The Java Deployment Toolkit is a utility to deploy Java content in + the browser as applets or applications using the right version of Java. + If needed it can initiate an upgrade of user's system to install required + components of Java platform. +

+ Note that some of the Deployment Toolkit methods may not be fully operational if + used before web page body is loaded (because DT native plugins could not be instantiated). + If you intend to use it before web page DOM tree is ready then dtjava.js + needs to be loaded inside the body element of the page and before use of other DT APIs. + + @module java/deployment_toolkit +*/ +var dtjava = function() { + function notNull(o) { + return (o != undefined && o != null); + } + + function isDef(fn) { + return (fn != null && typeof fn != "undefined"); + } + + //return true if any of patterns from query list is found in the given string + function containsAny(lst, str) { + for (var q = 0; q < lst.length; q++) { + if (str.indexOf(lst[q]) != -1) { + return true; + } + } + return false; + } + + /* Location of static web content - images, javascript files. */ + var jscodebase = (function () { + // + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TuyoTuyo/nbproject/private/configs/Run_as_WebStart.properties b/TuyoTuyo/nbproject/private/configs/Run_as_WebStart.properties new file mode 100644 index 0000000..7a1d99d --- /dev/null +++ b/TuyoTuyo/nbproject/private/configs/Run_as_WebStart.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=webstart diff --git a/TuyoTuyo/nbproject/private/configs/Run_in_Browser.properties b/TuyoTuyo/nbproject/private/configs/Run_in_Browser.properties new file mode 100644 index 0000000..7a7b6e4 --- /dev/null +++ b/TuyoTuyo/nbproject/private/configs/Run_in_Browser.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=embedded diff --git a/TuyoTuyo/nbproject/private/private.properties b/TuyoTuyo/nbproject/private/private.properties new file mode 100644 index 0000000..e16ee0e --- /dev/null +++ b/TuyoTuyo/nbproject/private/private.properties @@ -0,0 +1,6 @@ +auxiliary.org-netbeans-modules-projectapi.issue214819_5f_fx_5f_enabled=true +# No need to modify this property unless customizing JavaFX Ant task infrastructure +endorsed.javafx.ant.classpath=. +javafx.run.inbrowser= +javafx.run.inbrowser.path=C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE +user.properties.file=C:\\Users\\Ursom\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/TuyoTuyo/nbproject/private/private.xml b/TuyoTuyo/nbproject/private/private.xml new file mode 100644 index 0000000..a500500 --- /dev/null +++ b/TuyoTuyo/nbproject/private/private.xml @@ -0,0 +1,13 @@ + + + + + + file:/C:/Users/Ursom/Documents/NetBeansProjects/TuyoTuyo/src/tuyotuyo/GridTester.java + file:/C:/Users/Ursom/Documents/NetBeansProjects/TuyoTuyo/src/tuyotuyo/TuyoTuyo.java + file:/C:/Users/Ursom/Documents/NetBeansProjects/TuyoTuyo/src/tuyotuyo/Block.java + file:/C:/Users/Ursom/Documents/NetBeansProjects/TuyoTuyo/src/tuyotuyo/Piece.java + file:/C:/Users/Ursom/Documents/NetBeansProjects/TuyoTuyo/src/tuyotuyo/Grid.java + + + diff --git a/TuyoTuyo/nbproject/private/retriever/catalog.xml b/TuyoTuyo/nbproject/private/retriever/catalog.xml new file mode 100644 index 0000000..35a2b39 --- /dev/null +++ b/TuyoTuyo/nbproject/private/retriever/catalog.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/TuyoTuyo/nbproject/private/retriever/www.oracle.com/technetwork/java/javase/overview/index.html b/TuyoTuyo/nbproject/private/retriever/www.oracle.com/technetwork/java/javase/overview/index.html new file mode 100644 index 0000000..591d78e --- /dev/null +++ b/TuyoTuyo/nbproject/private/retriever/www.oracle.com/technetwork/java/javase/overview/index.html @@ -0,0 +1,1337 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Java SE | Oracle Technology Network | Oracle + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+ + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + +
+
+ + + + + + +
+ +
+
+ + + + + + + + + + + + + +
+
+
+ + + + + + + + + + +
+
+ + + + + + + + + +
+

Java SE at a Glance
+
+

+
 
+ +
+ +
 
+ +
+ + + + + + + +
+
+

+ General FAQs
+  
+
+
+
+

+ Features
+  
+
+
+
+
+

Java Platform, Standard Edition (Java SE) lets you develop and deploy Java applications on desktops and servers. Java offers the rich user interface, performance, versatility, portability, and security that today's applications require.

+ + + + + + +

+
End of Public Updates for Oracle JDK 8
+

+
Oracle will not post further updates of Java SE 8 to its public download sites for commercial use after January 2019. Customers who need continued access to critical bug fixes and security fixes as well as general maintenance for Java SE 8 or previous versions can get long term support through Oracle Java SE Advanced, Oracle Java SE Advanced Desktop, or Oracle Java SE Suite. For more information, and details on how to receive longer term support for Oracle JDK 8, please see the Oracle Java SE Support Roadmap. +
 
+
+
+
 
+ +
+
+ + + + + + + +
+

What's New

+

Java Platform, Standard Edition 10.0.1
+ Java SE 10.0.1 is the latest release of Java SE Platform. This release contains improvements like Local-Variable Type Inference, Parallel Full GC, Application Class-Data Sharing. Oracle strongly recommends that all Java SE users upgrade to this release.
+
arrow Download  arrow  Release Notes

+ +

Java Platform, Standard Edition 8 Update 171 (Java SE 8u171)/ 8 Update 172 (Java SE 8u172)
+ This latest release of the Java Platform includes important bug fixes. Oracle strongly recommends that all Java SE 8 users upgrade to this release.
+ JDK for ARM releases are available on the same page as the downloads for other platforms

+
arrow Download  arrow  Release Notes

+ +

Advanced Management Console
+ Provides system administrators an effective control over diverse Java versions running on desktops in the enterprise enabling a more secure environment and enhanced application experience and availability. Documentation
+

+

+

Security of the Java Platform
+ A description of security information provided by role. For developers, system administrators, home users, and security professionals.
+
+ Java Mission Control 
+ Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis.
+ Release Notes   Demo   White Paper
+
+ Deployment Rule Set 
+ Deployment rule set allows a desktop administrator to control the level of Java client compatibility and default prompts across an organization. Documentation
+
+ Server JRE 
+ Starting with Java SE 7u21, a Server Java Runtime Environment (Server JRE) package is available for deploying Java applications on servers. Learn More
+
+ Java Applet & Web Start - Code Signing 
+ Starting with Java SE 7u21 all Java Applets and Web Start Applications are encouraged to be signed with a trusted certificate. Learn More
+
+ Archive of Technical Articles
+

+

 

+
+

Updates

+

Java SE 10.0.1
+ Java SE 10.0.1 is the latest release for JDK 10.

+

arrow Release Notes  arrow  Download

+ + + Java SE 8u171/ 8u172
+ Java SE 8u171/ 8u172 is the latest release for JDK 8. +

 

+

arrow Release Notes  arrow  Download

+

+

+
+ +

communityProducts and Training
+  

+ Oracle Java SE Advanced & Suite 
+ Expert monitoring, diagnostics, and centralized management for enterprise and ISV Java-based applications.
+
+ Training & Certification:
+
+ + ?
+ Learn More about Java Software

+ Java can reduce costs, drive innovation, and improve application services.
+


+ +

+
+

+

community Community

+

JavaOne
+ JavaOne 2017 has concluded, but the Learning Lives On

+ Did you miss a JavaOne keynote or session? You can find those here.
+
+ Java 8 Event Kit
+ Access the "Create the Future with Java 8 Event Kit" - run your own Java 8 event using the resources designed for Java User Groups (JUGs). The kit includes a fully scripted technical presentation, intro video, promotional tools and more. Learn More
+
+ Adopt a JSR Program
+ This program is intended to encourage JUG members to get involved in a Java Specification Request (JSR) and to evangelise that JSR to their JUG and the wider Java community in order to increase grass roots participation. Learn More
+

+ Java.net 
- The Source for Java Technology Collaboration
+
+ Java Embedded Community
+

+ JavaFX Community
+
+
NightHacking LogoNighthacking.com
+ The NightHacking Java 8 Tour is the inaugural leg of the Java 8 Tour event where the evangelism team will be crossing the globe to speak at conferences and Java User Groups to spread the word about the new Java 8 release.

+
+

 

+
+ +
+
+

+
+ + + + + + + +
+

Participate
+  

+ +
+

Make the Future Java Outreach Program
+
Together, we can inspire future technologists to learn more about Java and the opportunities it brings. The Make the Future Java program offers resources, tool kits and promotional items you can use for Java outreach within your local community.

+

Join a Java User Group (JUG)
+
Java User Groups (JUGs) are volunteer organizations that strive to distribute Java-related knowledge around the world. They provide a meeting place for Java users to get information, share resources and solutions, increase networking, expand Java Technology expertise, and above all, drink beer, eat pizza and have fun. Find a JUG and become a part of the Java community today!

+

Java ForumsI Code Java
+
Read about and share ideas and suggestions about Java technology on the discussion forums. Start with the New to Java or the more advanced Java Programming category.

+

Gimme Java - Show your true colors!
+
These Java designs are yours to take and use. Post on your Website, put them on t-shirts or coffee mugs—use them just about anywhere except on a Java product—and let the world know about your passion for Java.

+
+
 
+
+
+
+

+
+  
+ +

Java SE Site Map

+
+
+ +
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + +
Left Curve +
Java SDKs and Tools
+
Right Curve
+ +
+ + + + + + + + + + + + + + + +
Left Curve +
Java Resources
+
Right Curve
+ +
+ + +
+
+ + +
+ + +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + diff --git a/TuyoTuyo/nbproject/project.properties b/TuyoTuyo/nbproject/project.properties new file mode 100644 index 0000000..eacaad2 --- /dev/null +++ b/TuyoTuyo/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=TuyoTuyo +application.vendor=rithw +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}/TuyoTuyo.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=tuyotuyo.TuyoTuyo +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/TuyoTuyo/nbproject/project.xml b/TuyoTuyo/nbproject/project.xml new file mode 100644 index 0000000..c1a0f14 --- /dev/null +++ b/TuyoTuyo/nbproject/project.xml @@ -0,0 +1,25 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + + + + + + + + TuyoTuyo + + + + + + + + + diff --git a/TuyoTuyo/src/tuyotuyo/Block.java b/TuyoTuyo/src/tuyotuyo/Block.java new file mode 100644 index 0000000..a47f0e0 --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/Block.java @@ -0,0 +1,47 @@ +/** + * The Block class stores a color and (x, y) coordinate, + * and is able to move the block and return its color and rectangle + * + * @author Tristan Pior, Rithwik Path, David Brooks Teacher Name: Mrs.Ishman + */ +package tuyotuyo; + +import java.util.*; +import javafx.scene.paint.Color; + +public class Block { + + private final List colors = new ArrayList<>(Arrays.asList(Color.CYAN, Color.BLUE, Color.ORANGE, + Color.YELLOW, Color.GREEN, Color.MAGENTA, Color.RED)); + private Color blockColor; + + /** + * Instantiates a block with a random color + */ + public Block() { + blockColor = colors.get((int) (Math.random() * 7)); + } + + /** + * Returns the block color + * + * @return Color the color of the block + */ + public Color getColor() { + return blockColor; + } + + /** + * Returns if the current block equals the given block in terms of color + * + * @param b block to compare against + * @return if the current block equals the given block + */ + public boolean equals(Block b) { + if (blockColor.equals(b.getColor())) { + return true; + } + return false; + } + +} diff --git a/TuyoTuyo/src/tuyotuyo/BlockTester.java b/TuyoTuyo/src/tuyotuyo/BlockTester.java new file mode 100644 index 0000000..78a4a86 --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/BlockTester.java @@ -0,0 +1,20 @@ +/** + * @(#)BlockTester.java + * + * + * @author + * @version 1.00 2018/5/11 + */ +package tuyotuyo; + +public class BlockTester +{ + public static void main(String[] args) + { + for(int i = 0; i < 20; i++) + { + Block a = new Block(); + System.out.println(a.getColor()); + } + } +} diff --git a/TuyoTuyo/src/tuyotuyo/Grid.java b/TuyoTuyo/src/tuyotuyo/Grid.java new file mode 100644 index 0000000..4b4cf12 --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/Grid.java @@ -0,0 +1,415 @@ +/** + * Grid.java + * Creates a grid of blocks and keeps track of a user piece. + * Deletes rows upon completion and deletes 4 adjacent with the + * same color. + * + * @author: David Brooks + * Teacher: Tracy Ishman + * Period 2 + * Date: May 18 2018 + */ +package tuyotuyo; + +import java.util.*; +import javafx.scene.paint.Color; + +public class Grid { + + private Block[][] del; + private final int DONE = 3; + private final int TUYO = 4; + private final int BLOCKS = 4; + public Block[][] grid; + private Piece p; + public Block[][] pieceG; + public int score; + public static String debugt = ""; + + /** + * Creates a new grid with the given number of rows and columns, inserts a + * piece, and resets the score. + * + * @param row number of rows to instantiate the grid with + * @param col number of columns to instantiate the grid with + */ + public Grid(int row, int col) { + grid = new Block[row][col]; + score = 0; + insertPiece(); + } + + /** + * Creates a new piece for the player + */ + private void insertPiece() { + p = new Piece(); + pieceG = new Block[grid.length][grid[0].length]; + int col = grid[0].length / 2 - p.getBlockArray()[0].length / 2; + for (int r = 0; r < p.getBlockArray().length; r++) { + for (int c = 0; c < p.getBlockArray()[0].length; c++) { + pieceG[r][c + col] = p.getBlockArray()[r][c]; + } + } + } + + /** + * Attempts to rotate the piece, checks if it would cause any issues doing + * so and returns the either same grid or updated grid + * + * @return block[][] Returns the updated grid after attempting to rotate the + * piece + */ + public Block[][] rotate() { + int ind = p.getIndex(); + Block[][] previousP = pieceG; + + p.rotate(); + int row = -1; + int col = -1; + System.out.println(); + + for (int r = 0; r < grid.length; r++) { + for (int c = 0; c < grid[r].length; c++) { + if (pieceG[r][c] != null && row < 0) { + row = r; + col = c; + } else if (pieceG[r][c] != null && c < col) { + col = c; + } + } + } + + if (col + p.getBlockArray()[0].length - 1 > grid.length - 1) { + col = grid.length - p.getBlockArray().length; + } + + boolean canChange = true; + int count = 0; + pieceG = new Block[grid.length][grid[0].length]; + + for (int r = 0; r < p.getBlockArray().length; r++) { + if (r + row >= grid.length) { + row = grid.length - r - 1; + } + if (r + row < 0) { + row = 0; + } + for (int c = 0; c < p.getBlockArray()[0].length; c++) { + System.out.println(r + row + " " + (c + col) + " " + r + " " + c); + int add = 0; + if (c + col >= grid[0].length) { + col = grid[0].length - c - 1; + } + if (c + col < 0) { + col = 0; + } + + pieceG[r + row][c + col + add] = p.getBlockArray()[r][c]; + if (grid[r + row][c + col + add] != null) { + canChange = false; + } + } + } + + for (int r = 0; r < grid.length; r++) { + for (int c = 0; c < grid[0].length; c++) { + if (pieceG[r][c] != null) { + count++; + } + } + } + System.out.println("\n" + count); + if (count < BLOCKS) { + canChange = false; + } + + if (canChange) { + return getGrid(); + } else { + System.out.println("reset"); + p.setIndex(ind); + pieceG = previousP; + return getGrid(); + } + } + + /** + * Attempts to move the piece to the right 1 space so long as it isn't at + * the end edge of the grid and nothing is next to it + * + * @return block[][] Returns the updated grid after attempting to move the + * piece to the right + */ + public Block[][] right() { + boolean canChange = true; + for (int r = grid.length - 1; r >= 0; r--) { + for (int c = grid[r].length - 1; c >= 0; c--) { + if (pieceG[r][c] != null) { + if (c == grid[r].length - 1 || grid[r][c + 1] != null) { + canChange = false; + } + } + } + } + + if (canChange) { + for (int r = grid.length - 1; r >= 0; r--) { + for (int c = grid[r].length - 2; c >= 0; c--) { + if (pieceG[r][c] != null) { + pieceG[r][c + 1] = pieceG[r][c]; + pieceG[r][c] = null; + } + } + } + } + return getGrid(); + } + + /** + * Attempts to move the piece to the left 1 space so long as it isn't at the + * end edge of the grid and nothing is next to it + * + * @return block[][] Returns the updated grid after attempting to move the + * piece to the left + */ + public Block[][] left() { + boolean canChange = true; + for (int r = grid.length - 1; r >= 0; r--) { + for (int c = 0; c < grid[r].length; c++) { + if (pieceG[r][c] != null) { + if (c == 0 || grid[r][c - 1] != null) { + canChange = false; + } + } + } + } + + if (canChange) { + for (int r = grid.length - 1; r >= 0; r--) { + for (int c = 1; c < grid[r].length; c++) { + if (pieceG[r][c] != null) { + pieceG[r][c - 1] = pieceG[r][c]; + pieceG[r][c] = null; + } + } + } + } + return getGrid(); + } + + /** + * Returns the integer score + * + * @return int returns the game score + */ + public int getScore() { + return score; + } + + /** + * Takes the piece grid and combines it with the block grid and returns the + * combination for drawing. + * + * @return Block[][] grid and pieceG embedded together for drawing + */ + private Block[][] getGrid() { + Block[][] ret = new Block[grid.length][grid[0].length]; + for (int r = 0; r < grid.length; r++) { + for (int c = 0; c < grid[r].length; c++) { + + if (pieceG[r][c] != null) { + ret[r][c] = pieceG[r][c]; + } else { + ret[r][c] = grid[r][c]; + } + } + } + return ret; + } + + /** + * Checks if the piece has stopped moving. If so, it checks for a Tetris and + * inserts a new piece. Otherwise it moves the piece down 1 space. + * + * @return Block[][] returns the updated grid for drawing + */ + public Block[][] updateGrid() { + debugt = ""; + if (pieceStopped()) { + debugt += " tetris"; + + tetris(); + insertPiece(); + } else { + for (int r = grid.length - 1; r > 0; r--) { + for (int c = 0; c < grid[r].length; c++) { + pieceG[r][c] = pieceG[r - 1][c]; + pieceG[r - 1][c] = null; + } + } + } + return getGrid(); + } + + /** + * Returns if the piece has stopped moving down or not + * + * @return boolean returns if the piece has stopped or not + */ + private boolean pieceStopped() { + boolean stop = false; + + for (int r = grid.length - 1; r >= 0; r--) { + for (int c = 0; c < grid[r].length; c++) { + if (pieceG[r][c] != null) { + if (r == grid.length - 1) { + stop = true; + debugt += " going below "; + } else if (grid[r + 1][c] != null) { + stop = true; + debugt += " below is not null "; + } + } + } + } + + if (stop) { + score += 100; + } + return stop; + } + + /** + * Runs through and checks for completed rows, calling puyo as needed and + * then deleting rows. + */ + private void tetris() { + debugt += "t"; + for (int r = grid.length - 1; r >= 0; r--) { + for (int c = 0; c < grid[r].length; c++) { + if (grid[r][c] == null) { + if (pieceG[r][c] != null) { + grid[r][c] = pieceG[r][c]; + pieceG[r][c] = null; + puyo(r); + } + } + } + } + for (int r = 0; r < grid.length; r++) { + for (int c = 0; c < grid[r].length; c++) { + if (pieceG[r][c] != null) { + puyo(r); + } + } + } + + for (int r = grid.length - 1; r >= 0; r--) { + boolean full = true; + for (int c = 0; c < grid[r].length; c++) { + if (grid[r][c] == null) { + full = false; + } + } + + if (full) { + moveDown(r); + puyo(r); + } + } + } + + /** + * Moves the grid down one row starting at the given row + * + * @param row row to start moving down at + */ + private void moveDown(int row) { + debugt += " remove row "; + for (int r = row; r > 0; r--) { + grid[r] = grid[r - 1]; + } + } + + /** + * Runs puyo for every block in the given row + * + * @param row row of blocks to be checked for puyo + */ + private void puyo(int row) { + debugt += " puyo "; + for (int c = 0; c < grid[row].length; c++) { + if (grid[row][c] != null) { + del = new Block[grid.length][grid[row].length]; + if (puyo(row, c, grid[row][c].getColor()) >= TUYO) { + for (int r = 0; r < grid.length; r++) { + for (int col = 0; col < grid[r].length; col++) { + if (del[r][col] != null) { + grid[r][col] = null; + } + } + } + } + } + } + } + + /** + * Returns the number of blocks directly adjacent to the block of the given + * row and column with the same color as the given one. + * + * @param row row of requested block to be checked + * @param col col of requested block to be checked + * @param c color to be checked against + * @return int number of blocks directly adjacent with the same color + */ + private int puyo(int row, int col, Color c) { + int ret = 0; + if (grid[row][col] != null && grid[row][col].getColor().equals(c) && del[row][col] == null) { + ret += 1; + del[row][col] = grid[row][col]; + if (row + 1 < grid.length) { + ret += puyo(row + 1, col, c); + } + if (col + 1 < grid[0].length) { + ret += puyo(row, col + 1, c); + } + if (row - 1 > 0) { + ret += puyo(row - 1, col, c); + } + if (col - 1 > 0) { + ret += puyo(row, col - 1, c); + } + } + return ret; + } + + /** + * Return if the game is over or not by going out of bounds + * + * @return if the game is over or not + */ + public Boolean gameDone() { + boolean done = false; + for (int c = 0; c < grid[DONE].length; c++) { + + if (grid[DONE][c] != null) { + done = true; + } + } + if (done) { + debugt += " done "; + } + return done; + } + + /** + * Returns debug string of methods called + * + * @return string returns Debug Text + */ + public static String debugT() { + return debugt; + } +} diff --git a/TuyoTuyo/src/tuyotuyo/GridTester.java b/TuyoTuyo/src/tuyotuyo/GridTester.java new file mode 100644 index 0000000..fd0c338 --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/GridTester.java @@ -0,0 +1,50 @@ +/** + * GridTester.java + * Tests the grid class to make sure the grid is working properly + * + * @author: David Brooks Teacher: Tracy Ishman Period 2 Date: May 18 2018 + */ +package tuyotuyo; + +import java.util.*; + +public class GridTester { + + public static Timer timer; + public static Grid g; + + /** + * + * + */ + public static void main(String[] args) { + TimerTask task = new TimerTask() { + @Override + public void run() { + + Block[][] gr = g.updateGrid(); + + for (Block[] r : gr) { + + for (Block c : r) { + if (c != null) { + System.out.print("n"); + } else { + System.out.print(","); + } + } + System.out.println(); + } + + System.out.println(g.debugT()); + System.out.println(g.getScore() + "a"); + System.out.println(g.gameDone()); + System.out.println(g.pieceG.length + " " + g.pieceG[0].length); + + } + }; + g = new Grid(14, 10); + timer = new Timer(); + timer.scheduleAtFixedRate(task, 500l, 500l); + } +} diff --git a/TuyoTuyo/src/tuyotuyo/Piece.java b/TuyoTuyo/src/tuyotuyo/Piece.java new file mode 100644 index 0000000..998b01b --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/Piece.java @@ -0,0 +1,387 @@ +/** + * Piece.java + * Creates a 4 by 4 array of blocks in various configurations + * that resemble the common tetris pieces + * + * @author: Tristan Teacher: Tracy Ishman Period 2 Date: May 18 2018 + */ +package tuyotuyo; + +import java.util.*; + +public class Piece { + + private enum PieceType { + I_BLOCK, J_BLOCK, L_BLOCK, O_BLOCK, S_BLOCK, T_BLOCK, Z_BLOCK + } + + private final int X_START = -1; + private final int Y_START = -1; + private PieceType type; + public int pieceIndex; + private List rotations; + + /** + * Instantiates a randomized piece of randomized colors + */ + public Piece() { + int randPiece = (int) (Math.random() * 7); + switch (randPiece) { + case 0: + type = PieceType.I_BLOCK; + break; + case 1: + type = PieceType.J_BLOCK; + break; + case 2: + type = PieceType.L_BLOCK; + break; + case 3: + type = PieceType.O_BLOCK; + break; + case 4: + type = PieceType.S_BLOCK; + break; + case 5: + type = PieceType.T_BLOCK; + break; + case 6: + type = PieceType.Z_BLOCK; + break; + } + rotations = createRotations(); + pieceIndex = (int) (Math.random() * 4); + } + + /** + * Creates Rotations configurations for all the piece types + * + * @return a 2d List of blocks configuration + */ + private List createRotations() { + Block a = new Block(); + Block b = new Block(); + Block c = new Block(); + Block d = new Block(); + if (type.equals(PieceType.I_BLOCK)) { + return createIBlock(a, b, c, d); + } + if (type.equals(PieceType.J_BLOCK)) { + return createJBlock(a, b, c, d); + } + if (type.equals(PieceType.L_BLOCK)) { + return createLBlock(a, b, c, d); + } + if (type.equals(PieceType.O_BLOCK)) { + return createOBlock(a, b, c, d); + } + if (type.equals(PieceType.S_BLOCK)) { + return createSBlock(a, b, c, d); + } + if (type.equals(PieceType.T_BLOCK)) { + return createTBlock(a, b, c, d); + } + if (type.equals(PieceType.Z_BLOCK)) { + return createZBlock(a, b, c, d); + } + return null; + } + + /** + * Creates an I shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of an I Block with the 4 given blocks + */ + private List createIBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] iPiece1 = {{a, null, null, null}, + {b, null, null, null}, + {c, null, null, null}, + {d, null, null, null}}; + Block[][] iPiece2 = {{d, c, b, a}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] iPiece3 = {{d, null, null, null}, + {c, null, null, null}, + {b, null, null, null}, + {a, null, null, null}}; + Block[][] iPiece4 = {{a, b, c, d}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + ret.add(iPiece1); + ret.add(iPiece2); + ret.add(iPiece3); + ret.add(iPiece4); + return ret; + } + + /** + * Creates a J shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of an J Block with the 4 given blocks + */ + private List createJBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] jPiece1 = {{null, a, null, null}, + {null, b, null, null}, + {c, d, null, null}, + {null, null, null, null}}; + Block[][] jPiece2 = {{c, null, null, null}, + {d, b, a, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] jPiece3 = {{d, c, null, null}, + {b, null, null, null}, + {a, null, null, null}, + {null, null, null, null}}; + Block[][] jPiece4 = {{a, b, d, null}, + {null, null, c, null}, + {null, null, null, null}, + {null, null, null, null}}; + ret.add(jPiece1); + ret.add(jPiece2); + ret.add(jPiece3); + ret.add(jPiece4); + return ret; + } + + /** + * Creates an L shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of an L Block with the 4 given blocks + */ + private List createLBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] lPiece1 = {{a, null, null, null}, + {b, null, null, null}, + {c, d, null, null}, + {null, null, null, null}}; + Block[][] lPiece2 = {{c, b, a, null}, + {d, null, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] lPiece3 = {{d, c, null, null}, + {null, b, null, null}, + {null, a, null, null}, + {null, null, null, null}}; + Block[][] lPiece4 = {{null, null, d, null}, + {a, b, c, null}, + {null, null, null, null}, + {null, null, null, null}}; + ret.add(lPiece1); + ret.add(lPiece2); + ret.add(lPiece3); + ret.add(lPiece4); + return ret; + } + + /** + * Creates an O shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of an O Block with the 4 given blocks + */ + private List createOBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] oPiece1 = {{a, b, null, null}, + {c, d, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] oPiece2 = {{c, a, null, null}, + {d, b, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] oPiece3 = {{d, c, null, null}, + {b, a, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] oPiece4 = {{b, d, null, null}, + {a, c, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + ret.add(oPiece1); + ret.add(oPiece2); + ret.add(oPiece3); + ret.add(oPiece4); + return ret; + } + + /** + * Creates an S shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of an S Block with the 4 given blocks + */ + private List createSBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] sPiece1 = {{null, c, d, null}, + {a, b, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] sPiece2 = {{a, null, null, null}, + {b, c, null, null}, + {null, d, null, null}, + {null, null, null, null}}; + Block[][] sPiece3 = {{null, b, a, null}, + {d, c, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] sPiece4 = {{d, null, null, null}, + {c, b, null, null}, + {null, a, null, null}, + {null, null, null, null}}; + ret.add(sPiece1); + ret.add(sPiece2); + ret.add(sPiece3); + ret.add(sPiece4); + return ret; + } + + /** + * Creates a T shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of a T Block with the 4 given blocks + */ + private List createTBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] tPiece1 = {{null, c, null, null}, + {a, b, d, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] tPiece2 = {{a, null, null, null}, + {b, c, null, null}, + {d, null, null, null}, + {null, null, null, null}}; + Block[][] tPiece3 = {{d, b, a, null}, + {null, c, null, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] tPiece4 = {{null, d, null, null}, + {c, b, null, null}, + {null, a, null, null}, + {null, null, null, null}}; + ret.add(tPiece1); + ret.add(tPiece2); + ret.add(tPiece3); + ret.add(tPiece4); + return ret; + } + + /** + * Creates a Z shaped block with the 4 given Blocks + * + * @param a A Block + * @param b B Block + * @param c C Block + * @param d D Block + * @return configuration of a Z Block with the 4 given blocks + */ + private List createZBlock(Block a, Block b, Block c, Block d) { + List ret = new ArrayList<>(); + Block[][] zPiece1 = {{a, b, null, null}, + {null, c, d, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] zPiece2 = {{null, a, null, null}, + {c, b, null, null}, + {d, null, null, null}, + {null, null, null, null}}; + Block[][] zPiece3 = {{d, c, null, null}, + {null, b, a, null}, + {null, null, null, null}, + {null, null, null, null}}; + Block[][] zPiece4 = {{null, d, null, null}, + {b, c, null, null}, + {a, null, null, null}, + {null, null, null, null}}; + ret.add(zPiece1); + ret.add(zPiece2); + ret.add(zPiece3); + ret.add(zPiece4); + return ret; + } + + /** + * Increases the piece index so as to go up one rotation configuration + */ + public void rotate() { + pieceIndex++; + if (pieceIndex > rotations.size() - 1) { + pieceIndex = 0; + } + } + + /** + * returns the pieceIndex + * + * @return integer of the pieceIndex + */ + public int getIndex() { + return pieceIndex; + } + + /** + * Sets the pieceIndex to the given index + * + * @param ind index to set to + */ + public void setIndex(int ind) { + pieceIndex = ind; + } + + /** + * Returns the block configuration of the piece + * + * @return the block configuration of the piece + */ + public Block[][] getBlockArray() { + return rotations.get(pieceIndex); + } + + /** + * Converts the piece into a string for displaying + * + * @return the piece as a string + */ + @Override + public String toString() { + String ret = ""; + Block[][] me = rotations.get(pieceIndex); + for (int i = 0; i < me.length; i++) { + ret += "["; + for (int j = 0; j < me[i].length; j++) { + if (me[i][j] != null) { + ret += "1"; + } else { + ret += "0"; + } + } + ret += "]\n"; + } + return ret; + } +} diff --git a/TuyoTuyo/src/tuyotuyo/PieceTester.java b/TuyoTuyo/src/tuyotuyo/PieceTester.java new file mode 100644 index 0000000..eee3c94 --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/PieceTester.java @@ -0,0 +1,29 @@ +/** + * @(#)PieceTester.java + * + * + * @author + * @version 1.00 2018/5/11 + */ +package tuyotuyo; + +public class PieceTester +{ + public static void main(String[] args) + { + for(int i = 0; i < 20; i++) + { + Piece a = new Piece(); + System.out.println(a.toString()); + a.rotate(); + System.out.println(a.toString()); + a.rotate(); + System.out.println(a.toString()); + a.rotate(); + System.out.println(a.toString()); + a.rotate(); + System.out.println(a.toString()); + System.out.println("--------------------------------------------"); + } + } +} diff --git a/TuyoTuyo/src/tuyotuyo/TuyoFXML.fxml b/TuyoTuyo/src/tuyotuyo/TuyoFXML.fxml new file mode 100644 index 0000000..9474d9c --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/TuyoFXML.fxml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TuyoTuyo/src/tuyotuyo/TuyoFXMLController.java b/TuyoTuyo/src/tuyotuyo/TuyoFXMLController.java new file mode 100644 index 0000000..a316260 --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/TuyoFXMLController.java @@ -0,0 +1,160 @@ +/** + * Manages and runs the game and connects the game logic to the FXML + * @author Rithwik Pattikonda + * Teacher: Tracy Ishman + * Date: 5/18/2018 + * Period: 2 + */ +package tuyotuyo; + +import java.net.URL; +import java.util.ResourceBundle; +import java.util.Timer; +import java.util.TimerTask; +import javafx.animation.Animation; +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.application.Platform; +import javafx.beans.binding.Bindings; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.fxml.Initializable; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.GridPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Text; +import javafx.util.Duration; + +/** + * + * @author rithw + */ +public class TuyoFXMLController implements Initializable, EventHandler { + private SimpleStringProperty value; + private Timeline timeline; + private boolean moveable; + private Grid grid; + // private Timeline timeline; + + private Block[][] blocks; + + @FXML + private Text score; + + @FXML + private Button startButton; + + @FXML + private GridPane mainGrid; + + @FXML + private Text gameover; + + /** + * Initializer method called when the program is started + * @param url + * @param rb + */ + @Override + public void initialize(URL url, ResourceBundle rb) { + value = new SimpleStringProperty(this, "0"); + //System.out.println(url.toString()); + //System.out.println(rb.toString()); + startButton.requestFocus(); + startButton.setOnKeyPressed(this); + score.textProperty().bind(value); + timeline = null; + + } + + /** + * Starts the game timer and runs the game + */ + @FXML + private void startGame(ActionEvent event) { + gameover.setVisible(false); + + System.out.println("You clicked me!"); + if (startButton.getText().equals("Stop Game")) { + startButton.setText("Start Game"); + stopGame(); + } else if (startButton.getText().equals("Start Game")) { + startButton.setText("Stop Game"); + moveable = true; + grid = new Grid(20, 10); + + + timeline = new Timeline(new KeyFrame(Duration.millis(200l), ev -> { + if (grid.gameDone()) { + stopGame(); + System.out.println(grid.gameDone()); + } + blocks = grid.updateGrid(); + value.set(Integer.toString(grid.getScore())); + refresh(blocks); + })); + timeline.setCycleCount(Timeline.INDEFINITE); + timeline.play(); + } + } + + /** + * Refreshes the Tetris grid with new block positions + * + * @param blocks block array to replace the grid with + */ + private void refresh(Block[][] blocks) { + startButton.requestFocus(); + mainGrid.getChildren().clear(); + for (int r = 0; r < blocks.length; r++) { + for (int c = 0; c < blocks[r].length; c++) { + if (blocks[r][c] != null) { + Rectangle rect = new Rectangle(0, 0, 40, 40); + rect.setFill(blocks[r][c].getColor()); + rect.setStroke(Color.BLACK); + mainGrid.add(rect, c, r ); + } + } + } + } + + /** + * Stops the game and clears the grid + */ + private void stopGame() { + timeline.stop(); + mainGrid.getChildren().clear(); + gameover.setVisible(true); + } + + /** + * Handles keypresses to move and rotate the piece + * + * @param event the keyevent detected + */ + @Override + public void handle(KeyEvent event) { + if(!moveable){ + + } + else if (event.getCode().toString().equals("LEFT")) { + refresh(grid.left()); + } + else if (event.getCode().toString().equals("RIGHT")) { + refresh(grid.right()); + } + else if (event.getCode().toString().equals("UP")) { + refresh(grid.rotate()); + } + + } +} diff --git a/TuyoTuyo/src/tuyotuyo/TuyoTuyo.java b/TuyoTuyo/src/tuyotuyo/TuyoTuyo.java new file mode 100644 index 0000000..95100ea --- /dev/null +++ b/TuyoTuyo/src/tuyotuyo/TuyoTuyo.java @@ -0,0 +1,45 @@ +/** + * Class to set up the stage and connect to the scene and FXML + * @author Rithwik Pattikonda + * Teacher: Tracy Ishman + * Date: 5/18/2018 + * Period: 2 + */ +package tuyotuyo; + +import javafx.application.Application; +import javafx.event.EventHandler; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.input.KeyEvent; +import javafx.stage.Stage; + +public class TuyoTuyo extends Application{ + + /** + * Sets up the stage with a scene designed with XML + * @param stage on which the program runs + * @throws Exception + */ + @Override + public void start(Stage stage) throws Exception { + Parent root = FXMLLoader.load(getClass().getResource("TuyoFXML.fxml")); + + Scene scene = new Scene(root); + stage.setScene(scene); + stage.show(); + scene.getRoot().requestFocus(); + } + + /** + * Main method + * @param args the command line arguments + */ + public static void main(String[] args) { + launch(args); + } + + + +}