From 86ddfa66383757e9956fc6cff0e2204591d5158d Mon Sep 17 00:00:00 2001 From: jalen Date: Thu, 10 Aug 2017 02:11:14 -0700 Subject: [PATCH] initial project --- build.xml | 73 + build/built-jar.properties | 4 + build/classes/.netbeans_automatic_build | 0 build/classes/.netbeans_update_resources | 0 .../javaapplication1/JavaApplication1.class | Bin 0 -> 3160 bytes .../classes/javaapplication1/KeyManager.class | Bin 0 -> 1025 bytes dist/JavaApplication1.jar | Bin 0 -> 1783 bytes dist/README.TXT | 32 + manifest.mf | 3 + nbproject/build-impl.xml | 1420 +++++++++++++++++ nbproject/genfiles.properties | 8 + nbproject/private/private.properties | 2 + nbproject/private/private.xml | 10 + nbproject/project.properties | 74 + nbproject/project.xml | 15 + src/javaapplication1/JavaApplication1.java | 106 ++ src/javaapplication1/KeyManager.java | 46 + 17 files changed, 1793 insertions(+) create mode 100644 build.xml create mode 100644 build/built-jar.properties create mode 100644 build/classes/.netbeans_automatic_build create mode 100644 build/classes/.netbeans_update_resources create mode 100644 build/classes/javaapplication1/JavaApplication1.class create mode 100644 build/classes/javaapplication1/KeyManager.class create mode 100644 dist/JavaApplication1.jar create mode 100644 dist/README.TXT create mode 100644 manifest.mf create mode 100644 nbproject/build-impl.xml create mode 100644 nbproject/genfiles.properties create mode 100644 nbproject/private/private.properties create mode 100644 nbproject/private/private.xml create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 src/javaapplication1/JavaApplication1.java create mode 100644 src/javaapplication1/KeyManager.java diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..9a33201 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project JavaApplication1. + + + diff --git a/build/built-jar.properties b/build/built-jar.properties new file mode 100644 index 0000000..ddb5a77 --- /dev/null +++ b/build/built-jar.properties @@ -0,0 +1,4 @@ +#Mon, 31 Jul 2017 02:00:34 -0700 + + +/home/jalen/NetBeansProjects/JavaApplication1= diff --git a/build/classes/.netbeans_automatic_build b/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/.netbeans_update_resources b/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/javaapplication1/JavaApplication1.class b/build/classes/javaapplication1/JavaApplication1.class new file mode 100644 index 0000000000000000000000000000000000000000..33ac59f4134a49ffb88cfdf6109db88b13125db0 GIT binary patch literal 3160 zcmaJ@Yj9L&8GgR(h3#Rw=Yrq_v`j;-y-ZYHOvmF14xEdh1O6;f#O% z_C4SCe((K#-tV0E{`cnF0Pe)QA>4%{8a^396^tRj}$W;A3&h$?eIqGmZpMQqMU> z<`p>}!U9exE1wRMd`6MaDtn((2`>sXIPNRJvbSVfDOC;4 zDc9~69Y4g66nRO<%lNT|S9JUYmvy|VJYT_UI$l@grzq>Vs*-yHKhyB0jzzqs;paNu z#xHdI67T5v72eYEYo+%aRjCbwjJTx&$SoZ$?JfPIi8Wl3v7K~VoI+}!M3tJ?P~d3RP>(48XgIdv;@dX;naP+c9Hs_8WWjL9h zT#52AH#Reu80D>H^HP#VMqM7nw9GQ4_GR}KXzkhIDpjzS0Zhf_*1iuq4%j*Oe&n^) z`hGzgh&l+mJ|N;Iufns~{@7Xp5i$N!KE(@_z$&<<5QkV}OHMP(2rG2`txJHfxW5@# z8O!=4%VEnKRl_vbS1{&RE@~CjaxTi)3Y!KZ*T!LmDG*Fr(kP5M_ za_qZr%5v~gTZtZ?&}x8iT$YMfpu=G~hzLxZmbL65Wft=sAl9Ndqwe5lj?V}5PuZR@ zZA)S+KOyc?FIv7^g}P-)Kf+ytPr;{e=T(STo#Sp&zr&1TH`lr=fF9h!cMFc4o8g5&}x`VFdRp@0@ z-^i%Bkr9r!l~H>jUPh#img*J}rKR<|eQiy?GGetYoqnFx*X~JmYBk+~^=Rl0)o$+8 z>zZP^b*ihnraSxwHgrXUT`^B*gIY!!!}XE+sI0HfJelkc*T(sp*q1J%Vpvgtq*Kdd&O4ja+H zud8NkA{aK~HndzCSD^d-l4VMV-Nm-`|vmH#XoUB{)GqdAM6ue42TE@MH7a_X6zT+ zFd}ZpsMv`yaR*K^GA15!uI{X!rTt!)pzu*8@ zG1lbIc!;_UILLTT!?#3MorXgisx(d!T}FlQc!bvjc)gs#C0dKDDd2U^^(7A5s({9C a=T#f7$Pyc}DpBdfJ!d^W!Dy=R@c#iKC;~tL literal 0 HcmV?d00001 diff --git a/build/classes/javaapplication1/KeyManager.class b/build/classes/javaapplication1/KeyManager.class new file mode 100644 index 0000000000000000000000000000000000000000..d396db35cf0155546efb16c4548300893a8b3a09 GIT binary patch literal 1025 zcmb7?T~8B16o%i~Za>&=X+dbA1r<;zEoo!aD~t(2O^Ed)*l?j&({?Ni>$cf$Yx=WH zL=$8D0sbiCJG%v%04ApC*)wzIJoC)X{{Hjh7l23Dv5>;r43b#aVMB*|N!+&($7T{+ zNtBb=7BElMcpzYWc+cEb9|HlwH10dyW9Eq`j^_kV1!CpxBd*x*b(BE1;dtux@Ka0q zP1$leGvDa7rF$fOM~^3yW^n9~z1ldDBPsiR*J;bZ>3I+8FV*;!^ki50yWC^g@5q3V z6kVF*zUm09l*6XF{2bKPNO^&7d9IUP?O~j9`SOiR1U7npx8|v!rKC5gz3UDAwrUXM z?s;A>2rX!~5D{GIb?a|N%J-d)qL4+8x4s$-v`LzSL**(Nj;sjv!qJD$(rI#xnm(e9 zEOIt1q;1&9*qB8|prA|F9K=QiRe{n!UXDO6Y>ot5C#uaWDPH9@oI#*Ga3VbF~cS}%Okkk2^lRA-#y=nw`oV5#yQqB1A&(>#MwiJc*)gZYIu z1M`e|b^;49*_Xj0=kh4-E!Mh5dP%fM98h3h9m{rDs7>599wZIP3x3`>&7$rapEDFKq)hwWBWK!ktL5T zH*K%zgK*au;KrFDGu$%ME4bhRnBkUJDC|nbc8%fKTIqb}+daE`_H1n{98rNOU?%z3 zCPv0IBB-wKmvS3B731|Qpf;eUi2B?2_Rqf)ou65H2GnY4XQQ&dx1X<8s=_u~vg_pz zq}w$eyQmlPD+#q^k07OvXdFqMFj~BwUrnfGR|-!ybN8Mx|5kqGQQ<}*S1;Vu)4Q%{ zSW+)LZpU$jMA>b$w^Qs8@w)=loUu*t9IYE_Kmt%BC)Q zp3^4vhOn$>dY%3~(`qKvp+ZrAES?C_=~zVKeG2(a0!kx5LQSZ{l#FLDMJX9KVZ2R$ z_{UNFVg%sl+9dk;j`;>h`s($MKN0%|?x~o;)i^#>5yDj#AF;T`BF!Qb$C64%OPs6< z70W!yvB$Qqe$)8QzXOF#7Kh9&GnW6yI<`*6+QTDXT~?A(N9 z1<{r(+T_Npulv;K9+R4}Sz(lH#~Q+ZB1k(G*cQj0QT8EPRQH^o+mIEL<9K)6vpoB* z;T&cuNdA7?xJGIJM8i$2YPf~l8j4t@{4miN?(#;}NA8<#X>;wfQBqyQ9SxtdxXa=* ze6FFyyDhSj(SkEJ2^cLn1xbG+KUKT+$FkumhN0IjRRAL;MUDH3{Bu#3rY)RLZ&A|SAdYH{YRQ_3= zA##-pr`>A@R38vehd`L_or0wi3uUL>acpUOYnh?hAxK_PU-%Y_NKujV2!X1BIt?8f z%?x@g^o}l_K>5L6o+BCa!6fGCTMGzSz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..f6e6d1e --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=3569ad16 +build.xml.script.CRC32=360ae6d5 +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=3569ad16 +nbproject/build-impl.xml.script.CRC32=3e9f3573 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..d8ad482 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=/home/jalen/.netbeans/8.2/build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..842e312 --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,10 @@ + + + + + + file:/home/jalen/NetBeansProjects/JavaApplication1/src/javaapplication1/JavaApplication1.java + file:/home/jalen/NetBeansProjects/JavaApplication1/src/javaapplication1/KeyManager.java + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..a16b614 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,74 @@ +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 +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 +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/JavaApplication1.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +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= +main.class=javaapplication1.JavaApplication1 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..b466dd5 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + JavaApplication1 + + + + + + + + + diff --git a/src/javaapplication1/JavaApplication1.java b/src/javaapplication1/JavaApplication1.java new file mode 100644 index 0000000..d7533a9 --- /dev/null +++ b/src/javaapplication1/JavaApplication1.java @@ -0,0 +1,106 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package javaapplication1; + +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.image.BufferStrategy; +import javax.swing.JFrame; + +/** + * + * @author jalen + */ +public class JavaApplication1 { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + JFrame frame = new JFrame(); + frame.setSize(640, 640); + frame.setResizable(false); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + + Canvas canvas = new Canvas(); + canvas.setPreferredSize(new Dimension(640,640)); + canvas.setMinimumSize(new Dimension(640, 640)); + canvas.setMaximumSize(new Dimension(640, 640)); + frame.add(canvas); + frame.pack(); + canvas.setFocusable(true); + + BufferStrategy bs; + Graphics g; + + KeyManager keyManager = new KeyManager(); + canvas.addKeyListener(keyManager); + + int x = 32; + int y = frame.getHeight() - 64; + double vecX = 0; + double speed = 3.0; + + //set up for 60 fps + int fps = 30; + long secondsPerFrame = 1000000000 / fps; + double delta = 0; + long now; + long lastTime = System.nanoTime(); + long timer = 0; + int tick = 0; + + while (true) { + now = System.nanoTime(); + delta += (now - lastTime) / secondsPerFrame; + timer += (now - lastTime); + lastTime = now; + System.out.println("delta: " + delta); + if (delta >= 1) { + //Update + + keyManager.update(); + + vecX = 0; + if (keyManager.right) vecX = speed; + if (keyManager.left) vecX = -speed; + x += (int)vecX; + + //Render + bs = canvas.getBufferStrategy(); + if (bs == null) { + canvas.createBufferStrategy(3); + continue; + } + g = bs.getDrawGraphics(); + g.clearRect(0, 0, 640, 640); + + //Draw here + g.setColor(Color.black); + g.fillRect(x, y, 32, 32); + + //End draw + g.dispose(); + bs.show(); + + delta--; + tick++; + } + + if (timer >= 1000000000) { + frame.setTitle("Java Application 1 - FPS: " + tick); + tick = 0; + timer = 0; + } + } + } + + +} diff --git a/src/javaapplication1/KeyManager.java b/src/javaapplication1/KeyManager.java new file mode 100644 index 0000000..964c456 --- /dev/null +++ b/src/javaapplication1/KeyManager.java @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package javaapplication1; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +/** + * + * @author jalen + */ +public class KeyManager implements KeyListener{ + + boolean keys[] = new boolean[256]; + boolean left, right; + + public KeyManager() { + left = false; + right = false; + } + + public void update() { + left = keys[KeyEvent.VK_A]; + right = keys[KeyEvent.VK_D]; + + } + + @Override + public void keyTyped(KeyEvent ke) { + + } + + @Override + public void keyPressed(KeyEvent ke) { + keys[ke.getKeyCode()] = true; + } + + @Override + public void keyReleased(KeyEvent ke) { + keys[ke.getKeyCode()] = false; + } + +}