|
001 packagepackage is used to name the directory or folder a class is in Newman;
002 //start auto-imports
003 //end auto-imports
004
005 importimport means to make the classes and/or packages available in this program fang.*;
006 importimport means to make the classes and/or packages available in this program java.awt.*;
007 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
008
009 /**
010 * All about my game.
011 * @authornull My Moriah
012 */
013 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects Assignment_6 extendsextends means to customize or extend the functionality of a class Game
014 {open braces start code blocks and must be matched with a close brace
015 privateprivate is used to restrict access to the current class only intint is the type for whole numbers and it is short for integer numClicks;
016 privateprivate is used to restrict access to the current class only ImageSprite monkey;
017 privateprivate is used to restrict access to the current class only ImageSprite walker;
018 privateprivate is used to restrict access to the current class only PieSprite banana;
019 privateprivate is used to restrict access to the current class only OvalSprite spin;
020 privateprivate is used to restrict access to the current class only StringSprite title;
021 privateprivate is used to restrict access to the current class only StringSprite name;
022
023
024
025 /**sets up the game*/
026 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
027
028 {open braces start code blocks and must be matched with a close brace
029 makeAndAddHelpSetup();
030 makeAndAddMonkey();
031 makeAndAddWalker();
032 makeAndAddBanana();
033 makeAndAddSpin();
034 makeAndAddTitle();
035 makeAndAddName();
036
037
038 }close braces end code blocks and must match an earlier open brace
039 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddHelpSetup()
040 {open braces start code blocks and must be matched with a close brace
041 String helpText=this assignment operator makes the left side equal to the right side
042 " press start to begain";
043 setHelpText(helpText);
044 }close braces end code blocks and must match an earlier open brace
045
046 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddMonkey()
047 {open braces start code blocks and must be matched with a close brace
048 monkey=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite("Monkey3.gif");
049 monkey.setSize(.3);
050 monkey.setLocation(.2,.1);
051 addSprite(monkey);
052 }close braces end code blocks and must match an earlier open brace
053 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddBanana()
054
055 {open braces start code blocks and must be matched with a close brace
056 numClicks=this assignment operator makes the left side equal to the right side1;
057 banana=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor PieSprite( 1,1,30,250);
058 banana.setSize(.15);
059 OutlineTransformer transformer;
060 transformer=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTransformer(0.25,
061 0.35, 0.2,
062 0.5, 0.4,
063 0.7, 0.6,
064 0.7, 0.5,
065 0.7, 0.3,
066 0.35,0.2);
067 transformer.setLooping(truetrue is the boolean value that is the opposite of false);
068
069 banana.addTransformer(transformer);
070 banana.setLocation(transformer.getCurrentPoint());
071 banana.setColor(Palette.getColor("Yellow"));
072 addSprite(banana);
073
074 }close braces end code blocks and must match an earlier open brace
075 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddWalker()
076 {open braces start code blocks and must be matched with a close brace
077 walker=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ImageSprite ("Walk.gif");
078 walker.setSize(.25);
079 OutlineTransformer transformer;
080 transformer=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OutlineTransformer(0.15,
081 0.5, 0.8,
082 0.7, 0.8,
083 0.9, 0.8);
084 transformer.setLooping(truetrue is the boolean value that is the opposite of false);
085
086 walker.addTransformer(transformer);
087 walker.setLocation(transformer.getCurrentPoint());
088 addSprite(walker);
089 }close braces end code blocks and must match an earlier open brace
090 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddSpin()
091 {open braces start code blocks and must be matched with a close brace
092 spin=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(1,3);
093 spin.setSize(.25);
094 spin.setColor(Palette.getColor("Lime Green"));
095 spin.setLocation(.8,.2);
096 addSprite(spin);
097
098 Spinner twirl;
099 twirl=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
100 twirl.setRotationDegrees(85);
101 spin.addTransformer(twirl);
102 }close braces end code blocks and must match an earlier open brace
103 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddTitle()
104 {open braces start code blocks and must be matched with a close brace
105 title=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Monkey Business");
106 title.setSize(.5);
107 title.setLocation(.3,.5);
108 title.setColor(Palette.getColor("Hot Pink"));
109 addSprite(title);
110 }close braces end code blocks and must match an earlier open brace
111 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value makeAndAddName()
112 {open braces start code blocks and must be matched with a close brace
113 name=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor StringSprite("Moriah Newman");
114 name.setSize(.35);
115 name.setLocation(.25,.6);
116 name.setColor(Palette.getColor("Lime Green"));
117 addSprite(name);
118
119 }close braces end code blocks and must match an earlier open brace
120 privateprivate is used to restrict access to the current class only voidvoid means the method does not return a value handleCollisions()
121 {open braces start code blocks and must be matched with a close brace
122 banana.bounceOffOf(walker);
123 }close braces end code blocks and must match an earlier open brace
124 /**handle input and game events*/
125 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
126 {open braces start code blocks and must be matched with a close brace
127 handleCollisions();
128 }close braces end code blocks and must match an earlier open brace
129
130 }close braces end code blocks and must match an earlier open brace
|