Results 1 to 1 of 1
Thread: Tower Defense Rocket
 04122012, 03:16 AM #1Member
 Join Date
 Mar 2012
 Posts
 4
 Rep Power
 0
Tower Defense Rocket
Hey everyone, I've been using lwjgl in order to make a zombie tower defense game on here. The lwjgl is not the problem, but instead the mechanics of the towers shooting. I have the shooting with the function:
public void shoot(int damage, int time, float speed, int width, int height, Texture bullet, Zombies... zom)
Java Code:{ int delta = getDelta(); Zombies t = choose(zom); waittime += delta / 16; for(int i = 0; i < zom.length; i++) { if(zom[i] == null) { continue; } if(zom[i].equals(t)) { if(zom[i].inRange(this)) { aim(zom[i]); } if(zom[i] != null && canShoot && Point2D.distance(t.x, t.y + t.randomy, bulletx, bullety) > 1) { float disty = t.y  finaly + t.randomy  10 + t.movingNumY(speed); float distx = (float) (t.x  finalx  10) + t.movingNumX(speed); System.out.println(t.x + " " + t.y); bulletx += distx/speed; bullety += disty/speed; drawBullet(width, height, bullet); } if(waittime % time == 0 && zom[i].inRange(this) && canShoot == false) { canShoot = true; } if((Point2D.distance(t.x, t.y + t.randomy, bulletx, bullety) <= 1)  (bulletx<0  bullety<0  bulletx > 800  bullety > 600)) { bulletx = finalx + 10; bullety = finaly + 10; zom[i].health = damage; canShoot = false; } System.out.println(Point2D.distance(t.x, t.y + t.randomy, bulletx, bullety)); if(zom[i].dead()) { SpawnManager.moneyamount += 20; chosezombie = false; zom[i]=null; } } } }
public float movingNumX(float speed)
Java Code:{ if(x > 624) { if((y <= 160 && y >= 106)) { numx = 0.7f; } else if(y < 106) { numx = 0.7f; } } else if(x < 144 && y >= 160) { if((y < 212 && y >= 160)  (y < 392 && y <= 338)  (y < 454 && y >= 392)) { numx = 0.35f; } else if((y < 278 && y >= 212)  (y < 338 && y <= 278)  (y < 516 && y >= 454)) { numx = 0.35f; } } else if(x <= 624  (y > 106 && x > 144)) { if(y == 44  y == 278  y == 516) { numx = 1f; } else if(y == 160  y == 392) { numx = 1f; } } System.out.println(numx); return (speed/2) * numx; }
Java Code:public float movingNumY(float speed) { if(x >= 624) { numy = 1f; } else if(x <= 144 && y > 106) { numy = 1f; } else { numy = 0; } System.out.println(numy); return (speed) * numy; }
Thanks though,
PFolder
Similar Threads

Recursive and Tower of Hanoi!
By xdrazkalnytex in forum New To JavaReplies: 4Last Post: 04022012, 05:51 PM 
Java's Class Final Project  Tower Defense
By lastpirate89 in forum New To JavaReplies: 6Last Post: 05112011, 03:04 PM 
Tower Defense problems
By emo bob in forum New To JavaReplies: 1Last Post: 04292011, 03:13 PM 
In defense of the Garbage Collector
By Katanagas in forum Advanced JavaReplies: 2Last Post: 10252010, 06:40 PM 
Amazing Rocket Launch Simulation
By adam1 in forum Forum LobbyReplies: 0Last Post: 10012010, 03:23 PM
Bookmarks