android - How to draw continuous enemies in java 2D -


I am making a warship game with the ship at the bottom of the screen moving left and right. The ship shoots projectiles directly on the bombs falling from the sky.

The objective is to avoid falling on the player to shoot the continuous flow of the bomb.

So far, I have delt in drawing like this:

  Public stable bomb B1, B2; Private image image, warship, background, bomb; @ Override public zero start () {bg = 1 new background (0, 0); Ship = new ship (); B1 = new bomb (340, -100); B2 = new bomb (700, -100); Thread thread = new thread (this); Thread.start (); } @ Override Public Wide Run (While {true} {ship.update (); Array list projectile = ShipGetProjects (); For (Int i = 0; I & lt; Projects size (); i ++) {Projectile P = (projectile) projectiles.jet (i); If (p.isVisible () == true) {p.update (); } Other {Projects. Extract (i); }} B1.update (); B2.update (); Bg1.update (); Bg2.update (); Repaint (); Try {Thread.sleep (17); } Grip (Interrupted e) e.printStackTrace (); }}} @ Override Public Wide Paint (Graphics G) {g.drawImage (Background, BG 1.getBgX (), BG 1.getBgY (), this); Array list projectile = ShipGetProjects (); For (Int i = 0; I & lt; Projects size (); i ++) {Projectile P = (projectile) projectiles.jet (i); G.setColor (Color.BLACK); G Filtrect (PJTX), PGTE (5), 10); } G.drawImage (battleship, ship.getCenterX) + 230, ship.getCenterY () -23, this); G.drawImage (bomb, b 1.getCenterX () - 20, b1 .getCenterY () - 19, this); G.drawImage (Bomb, B2 .getCenterX () - 20, B2 .getCenterY () - 19, this); G.setFont (font); G.setColor (Color.BLACK); G.drawString (text, 650, 30); G.drawString (integer. Two string (score), 720, 30); }  

So everything that I have started is how do I continuously add bombs?

What I mean to my observations was something like this:

  ArrayList bombs; Run public void () {while (true) {ship.update (); Array list projectile = ShipGetProjects (); For (Int i = 0; I & lt; Projects size (); i ++) {Projectile P = (projectile) projectiles.jet (i); If (p.isVisible () == true) {p.update (); } Other {Projects. Extract (i); }} For (int i = 0; i  5) {bomb B = new bomb (randommax, random); Bombs.add (b); } Bg1.update (); Bg2.update (); Repaint (); Try {Thread.sleep (17); } Grip (Interrupted e) e.printStackTrace (); }}}  

For something like this:

 for  (int i = 0; i  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -