From b7f6c9ce642b1f3d398ab9b4f356bfc14f6579e8 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Thu, 2 Jun 2016 21:26:05 -0400 Subject: [PATCH] added turret images boolean movement for player turret --- .gitignore | 3 ++- src/tanks/DrawableElement.java | 2 +- src/tanks/Tanks.java | 32 ++++++++++++++++++++------------ src/tanks/enemyTank.png | Bin 0 -> 2017 bytes src/tanks/player.png | Bin 3288 -> 2198 bytes src/tanks/turret.png | Bin 0 -> 1924 bytes 6 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 src/tanks/enemyTank.png create mode 100644 src/tanks/turret.png diff --git a/.gitignore b/.gitignore index 46cba4a..a568390 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /nbproject/private/ -/build/ \ No newline at end of file +/build/ +/dist/ \ No newline at end of file diff --git a/src/tanks/DrawableElement.java b/src/tanks/DrawableElement.java index 955fc40..c82cb37 100644 --- a/src/tanks/DrawableElement.java +++ b/src/tanks/DrawableElement.java @@ -32,7 +32,7 @@ public abstract class DrawableElement img = null; try { - System.out.println(imageLocation); + //System.out.println(imageLocation); img = ImageIO.read(getClass().getResourceAsStream(imageLocation)); //img = ImageIO.read(new File(imageLoc)); } diff --git a/src/tanks/Tanks.java b/src/tanks/Tanks.java index 13b4ba1..9faa05e 100644 --- a/src/tanks/Tanks.java +++ b/src/tanks/Tanks.java @@ -43,6 +43,7 @@ public class Tanks frame=new JFrame("Tanks project"); frame.setSize(fwidth,fheight + 150); + frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); newGame(); @@ -184,7 +185,7 @@ public class Tanks private class Player extends Living { private Turret t; - private boolean up,down,left,right; + private boolean up,down,left,right, rleft, rRight; public Player() { @@ -201,12 +202,19 @@ public class Tanks void move() { + if(rleft) + { + t.rotate(-1); + } + if(rRight) + { + t.rotate(1); + } if(up==true) { super.move(-1); t.move(-1); - } if(down==true) { @@ -239,8 +247,8 @@ public class Tanks { y-=speed; } - t.x = x+12; - t.y = y+12; + t.x = x; + t.y = y; } void updateDir(KeyEvent e, boolean pressed) @@ -264,11 +272,11 @@ public class Tanks } else if(id==KeyEvent.VK_A) { - t.rotate(-1); + rleft = pressed; } else if(id==KeyEvent.VK_D) { - t.rotate(1); + rRight = pressed; } else if(id==KeyEvent.VK_SPACE) { @@ -352,8 +360,8 @@ public class Tanks { width = 25; height = 25; - x = e.x; - y = e.y; + x = e.x + 12; + y = e.y + 12; direction = e.direction; speed = 10; imageLocation = "bullet.png"; @@ -423,13 +431,13 @@ public class Tanks { public Turret(RotationalElement e) { - width = 25; - height = 25; + width = 50; + height = 50; x = e.x; y = e.y; direction = e.direction; speed = 10; - imageLocation = "bullet.png"; + imageLocation = "turret.png"; super.loadImage(); } public void shoot() @@ -562,7 +570,7 @@ public class Tanks Enemy temp = new Zombie(); temp.spawn(frame); enemy.add(temp); - + } diff --git a/src/tanks/enemyTank.png b/src/tanks/enemyTank.png new file mode 100644 index 0000000000000000000000000000000000000000..29132b6ffb92b11a73bee211ad085fedd047ee8d GIT binary patch literal 2017 zcmV<72Oju|P)Bh33+xDwjThL}?K!Awf_f@x)729+0>d3gQ6}4-pTo zio``iLRB76Dd-%VK6{umG}I8_Tkc##0eY-w*TaR_A4}=dM(f1v@mr(lESxCzGy& zDZ-B7QTj&4L4mE|tFP}!=Dj^C?)8rq!?n5k-z_Iw$fgz%49~6uz*dIYyvpJWu$+`||>pcT8 zBJyCl9R6KtDg5$Av1fPD&(>uZ$A5*t#zTb>15f^*-d`VX=w15H&#BzC5~Ve3e*9

Y(#D(2Hlr<>Dkz6)&O(|Ab7e{ZzN5rm_L)Q>-r&RM877Aqo*G7dAz8@xJ z75qXO6=`~7vM`D$7R#Uo>vp+Gr{aecYtJGNLaiHqt__3fqK|}{u-`;$Y3P|TyF_@T zI9&n2vdp+^iQy|iAi)FFtS8Mfsp=&JjTfm|vUabF=_O>XUSqU)zA&g0OhY?jZThSg zIwvxZ9-Yxi8`=)uzoGO4N2|s2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fp{J+twfX=>&>Km& zRg(@vceQ@2W+8b!>+I5kT}?(W zO!2L+K7)6j$R&&nP7}|jl^u8X?E)Er$`h?W$bT2_v{ronkN0xZj`g^tbw*cnl{))q zkZGuVr}g;5Lu35aA3fe)<2F(UvP_m+qNFi~FbGK0(j%paAPC|GZB!apnnqUr_NQzs zw#79>8sK5$XUP=M*}jp)j!L<4Jf69_z?I3Fwibc(U=__I$b34sRGQmWNIhnZGL&ps zzklkiBoQu)H5^EblR1D50*$o>ts5pW8`6^*7M#GtcYKnq0~>MParpTm9{al=;S!Gk zU;g5Ly1EM;lSx4szB)>|Orvs{TeRS#VBZCahway`uF18Mcp>;MS?4}Uv9vW54pxtZ7}EX-BWTI14N8Ge4KLj*2I z6qrq5ZcACOe_e?W-TfXCag>uPPnsWdb~N1r7F)6j2&9)Oa|=8iSdOih(LE(WapZ9gMin<@Y?fCb2XcH z@x9?PbFE4xMntGo;$5??vApTr9VYxs+M9%Oy* zDq^4TmBaga>dlu(Jlxnnz+d0<1%DKZ$jAK6p>J{U;*pl~y}he9rAT65H=M7Tqh=D7 z?im_|4$>4x`LwxvMS;G)5{Y+o^@ONW+J=Shz7l=CB_f{?b_ew~-37gUB{Yi2S%NTs z3Y7X>CcR2q-U+c_6am8e^}TlJ^ku@pVgrS8as946i4)@35qpQL`E16B)qhGtrIPw| z9Qj6@7pmomN)QwI1fOg35mYL13dCn|P`hW3g(yyN-V-OTQT5a`*Sr)I3KoUJdqKVb zuAA`U^>tlqZY!g`#uYs2NS^UO|80|tQz#V|1Qj_TT3E^3V*AHU4LeUI}$Cshyt TSua%L00000NkvXXu0mjf1*TqK diff --git a/src/tanks/turret.png b/src/tanks/turret.png new file mode 100644 index 0000000000000000000000000000000000000000..a90d99fc2b61d2aa36e8defe927cb9af22c6cc4e GIT binary patch literal 1924 zcmV-~2YdL5P)Y46&tv$1I0LkA~ucrD} zuW!}wRn>48cX1bY@&5!_I5pyJ75G^M%K=oBI8BLNQmzpJYQ?Y=?L$NW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