Question
Exercise 1 import imagePackage.RasterImage; import java.awt.Color; import java.awt.Composite; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.Toolkit; import java.awt.geom.AffineTransform; import
Exercise 1
import imagePackage.RasterImage;
import java.awt.Color; import java.awt.Composite; import java.awt.Dimension; import java.awt.Font; import java.awt.Graphics2D; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; import java.awt.Toolkit; import java.awt.geom.AffineTransform; import java.awt.geom.Point2D; import java.io.PrintStream;
public class BattleField {
public static void main(String[] args) { /* * Exercise: * Create an Array of Aliens, positioned according to a bounding box * * */
final int ROWS = 3; final int COLS = 10; Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); RasterImage gameBoard = new RasterImage(640,480); gameBoard.show(); gameBoard.setTitle("BattleField"); Graphics2D g = gameBoard.getGraphics2D();
Alien[][] aliens = new Alien[ROWS][COLS]; // 2D array of Aliens
for (int col=0; col // create and initialize position of Aliens Point2D.Double pos = new Point2D.Double(col*60.0, row*60.0); aliens[row][col] = new Alien(pos); aliens[row][col].drawAlien(g); } } Hero shooter = new Hero(200,350); shooter.draw(g); // } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started