Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //A diamond shape
- public void draw(Graphics2D g)
- {
- g.setColor(getColor());
- g.transform(myTranslation);
- g.transform(myRotation);
- //This shape is a square.. I just rotated it.
- int[] xs = new int[]{width/2, 0, -width/2, 0};
- int[] ys = new int[]{0, height/2, 0, -height/2};
- g.fillPolygon(xs, ys, 4);
- try {
- g.transform(myRotation.createInverse());
- g.transform(myTranslation.createInverse());
- } catch (NoninvertibleTransformException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- //A square shape
- public void draw(Graphics2D g)
- {
- g.setColor(getColor());
- g.transform(myTranslation);
- g.transform(myRotation);
- g.drawRect((int)(0), (int)(0), 1, 1);
- try {
- g.transform(myRotation.createInverse());
- g.transform(myTranslation.createInverse());
- } catch (NoninvertibleTransformException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- //Inside mapview
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- Graphics2D g2d = (Graphics2D)g;
- AffineTransform saveAT = g2d.getTransform();
- g2d.translate(0, this.getHeight());
- g2d.scale(1, -1);
- g2d.scale(5, 5);
- //If it's not blank, go ahead and paint each element in our lists.
- if(fieldSquares != null && !fieldSquares.isEmpty())
- for(FieldSquare fs : fieldSquares)
- {
- fs.draw(g2d);
- }
- if(gameObjects != null && !gameObjects.isEmpty())
- for(GameObject go : gameObjects)
- {
- go.draw(g2d);
- }
- g2d.setTransform(saveAT);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement