|
001 packagepackage is used to name the directory or folder a class is in Rohrer;
002
003 importimport means to make the classes and/or packages available in this program fang.*;
004 importimport means to make the classes and/or packages available in this program java.awt.*;
005 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
006
007 /**
008 * A random stupid Game that I created.
009 * @authorthis is the Javadoc tag for documenting who created the source code Kevin Rohrer
010 */
011 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 Interactive_Art_Assignment_6 extendsextends means to customize or extend the functionality of a class Game
012 {open braces start code blocks and must be matched with a close brace
013 ImageSprite nuke =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite("Rohrer-Nuke.jpg");
014 ImageSprite fire =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor ImageSprite("Rohrer-Fire.jpg");
015 publicpublic is used to indicate unrestricted access (any other class can have access) Sound bang =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound("Rohrer-Missile.wav");
016 publicpublic is used to indicate unrestricted access (any other class can have access) Sound burn =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor Sound("Rohrer-Fireball.wav");
017 publicpublic is used to indicate unrestricted access (any other class can have access) ProjectileTransformer bouncer;
018 publicpublic is used to indicate unrestricted access (any other class can have access) OutlineSprite screenOutline;
019 publicpublic is used to indicate unrestricted access (any other class can have access) Sprite bouncingBall;
020 publicpublic is used to indicate unrestricted access (any other class can have access) Sprite spin1, spin2;
021 publicpublic is used to indicate unrestricted access (any other class can have access) Sprite artist, title;
022
023
024 /**adds primary objects to the game*/
025 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
026 {open braces start code blocks and must be matched with a close brace
027 addScreenOutline();
028 titleAndArtist();
029 addFireNukeIcon();
030 bounceBall();
031 spiningBricks();
032 helpScreen();
033 }close braces end code blocks and must match an earlier open brace
034 /**handle input and game events*/
035 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
036 {open braces start code blocks and must be matched with a close brace
037 bounce();
038 soundWhenClick();
039 colorChange();
040 }close braces end code blocks and must match an earlier open brace
041
042
043 /** creates and adds the Fire and Nuke icon to screen */
044 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addFireNukeIcon()
045 {open braces start code blocks and must be matched with a close brace
046 fire.setSize(.2);
047 fire.setLocation(.9,.1);
048 addSprite(fire);
049
050 nuke.setSize(.2);
051 nuke.setLocation(.1,.1);
052 addSprite(nuke);
053 }close braces end code blocks and must match an earlier open brace
054 /** plays a sound when user clicks on ether the Nuke or the Fire icon */
055 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value soundWhenClick()
056 {open braces start code blocks and must be matched with a close brace
057 ifif executes the next statement only if the condition in parenthesis evaluates to true (getClick2D()!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) nuke.intersects(getClick2D()))
058 {open braces start code blocks and must be matched with a close brace
059 bang.setVolume(.5);
060 bang.play(.25);
061 }close braces end code blocks and must match an earlier open brace
062 ifif executes the next statement only if the condition in parenthesis evaluates to true (getClick2D()!=this is the not equals operator which evaluates to true if both sides are differentnullnull is the value used to refer to a non-existant object &this performs a bit-wise and (not the same as boolean and which is &&)&this performs a bit-wise and (not the same as boolean and which is &&) fire.intersects(getClick2D()))
063 {open braces start code blocks and must be matched with a close brace
064 burn.setVolume(.5);
065 burn.play(.75);
066 }close braces end code blocks and must match an earlier open brace
067 }close braces end code blocks and must match an earlier open brace
068
069 /** makes, adds, and sets spin velocity to the two spinning objects*/
070 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value spiningBricks()
071 {open braces start code blocks and must be matched with a close brace
072 spin1 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(3);
073 spin1.setLocation(.3,.7);
074 spin1.setSize(.2);
075 spin1.setColor(getColor("Lawn Green"));
076 addSprite(spin1);
077
078 spin2 =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(3);
079 spin2.setLocation(.7,.7);
080 spin2.setSize(.2);
081 spin2.setColor(getColor("Lawn Green"));
082 addSprite(spin2);
083
084 Spinner spinner;
085 spinner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Spinner(0);
086 spinner.setRotationDegrees(180);
087
088 spin1.addTransformer(spinner);
089 spin2.addTransformer(spinner);
090 }close braces end code blocks and must match an earlier open brace
091 /** exicutes the proper delayed color change of the spinning objects apon keypress*/
092 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value colorChange()
093 {open braces start code blocks and must be matched with a close brace
094 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'c')
095 {open braces start code blocks and must be matched with a close brace
096 schedule(newnew is used to create objects by calling the constructor DelayedResponse1(), 2.5);
097 }close braces end code blocks and must match an earlier open brace
098 ifif executes the next statement only if the condition in parenthesis evaluates to true(getKeyPressed()==this is the comparison operator which evaluates to true if both sides are the same'r')
099 {open braces start code blocks and must be matched with a close brace
100 schedule(newnew is used to create objects by calling the constructor DelayedResponse2(), 2.5);
101 }close braces end code blocks and must match an earlier open brace
102 }close braces end code blocks and must match an earlier open brace
103 /** changes color of spinning objects after a preset time*/
104 classclass is a group of fields and methods used for making objects DelayedResponse1 extendsextends means to customize or extend the functionality of a class TimedAction
105 {open braces start code blocks and must be matched with a close brace
106 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
107 {open braces start code blocks and must be matched with a close brace
108 spin1.setColor(getColor("red"));
109 spin2.setColor(getColor("red"));
110 }close braces end code blocks and must match an earlier open brace
111 }close braces end code blocks and must match an earlier open brace
112 /**changes color of spinning objects after a preset time*/
113 classclass is a group of fields and methods used for making objects DelayedResponse2 extendsextends means to customize or extend the functionality of a class TimedAction
114 {open braces start code blocks and must be matched with a close brace
115 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
116 {open braces start code blocks and must be matched with a close brace
117 spin1.setColor(getColor("Lawn Green"));
118 spin2.setColor(getColor("Lawn Green"));
119 }close braces end code blocks and must match an earlier open brace
120 }close braces end code blocks and must match an earlier open brace
121
122
123 /** creates and sets direction and speed of the bouncing ball */
124 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value bounceBall()
125 {open braces start code blocks and must be matched with a close brace
126 bouncingBall =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OvalSprite(1,1);
127 bouncingBall.setSize(.1);
128 bouncingBall.setLocation(.5,.3);
129 bouncingBall.setColor(getColor("orange"));
130 addSprite(bouncingBall);
131
132 bouncer=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor ProjectileTransformer(0.1, 0.5);
133 bouncingBall.addTransformer(bouncer);
134
135 schedule(newnew is used to create objects by calling the constructor Blinker(), .5);
136 }close braces end code blocks and must match an earlier open brace
137 /** makes the ball blink every 1/2 second*/
138 classclass is a group of fields and methods used for making objects Blinker extendsextends means to customize or extend the functionality of a class TimedAction
139 {open braces start code blocks and must be matched with a close brace
140 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value act()
141 {open braces start code blocks and must be matched with a close brace
142 booleanboolean is a type that is either true or false vis=this assignment operator makes the left side equal to the right sidebouncingBall.isVisible();
143 bouncingBall.setVisible(!this is the not operator, which changes true to false and false to truevis);
144 schedule(thisthis means the current object (the implicit parameter),.5);
145 }close braces end code blocks and must match an earlier open brace
146 }close braces end code blocks and must match an earlier open brace
147 /** sets bounce boundaries forfor is a looping structure for repeatedly executing a block of code bouncingBall */
148 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value bounce()
149 {open braces start code blocks and must be matched with a close brace
150 bouncingBall.bounceOffOf(screenOutline);
151 bouncingBall.bounceOffOf(fire);
152 bouncingBall.bounceOffOf(nuke);
153 bouncingBall.bounceOffOf(spin1);
154 bouncingBall.bounceOffOf(spin2);
155 }close braces end code blocks and must match an earlier open brace
156 /** creates the screen outline sprite to keep moving object on the screen */
157 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value addScreenOutline()
158 {open braces start code blocks and must be matched with a close brace
159 PolygonSprite screen =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor PolygonSprite(.0,.0,1,.0,1,1,.0,1);
160 screenOutline =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor OutlineSprite(screen);
161 screenOutline.setSize(1.1);
162 screenOutline.setLineThickness(0.05);
163 screenOutline.setLocation(0.5, 0.5);
164 screenOutline.setColor(getColor("black"));
165 addSprite(screenOutline);
166 }close braces end code blocks and must match an earlier open brace
167
168
169 /**makes and displays the artist and title of the game */
170 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value titleAndArtist()
171 {open braces start code blocks and must be matched with a close brace
172 artist =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("BY: Kevin Rohrer");
173 artist.setSize(.4);
174 artist.setLocation(.5, .95);
175 addSprite(artist);
176
177 title =this assignment operator makes the left side equal to the right side newnew is used to create objects by calling the constructor StringSprite("Headache Maker");
178 title.setSize(.55);
179 title.setLocation(.5, .1);
180 addSprite(title);
181 }close braces end code blocks and must match an earlier open brace
182
183
184 /** creates the text to go into the help screen*/
185 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value helpScreen()
186 {open braces start code blocks and must be matched with a close brace
187 String helpText=this assignment operator makes the left side equal to the right side
188 "click on an image to play its sound<br>"+adds two numbers together or concatenates Strings together
189 "or press the (C) or (R) key to change the color of the spining objects<br>"+adds two numbers together or concatenates Strings together
190 "Enjoy.";
191 setHelpText(helpText);
192 }close braces end code blocks and must match an earlier open brace
193 }close braces end code blocks and must match an earlier open brace
|