I forgor to push
parent
de8e3acf40
commit
6f5582f86e
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="DonorProject" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
|
||||||
|
<description>Builds, tests, and runs the project DonorProject.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. Those of them relevant for JavaFX project are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-jfx-jar: called before FX SDK specific <fx:jar> task
|
||||||
|
-post-jfx-jar: called after FX SDK specific <fx:jar> task
|
||||||
|
-pre-jfx-deploy: called before FX SDK specific <fx:deploy> task
|
||||||
|
-post-jfx-deploy: called after FX SDK specific <fx:deploy> task
|
||||||
|
-pre-jfx-native: called just after -pre-jfx-deploy if <fx:deploy> runs in native packaging mode
|
||||||
|
-post-jfx-native: called just after -post-jfx-deploy if <fx:deploy> runs in native packaging mode
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting a HTML postprocessor after javaFX SDK deployment:
|
||||||
|
|
||||||
|
<target name="-post-jfx-deploy">
|
||||||
|
<basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/>
|
||||||
|
<property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/>
|
||||||
|
<custompostprocess>
|
||||||
|
<fileset dir="${jfx.deployment.html}"/>
|
||||||
|
</custompostprocess>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be
|
||||||
|
initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target:
|
||||||
|
|
||||||
|
<target name="-post-jfx-jar" depends="-check-jfx-sdk-version">
|
||||||
|
<echo message="Calling jar task from JavaFX SDK"/>
|
||||||
|
<fx:jar ...>
|
||||||
|
...
|
||||||
|
</fx:jar>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For more details about JavaFX SDK Ant tasks go to
|
||||||
|
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
|
||||||
|
|
||||||
|
For list of available properties check the files
|
||||||
|
nbproject/build-impl.xml and nbproject/jfx-impl.xml.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
|||||||
|
# Do not modify this property in this configuration. It can be re-generated.
|
||||||
|
$label=Run as WebStart
|
@ -0,0 +1,2 @@
|
|||||||
|
# Do not modify this property in this configuration. It can be re-generated.
|
||||||
|
$label=Run in Browser
|
@ -0,0 +1,8 @@
|
|||||||
|
build.xml.data.CRC32=6e52aa2c
|
||||||
|
build.xml.script.CRC32=47905a69
|
||||||
|
build.xml.stylesheet.CRC32=f85dc8f2@1.107.0.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=6e52aa2c
|
||||||
|
nbproject/build-impl.xml.script.CRC32=a0105a46
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,120 @@
|
|||||||
|
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=DonorProject
|
||||||
|
application.vendor=caleb
|
||||||
|
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.modulepath=\
|
||||||
|
${run.modulepath}
|
||||||
|
debug.test.classpath=\
|
||||||
|
${run.test.classpath}
|
||||||
|
debug.test.modulepath=\
|
||||||
|
${run.test.modulepath}
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
dist.dir=dist
|
||||||
|
dist.jar=${dist.dir}/DonorProject.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=
|
||||||
|
# Space-separated list of extra javac options
|
||||||
|
javac.compilerargs=
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.modulepath=
|
||||||
|
javac.processormodulepath=
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
|
javac.source=1.8
|
||||||
|
javac.target=1.8
|
||||||
|
javac.test.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
javac.test.modulepath=\
|
||||||
|
${javac.modulepath}
|
||||||
|
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.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=donorproject.DonorProject
|
||||||
|
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.modulepath=\
|
||||||
|
${javac.modulepath}
|
||||||
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
|
run.test.modulepath=\
|
||||||
|
${javac.test.modulepath}
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1">
|
||||||
|
<extension file="jfx-impl.xml" id="jfx3">
|
||||||
|
<dependency dependsOn="-jfx-copylibs" target="-post-jar"/>
|
||||||
|
<dependency dependsOn="-rebase-libs" target="-post-jar"/>
|
||||||
|
<dependency dependsOn="jfx-deployment" target="-post-jar"/>
|
||||||
|
<dependency dependsOn="jar" target="debug"/>
|
||||||
|
<dependency dependsOn="jar" target="profile"/>
|
||||||
|
<dependency dependsOn="jar" target="run"/>
|
||||||
|
</extension>
|
||||||
|
</buildExtensions>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>DonorProject</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package anim;
|
||||||
|
|
||||||
|
import javafx.animation.KeyFrame;
|
||||||
|
import javafx.animation.Timeline;
|
||||||
|
import javafx.beans.property.DoubleProperty;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import javafx.util.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author asdv
|
||||||
|
*/
|
||||||
|
public class BouncingBall extends Pane
|
||||||
|
{
|
||||||
|
|
||||||
|
public int pScore = 0;
|
||||||
|
public int cScore = 0;
|
||||||
|
GridPane textDisplay = new GridPane();
|
||||||
|
Rectangle racket = new Rectangle();
|
||||||
|
|
||||||
|
public final double radius = 10; // ball size 40
|
||||||
|
private double x = radius, y = radius; // coordinates of ball
|
||||||
|
private double dx = 1, dy = 1; // direction of the ball
|
||||||
|
private Circle circle = new Circle(x, y, radius); // her majesty, the ball
|
||||||
|
private Timeline animation; // animate the ball
|
||||||
|
private Label playerScore = new Label("Your Score: 0");
|
||||||
|
private Label compScore = new Label("Computer Score: 0");
|
||||||
|
|
||||||
|
public BouncingBall()
|
||||||
|
{
|
||||||
|
racket.setWidth(70);
|
||||||
|
racket.setHeight(20);
|
||||||
|
racket.relocate(0, 580);
|
||||||
|
textDisplay.add(playerScore, 0, 0);
|
||||||
|
textDisplay.add(compScore, 0, 1);
|
||||||
|
|
||||||
|
circle.setFill(Color.BROWN);
|
||||||
|
getChildren().addAll(circle, racket, textDisplay);
|
||||||
|
|
||||||
|
animation = new Timeline(
|
||||||
|
new KeyFrame(Duration.millis(50), (ActionEvent event)
|
||||||
|
->
|
||||||
|
{
|
||||||
|
moveBall();
|
||||||
|
if (y >= (getHeight() - 20))
|
||||||
|
{
|
||||||
|
boolean intersected = intersection();
|
||||||
|
if (intersected && circle.getCenterX() <= racket.getX() / 2)
|
||||||
|
{
|
||||||
|
System.out.println("Intersected.");
|
||||||
|
dx *= -1;
|
||||||
|
dy *= -1;
|
||||||
|
playerScored();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (intersected && circle.getCenterX() >= racket.getX() / 2)
|
||||||
|
{
|
||||||
|
playerScored();
|
||||||
|
dy *= -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (y >= (getHeight() - 40))
|
||||||
|
{
|
||||||
|
computerScored();
|
||||||
|
dy *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
animation.setCycleCount(Timeline.INDEFINITE);
|
||||||
|
animation.setRate(animation.getRate() * 20);
|
||||||
|
animation.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveBall()
|
||||||
|
{
|
||||||
|
if (x < radius || x > getWidth() - radius)
|
||||||
|
{
|
||||||
|
dx *= -1;
|
||||||
|
}
|
||||||
|
if (y < radius || y > getHeight() - radius)
|
||||||
|
{
|
||||||
|
dy *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += dx;
|
||||||
|
y += dy;
|
||||||
|
circle.setCenterX(x);
|
||||||
|
circle.setCenterY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerScored()
|
||||||
|
{
|
||||||
|
playerScore.setText("Your Score: " + (++this.pScore));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void computerScored()
|
||||||
|
{
|
||||||
|
compScore.setText("Computer Score: " + (++this.cScore));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean intersection()
|
||||||
|
{
|
||||||
|
boolean intersected = racket.getBoundsInParent().intersects(circle.getBoundsInParent());
|
||||||
|
|
||||||
|
if (intersected)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveRacket(double x)
|
||||||
|
{
|
||||||
|
racket.relocate(x, 580);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void play()
|
||||||
|
{
|
||||||
|
animation.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pause()
|
||||||
|
{
|
||||||
|
animation.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void increaseSpeed()
|
||||||
|
{
|
||||||
|
animation.setRate(animation.getRate() * 1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decreaseSpeed()
|
||||||
|
{
|
||||||
|
animation.setRate(animation.getRate() * 1.5 > 0 ? animation.getRate() / 1.5 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DoubleProperty rateProperty()
|
||||||
|
{
|
||||||
|
return animation.rateProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package anim;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author asdv
|
||||||
|
*/
|
||||||
|
public class Tennis extends Application
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
BouncingBall bouncingBall = new BouncingBall();
|
||||||
|
|
||||||
|
Scene scene = new Scene(bouncingBall, 800, 600);
|
||||||
|
primaryStage.setTitle("Play Tennis");
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
|
||||||
|
bouncingBall.requestFocus();
|
||||||
|
bouncingBall.setOnMousePressed((MouseEvent event) ->
|
||||||
|
{
|
||||||
|
bouncingBall.pause();
|
||||||
|
});
|
||||||
|
bouncingBall.setOnMouseReleased((MouseEvent event) ->
|
||||||
|
{
|
||||||
|
bouncingBall.play();
|
||||||
|
});
|
||||||
|
bouncingBall.setOnKeyPressed(e ->
|
||||||
|
{
|
||||||
|
if(e.getCode() == KeyCode.UP)
|
||||||
|
{
|
||||||
|
bouncingBall.increaseSpeed();
|
||||||
|
}
|
||||||
|
else if(e.getCode() == KeyCode.DOWN)
|
||||||
|
{
|
||||||
|
bouncingBall.decreaseSpeed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bouncingBall.setOnMouseMoved((MouseEvent event) ->
|
||||||
|
{
|
||||||
|
bouncingBall.moveRacket(event.getSceneX() - bouncingBall.racket.getWidth() / 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/javafx/FXMain.java to edit this template
|
||||||
|
*/
|
||||||
|
package donorproject;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class DonorProject extends Application {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) {
|
||||||
|
Button btn = new Button();
|
||||||
|
btn.setText("Say 'Hello World'");
|
||||||
|
btn.setOnAction(new EventHandler<ActionEvent>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
System.out.println("Hello World!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
StackPane root = new StackPane();
|
||||||
|
root.getChildren().add(btn);
|
||||||
|
|
||||||
|
Scene scene = new Scene(root, 300, 250);
|
||||||
|
|
||||||
|
primaryStage.setTitle("Hello World!");
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args the command line arguments
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package MP2_chapter4_CalebFontenot;
|
||||||
|
|
||||||
|
import javafx.scene.media.MediaPlayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class MediaType {
|
||||||
|
private MediaPlayer mediaPlayer;
|
||||||
|
private boolean isBgm;
|
||||||
|
|
||||||
|
public MediaType(MediaPlayer mediaPlayer, boolean isBgm) {
|
||||||
|
this.mediaPlayer = mediaPlayer;
|
||||||
|
this.isBgm = isBgm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIsBgm() {
|
||||||
|
return isBgm;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="Lab1FX_Stelly" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
|
||||||
|
<description>Builds, tests, and runs the project Lab1FX_Stelly.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. Those of them relevant for JavaFX project are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-jfx-jar: called before FX SDK specific <fx:jar> task
|
||||||
|
-post-jfx-jar: called after FX SDK specific <fx:jar> task
|
||||||
|
-pre-jfx-deploy: called before FX SDK specific <fx:deploy> task
|
||||||
|
-post-jfx-deploy: called after FX SDK specific <fx:deploy> task
|
||||||
|
-pre-jfx-native: called just after -pre-jfx-deploy if <fx:deploy> runs in native packaging mode
|
||||||
|
-post-jfx-native: called just after -post-jfx-deploy if <fx:deploy> runs in native packaging mode
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting a HTML postprocessor after javaFX SDK deployment:
|
||||||
|
|
||||||
|
<target name="-post-jfx-deploy">
|
||||||
|
<basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/>
|
||||||
|
<property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/>
|
||||||
|
<custompostprocess>
|
||||||
|
<fileset dir="${jfx.deployment.html}"/>
|
||||||
|
</custompostprocess>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be
|
||||||
|
initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target:
|
||||||
|
|
||||||
|
<target name="-post-jfx-jar" depends="-check-jfx-sdk-version">
|
||||||
|
<echo message="Calling jar task from JavaFX SDK"/>
|
||||||
|
<fx:jar ...>
|
||||||
|
...
|
||||||
|
</fx:jar>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For more details about JavaFX SDK Ant tasks go to
|
||||||
|
http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm
|
||||||
|
|
||||||
|
For list of available properties check the files
|
||||||
|
nbproject/build-impl.xml and nbproject/jfx-impl.xml.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
@ -0,0 +1,3 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
X-COMMENT: Main-Class will be added automatically by build
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
|||||||
|
# Do not modify this property in this configuration. It can be re-generated.
|
||||||
|
$label=Run as WebStart
|
@ -0,0 +1,2 @@
|
|||||||
|
# Do not modify this property in this configuration. It can be re-generated.
|
||||||
|
$label=Run in Browser
|
@ -0,0 +1,8 @@
|
|||||||
|
build.xml.data.CRC32=5221739b
|
||||||
|
build.xml.script.CRC32=e15c08d4
|
||||||
|
build.xml.stylesheet.CRC32=f85dc8f2@1.103.0.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=811c71b0
|
||||||
|
nbproject/build-impl.xml.script.CRC32=98d2f61a
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,134 @@
|
|||||||
|
annotation.processing.enabled=true
|
||||||
|
annotation.processing.enabled.in.editor=false
|
||||||
|
annotation.processing.processors.list=
|
||||||
|
annotation.processing.run.all.processors=true
|
||||||
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
|
application.title=MP2FX_Stelly
|
||||||
|
application.vendor=asdv
|
||||||
|
auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml
|
||||||
|
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.modulepath=\
|
||||||
|
${run.modulepath}
|
||||||
|
debug.test.classpath=\
|
||||||
|
${run.test.classpath}
|
||||||
|
debug.test.modulepath=\
|
||||||
|
${run.test.modulepath}
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
dist.dir=dist
|
||||||
|
dist.jar=${dist.dir}/MP2FX_Stelly.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=
|
||||||
|
# Space-separated list of extra javac options
|
||||||
|
javac.compilerargs=
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.external.vm=false
|
||||||
|
javac.modulepath=
|
||||||
|
javac.processormodulepath=
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
|
javac.source=1.8
|
||||||
|
javac.target=1.8
|
||||||
|
javac.test.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
javac.test.modulepath=\
|
||||||
|
${javac.modulepath}
|
||||||
|
javac.test.processorpath=\
|
||||||
|
${javac.test.classpath}
|
||||||
|
javadoc.additionalparam=
|
||||||
|
javadoc.author=false
|
||||||
|
javadoc.encoding=${source.encoding}
|
||||||
|
javadoc.html5=false
|
||||||
|
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.deploy.adddesktopshortcut=false
|
||||||
|
javafx.deploy.addstartmenushortcut=false
|
||||||
|
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.disable.proxy=false
|
||||||
|
javafx.deploy.embedJNLP=true
|
||||||
|
javafx.deploy.includeDT=true
|
||||||
|
javafx.deploy.installpermanently=false
|
||||||
|
javafx.deploy.permissionselevated=false
|
||||||
|
# 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=anim.Tennis
|
||||||
|
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
|
||||||
|
javafx.signing.blob=false
|
||||||
|
javafx.signing.enabled=false
|
||||||
|
javafx.signing.type=notsigned
|
||||||
|
jlink.launcher=false
|
||||||
|
jlink.launcher.name=MP2FX_Stelly
|
||||||
|
# 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
|
||||||
|
mkdist.disabled=false
|
||||||
|
native.bundling.enabled=false
|
||||||
|
no.dependencies=true
|
||||||
|
platform.active=default_platform
|
||||||
|
run.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
run.modulepath=\
|
||||||
|
${javac.modulepath}
|
||||||
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
|
run.test.modulepath=\
|
||||||
|
${javac.test.modulepath}
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<buildExtensions xmlns="http://www.netbeans.org/ns/ant-build-extender/1">
|
||||||
|
<extension file="jfx-impl.xml" id="jfx3">
|
||||||
|
<dependency dependsOn="-jfx-copylibs" target="-post-jar"/>
|
||||||
|
<dependency dependsOn="-rebase-libs" target="-post-jar"/>
|
||||||
|
<dependency dependsOn="jfx-deployment" target="-post-jar"/>
|
||||||
|
<dependency dependsOn="jar" target="debug"/>
|
||||||
|
<dependency dependsOn="jar" target="profile"/>
|
||||||
|
<dependency dependsOn="jar" target="run"/>
|
||||||
|
</extension>
|
||||||
|
</buildExtensions>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>MP2FX_Stelly</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||||
|
<definitions>C:\Users\ethan\Documents\NetBeansProjects\JavaLibraryASDV\nblibraries.properties</definitions>
|
||||||
|
</libraries>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package anim;
|
||||||
|
|
||||||
|
import javafx.animation.KeyFrame;
|
||||||
|
import javafx.animation.Timeline;
|
||||||
|
import javafx.beans.property.DoubleProperty;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.shape.Circle;
|
||||||
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import javafx.util.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author asdv
|
||||||
|
*/
|
||||||
|
public class BouncingBall extends Pane
|
||||||
|
{
|
||||||
|
|
||||||
|
public int pScore = 0;
|
||||||
|
public int cScore = 0;
|
||||||
|
GridPane textDisplay = new GridPane();
|
||||||
|
Rectangle racket = new Rectangle();
|
||||||
|
|
||||||
|
public final double radius = 10; // ball size 40
|
||||||
|
private double x = radius, y = radius; // coordinates of ball
|
||||||
|
private double dx = 1, dy = 1; // direction of the ball
|
||||||
|
private Circle circle = new Circle(x, y, radius); // her majesty, the ball
|
||||||
|
private Timeline animation; // animate the ball
|
||||||
|
private Label playerScore = new Label("Your Score: 0");
|
||||||
|
private Label compScore = new Label("Computer Score: 0");
|
||||||
|
|
||||||
|
public BouncingBall()
|
||||||
|
{
|
||||||
|
racket.setWidth(70);
|
||||||
|
racket.setHeight(20);
|
||||||
|
racket.relocate(0, 580);
|
||||||
|
textDisplay.add(playerScore, 0, 0);
|
||||||
|
textDisplay.add(compScore, 0, 1);
|
||||||
|
|
||||||
|
circle.setFill(Color.BROWN);
|
||||||
|
getChildren().addAll(circle, racket, textDisplay);
|
||||||
|
|
||||||
|
animation = new Timeline(
|
||||||
|
new KeyFrame(Duration.millis(50), (ActionEvent event)
|
||||||
|
->
|
||||||
|
{
|
||||||
|
moveBall();
|
||||||
|
if (y >= (getHeight() - 20))
|
||||||
|
{
|
||||||
|
boolean intersected = intersection();
|
||||||
|
if (intersected && circle.getCenterX() <= racket.getX() / 2)
|
||||||
|
{
|
||||||
|
System.out.println("Intersected.");
|
||||||
|
dx *= -1;
|
||||||
|
dy *= -1;
|
||||||
|
playerScored();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (intersected && circle.getCenterX() >= racket.getX() / 2)
|
||||||
|
{
|
||||||
|
playerScored();
|
||||||
|
dy *= -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (y >= (getHeight() - 40))
|
||||||
|
{
|
||||||
|
computerScored();
|
||||||
|
dy *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
animation.setCycleCount(Timeline.INDEFINITE);
|
||||||
|
animation.setRate(animation.getRate() * 20);
|
||||||
|
animation.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveBall()
|
||||||
|
{
|
||||||
|
if (x < radius || x > getWidth() - radius)
|
||||||
|
{
|
||||||
|
dx *= -1;
|
||||||
|
}
|
||||||
|
if (y < radius || y > getHeight() - radius)
|
||||||
|
{
|
||||||
|
dy *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += dx;
|
||||||
|
y += dy;
|
||||||
|
circle.setCenterX(x);
|
||||||
|
circle.setCenterY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerScored()
|
||||||
|
{
|
||||||
|
playerScore.setText("Your Score: " + (++this.pScore));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void computerScored()
|
||||||
|
{
|
||||||
|
compScore.setText("Computer Score: " + (++this.cScore));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean intersection()
|
||||||
|
{
|
||||||
|
boolean intersected = racket.getBoundsInParent().intersects(circle.getBoundsInParent());
|
||||||
|
|
||||||
|
if (intersected)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveRacket(double x)
|
||||||
|
{
|
||||||
|
racket.relocate(x, 580);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void play()
|
||||||
|
{
|
||||||
|
animation.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pause()
|
||||||
|
{
|
||||||
|
animation.pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void increaseSpeed()
|
||||||
|
{
|
||||||
|
animation.setRate(animation.getRate() * 1.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decreaseSpeed()
|
||||||
|
{
|
||||||
|
animation.setRate(animation.getRate() * 1.5 > 0 ? animation.getRate() / 1.5 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DoubleProperty rateProperty()
|
||||||
|
{
|
||||||
|
return animation.rateProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package anim;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.shape.Rectangle;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author asdv
|
||||||
|
*/
|
||||||
|
public class Tennis extends Application
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
BouncingBall bouncingBall = new BouncingBall();
|
||||||
|
|
||||||
|
Scene scene = new Scene(bouncingBall, 800, 600);
|
||||||
|
primaryStage.setTitle("Play Tennis");
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
|
||||||
|
bouncingBall.requestFocus();
|
||||||
|
bouncingBall.setOnMousePressed((MouseEvent event) ->
|
||||||
|
{
|
||||||
|
bouncingBall.pause();
|
||||||
|
});
|
||||||
|
bouncingBall.setOnMouseReleased((MouseEvent event) ->
|
||||||
|
{
|
||||||
|
bouncingBall.play();
|
||||||
|
});
|
||||||
|
bouncingBall.setOnKeyPressed(e ->
|
||||||
|
{
|
||||||
|
if(e.getCode() == KeyCode.UP)
|
||||||
|
{
|
||||||
|
bouncingBall.increaseSpeed();
|
||||||
|
}
|
||||||
|
else if(e.getCode() == KeyCode.DOWN)
|
||||||
|
{
|
||||||
|
bouncingBall.decreaseSpeed();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
bouncingBall.setOnMouseMoved((MouseEvent event) ->
|
||||||
|
{
|
||||||
|
bouncingBall.moveRacket(event.getSceneX() - bouncingBall.racket.getWidth() / 2);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue