AssignmentEightLightsOutGame

From ggc

Jump to: navigation, search

001 import fang.*;
002 import java.awt.*;
003 import java.awt.geom.*;
004 import Derrick.*;
005 /**
006  * All about my game.
007  * @ Recipe provided by Jam Jekins
008 * game Cook Derrick Dixon I must give credit to Frank I thought of the idea of going off the 
009 *board however Frank succesfully used the idea first. Once Frank successfully implemented 
010 *the idea I then was able to see how the idea looked in a program. I then changed the model 
011 *using this idea. Also the casting idea came from Anam & Frank we sat together after class 
012 *last week. I used it in my program but couldn't gtet it to work so I took it out.  After 
013 *sitting with Dr. J the equation used for finding the location was talked about once again 
014 *so I reused the code Anam Frank and I wrote. 
015 * Frank  Dr. Jenkins and Anamn helped me with this Assignment. 
016 */
017 public class AssignmentEightLightsOutGame extends Game
018 {        /** col and row  is the initial value of the
019           * number of columns and rows */
020   private int col, row;
021   /** this sprite is used to display a winning message and help box*/
022   private StringSprite winner, helpBox;
023   /** Is Dr. Jenkins with my enhancements Lights Model*/
024   private Derrick.LightsOutModel workingGame;
025   /** used recatangle for the games board*/
026   private RectangleSprite gameBoard;
027   /** is an Array that stores the lights in the game. */
028 
029   private OvalSprite[][] lights  = new OvalSprite[7][7];
030 
031   /**makes and creates help box.*/
032 
033   private void makeAndAddGetHelp()
034   {
035     String helpBox=
036         "Press start to begin.<br>"+
037         "Once You Win is displayed<br>"+
038         "Click Reload to start again!";
039 
040     setHelpText(helpBox);
041   }
042   /**Creates a winning message.*/
043   private void createWinningMessage()
044   {
045     winner=new StringSprite("You Win");
046     winner.setColor(getColor("White"));
047     winner.setSize(0.40);
048     winner.setLocation(0.5,0.5);
049     addSprite(winner);
050     winner.setVisible(false);
051   }
052   /**Creates a game board using a for loop*/
053   private void createGameBoard()
054   {
055     for(int i=1;i<=6;i++)
056     {
057       for(int j=1;j<=6;j++)
058       {
059         gameBoard = new RectangleSprite(11);
060         gameBoard.setSize(0.19);
061 
062         gameBoard.setLocation(((i-1)/10.0)+(.10 * i)((j-1)/10.0)+(.10 * j));
063         addSprite(gameBoard);
064       }
065     }
066   }
067   /**Creates a lights using a for loop in a 2d array*/
068   private void createLights()
069   {
070     for (int i= 0;i<=6;i++)
071     {
072       for (int = 0;j<=6;j++)
073       {
074         lights[i][j] = new OvalSprite(11);
075         lights[i][j].setSize(0.19);
076         lights[i][j].setColor(getColor("white"));
077         lights[i][j].setLocation(((i-1)/10.0)+(.10 * i)((j-1)/10.0)+(.10 * j));
078         addSpritelights[i][j]);
079         lights[i][j].setVisible(false);
080       }
081     }
082   }
083 
084 
085   /**sets up the game*/
086   public void setup()
087   {
088     makeAndAddGetHelp();
089     workingGame = new Derrick.LightsOutModel();
090     createGameBoard();
091     createLights();
092     createWinningMessage();
093   }
094 
095   /**handle input and game events*/
096   public void advance ()
097   {
098 
099     int col = 0;
100     int row = 0;
101 /** I used William Anderson from last semester class as a reference for the player to game */
102 /**interaction, I used his code (Point2D.Double click = getPlayer().getMouse 
103 /**().getClickLocation()if(click !=null)
104 /**..
105 /**error*/
106     Point2D.Double click = getPlayer().getMouse().getClickLocation();
107     if(click !=null)
108 
109     {
110       col=(int)(click.y*5)+1;
111       row=(int)(click.x*5)+1;
112       //** used the play method of the model to get my lights to light up in a cross pattern*/
113       workingGame.play(row,col);
114     }
115     //** another for loop gives the boundaries of lights to light during play*/
116     for(int i=1;i<=6;i++)
117     {
118       for(int j=1;j<=6;j++)
119       {
120 
121         lights[i][j].setVisible(workingGame.isOn(i, j));
122         winner.setVisible(workingGame.won());
123 
124 
125 
126       }
127     }
128   }
129 }

Compiler Errors:
----------
1. ERROR in AssignmentEightLightsOutGame.java (at line 59)
	gameBoard = new RectangleSprite(1, 1);
	            ^^^^^^^^^^^^^^^^^^^^^^^^^
The constructor RectangleSprite(int, int) is undefined
----------
2. ERROR in AssignmentEightLightsOutGame.java (at line 60)
	gameBoard.setSize(0.19);
	          ^^^^^^^
The method addSprite(Sprite...) in the type Game is not applicable for the arguments (RectangleSprite)
----------
4 problems (4 errors)

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