matt mitrovich kcie green

From ggc

Jump to: navigation, search

001 import fang.*;
002 import java.awt.*;
003 import java.awt.geom.*;
004 
005 /**
006  * All about my game.
007  @author My Name Here
008 this is not our code its wilsons
009  */
010 public class matt_mitrovich_kcie_green extends Game
011 {
012 
013   RectangleSprite singleBox;
014   RectangleSprite[][] box = new RectangleSprite[5][5];
015   int x;
016   private OvalSprite light;
017   /**sets up the game*/
018 
019   /**This calls the display() method to set up all of the squares*/
020   public void setup()
021   {
022     display();
023   }
024   /**
025   *This method sets up all the squares in an array, it has two for loops for rows and colums
026   *Also randomizes a number between 1 and 2 and if its 1 then set the block to be blue, otherwise white
027   */
028   private void display()
029   {
030     for(int i=0; i<5; i++)
031     {
032       for(int l=0; l<5; l++)
033       {
034         singleBox = new RectangleSprite(1,1);
035         singleBox.setSize(.15);
036         if(x==1)
037           singleBox.setColor(getColor("Green"));
038         else
039           singleBox.setColor(getColor("Orange"));
040         singleBox.setLocation((i+.5)/5,(l+.5)/5);
041         box[i][l]=singleBox;
042         addSprite(singleBox);
043       }
044     }
045   }
046   /**
047   *This method makes it so you can click on a box and change its color and the boxes up,down,left, and right of it
048   *When wanting to change the color it calls the invertBlock() method
049   */
050   private void clickBox()
051   {
052     for(int j=0; j<5; j++)
053     {
054       for(int k=0; k<5; k++)
055       {
056         if(getClick2D() != null && getClick2D().intersects(box[j][k]))
057         {
058           invertBlock(box[j][k]);
059           if (j->=0)
060             invertBlock(box[j-1][k]);
061           if (j+<= 9)
062             invertBlock(box[j+1][k]);
063           if (k->= 0)
064             invertBlock(box[j][k-1]);
065           if (k+<= 9)
066             invertBlock(box[j][k+1]);
067         }
068       }
069     }
070   }
071   /**
072   *This method inverts the RectangleSprite that you tell it to
073   *@param block - this is the rectangle sprite that you want to invert
074   */
075   private void invertBlock(RectangleSprite block)
076   {
077     if(getColorName(block.getColor()) == getColorName(getColor("Green")))
078       block.setColor(getColor("orange"));
079     else
080       block.setColor(getColor("green"));
081 
082   }
083 
084   /**handle input and game events
085   *Calls the clickBox() method to change the color of the blocks.
086   */
087   public void advance()
088   {
089     clickBox();
090   }
091 }
092 /**
093 {
094   circle();
095   square();
096 }
097 private void circle()
098 {
099  
100   light =new OvalSprite(1,1);
101   light.setSize(.5);
102   light.setLocation(.50,.50);
103   light.setColor(getColor("White"));
104   addSprite(light);
105 }
106 from space invaders
107 private void square()
108 {
109   int enemiesAcross=5;
110   int enemiesDown=5;
111   for(int j=0; j<enemiesDown; j++)
112   {
113     for(int i=1; i<=enemiesAcross; i++)
114     {
115       RectangleSprite enemy=new RectangleSprite(1, 1);
116       enemy.setSize(0.9/enemiesAcross);
117       double x=0.5/enemiesAcross+1.0/enemiesAcross*(i-1);
118       double y=0.5/enemiesAcross+(j+0.0)/enemiesAcross;
119       enemy.setLocation(x, y);
120       addSprite(enemy);
121     }
122   }
123 }
124  
125 */
126 
127 
128 /**handle input and game events*/

Compiler Errors:
----------
1. ERROR in matt_mitrovich_kcie_green.java (at line 34)
	singleBox = new RectangleSprite(1,1);
	            ^^^^^^^^^^^^^^^^^^^^^^^^
The constructor RectangleSprite(int, int) is undefined
----------
2. ERROR in matt_mitrovich_kcie_green.java (at line 35)
	singleBox.setSize(.15);
	          ^^^^^^^
The method setColor(Color) is undefined for the type RectangleSprite
----------
10 problems (10 errors)

Download/View matt_mitrovich_kcie_green.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