Advertisement
CSenshi

GFace

Nov 6th, 2020
1,897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package samples;
  2.  
  3. import acm.graphics.GCompound;
  4. import acm.graphics.GOval;
  5.  
  6. public class GFace extends GCompound {
  7.  
  8.     private final int FACE_HEIGHT = 200;
  9.     private final int FACE_WIDTH = 150;
  10.  
  11.     private final int EYE_RADIUS = 25;
  12.     private final int EYE_OFFSET_X = 10;
  13.     private final int EYE_OFFSET_Y = 40;
  14.  
  15.     public GFace() {
  16.         // Face
  17.         GOval oval = new GOval(FACE_WIDTH, FACE_HEIGHT);
  18.         this.add(oval);
  19.  
  20.         // Eye1
  21.         GOval eye1 = new GOval(2 * EYE_RADIUS, 2 * EYE_RADIUS);
  22.         int x1 = FACE_WIDTH / 2 - EYE_OFFSET_X - 2 * EYE_RADIUS;
  23.         this.add(eye1, x1, EYE_OFFSET_Y);
  24.  
  25.         // Eye2
  26.         GOval eye2 = new GOval(2 * EYE_RADIUS, 2 * EYE_RADIUS);
  27.         int x2 = FACE_WIDTH / 2 + EYE_OFFSET_X;
  28.         this.add(eye2, x2, EYE_OFFSET_Y);
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement