FA/Assignment3

From ggc

Jump to: navigation, search

001 package FA;
002 
003 import fang.*;
004 import java.awt.*;
005 import java.awt.geom.*;
006 
007 /**
008  * Creating a mosaic using sprites.
009  @author Frank Anderson
010  */
011 public class Assignment3 extends Game
012 {
013   /**sets up the game*/
014   public void setup()
015   {
016     //rec1 is the square about 2/3 to the right and 2/3 down from the top.
017 
018     RectangleSprite rec1;
019     rec1=new RectangleSprite(5,5);
020     rec1.setSize(0.8);
021     rec1.setLocation(0.5,0.5);
022     rec1.setColor(Palette.getColor("Magenta"));
023     addSprite(rec1);
024 
025     // rec2  is the  vertical rectangle centered at (.7,.5)
026     RectangleSprite rec2;
027     rec2=new RectangleSprite(1,5);
028     rec2.setSize(0.6);
029     rec2.setLocation(0.7,0.5);
030     rec2.setColor(Palette.getColor("Dark Green"));
031     addSprite(rec2);
032 
033     // poly1 is a hexagon
034     PolygonSprite poly1;
035     poly1=new PolygonSprite(6);
036     poly1.setSize(0.15);
037     poly1.setLocation(0.35,0.15);
038     poly1.setColor(Palette.getColor("Orange"));
039     addSprite(poly1);
040 
041     // poly2 is an equilateral triangle
042     PolygonSprite poly2;
043     poly2=new PolygonSprite(3);
044     poly2.setSize(0.15);
045     poly2.setLocation(0.55,0.15);
046     poly2.setColor(Palette.getColor("Orange"));
047     addSprite(poly2);
048 
049 
050 
051 
052     // add a green circle,circ, on the right third of the screen
053     //and one third from top
054     OvalSprite circ;
055     circ = new OvalSprite(3,3);
056     circ.setSize(0.3);
057     circ.setLocation(0.2,0.3);
058     circ.setColor(Palette.getColor("Green"));
059     addSprite(circ);
060 
061     // add an oval sprite on the right third and down one third from the top.
062     // Place the oval inside the circle.
063     OvalSprite oval;
064     oval = new OvalSprite(5,3);
065     oval.setSize(.2);
066     oval.setLocation(.2,.3);
067     oval.setColor(Palette.getColor("White"));
068     addSprite(oval);
069 
070     // Add a thick line to the screen as a diagonal from lower left to upper
071     // right in color lime
072 
073     LineSprite thickline;
074     thickline = new LineSprite(0,1,1,0);
075     thickline.setSize(10);
076     thickline.setLocation(0.5,0.5);
077     thickline.setColor(Palette.getColor("Lime"));
078     addSprite(thickline);
079 
080     // Add a thin line to the screen as a vertical line along the right side
081     // of the screen in blue.
082 
083     LineSprite thinline;
084     thinline = new LineSprite(1,1,1,0);
085     thinline.setSize(4);
086     thinline.setLocation(0.95,0.5);
087     thinline.setColor(Palette.getColor("Blue"));
088     addSprite(thinline);
089 
090     // poly3 is a scalene triangle
091     PolygonSprite poly3;
092     poly3=new PolygonSprite(0,0,1,1,0,1);
093     poly3.setSize(0.15);
094     poly3.setLocation(0.65,0.35);
095     poly3.setColor(Palette.getColor("Orange"));
096     addSprite(poly3);
097 
098     // poly4 is a weird polygon
099     PolygonSprite poly4;
100     poly4=new PolygonSprite(0,0,1,3,0,1,2,4,1,6);
101     poly4.setSize(0.25);
102     poly4.setLocation(0.45,0.35);
103     poly4.setColor(Palette.getColor("Orange"));
104     addSprite(poly4);
105     // Make a pink pie sprite opening to the left
106     //and near the left of the screen
107     PieSprite paclarge;
108     paclarge = new PieSprite(2,3,200,160);
109     paclarge.setSize(0.4);
110     paclarge.setLocation(0.3,0.6);
111     paclarge.setColor(Palette.getColor("Pink"));
112     addSprite(paclarge);
113 
114     // Make a red pie sprite opening to the right and to the right
115     // of the large pie sprite
116     PieSprite pacsmall;
117     pacsmall = new PieSprite(2,2,60,30);
118     pacsmall.setSize(0.2);
119     pacsmall.setLocation(0.5,0.6);
120     pacsmall.setColor(Palette.getColor("Red"));
121     addSprite(pacsmall);
122 
123     // Make an arc sprite as the left part of a circle
124     // between 100 and 200 degrees
125 
126     ArcSprite arc1;
127     arc1 = new ArcSprite(3,3,120,180);
128     arc1.setSize(0.2);
129     arc1.setLocation(0.6,0.75);
130     arc1.setColor(Palette.getColor("Black"));
131     addSprite(arc1);
132 
133     // Make an arc sprite as the upper right part of an ellipse
134     // between 10 and 90 degrees
135 
136     ArcSprite arc2;
137     arc2 = new ArcSprite(3,1,0,90);
138     arc2.setSize(0.2);
139     arc2.setLocation(0.7,0.8);
140     arc2.setColor(Palette.getColor("Cyan"));
141     addSprite(arc2);
142 
143     // Make string sprite at the top of the page
144     // with the title  Assignment 3
145 
146     StringSprite toptitle;
147     toptitle = new StringSprite("Assignment 3");
148     toptitle.setSize(0.2);
149     toptitle.topJustify();
150     toptitle.setLocation(.5,0);
151     toptitle.setColor(Palette.getColor("Orange"));
152     addSprite(toptitle);
153 
154     // Make string sprite at the top of the page
155     // with the title  Assignment 3
156 
157     StringSprite bottomname;
158     bottomname = new StringSprite("Frank Anderson");
159     bottomname.setSize(0.4);
160     bottomname.bottomJustify();
161     bottomname.setLocation(.5,1);
162     bottomname.setColor(Palette.getColor("Orange"));
163     addSprite(bottomname);
164 
165     // Make an image sprite of a river to the bottom and left
166     // of the screen.
167 
168     ImageSprite river;
169     river = new ImageSprite("River2.JPG");
170     river.setSize(0.1);
171     river.setLocation(0.2,0.8);
172     addSprite(river);
173 
174     // Make an image sprite of a river to the bottom and right
175     // of the screen.
176 
177     ImageSprite image2;
178     image2 = new ImageSprite("SeipaCycle.JPG");
179     image2.setSize(0.1);
180     image2.setLocation(0.45,0.8);
181     addSprite(image2);
182 
183   }
184 
185   /**handle input and game events*/
186   public void advance()
187   {}
188 }


Download/View FA/Assignment3.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter