|
01 packagepackage is used to name the directory or folder a class is in intro;
02 //start auto-imports
03 importimport means to make the classes and/or packages available in this program java.io.*;
04 importimport means to make the classes and/or packages available in this program java.util.*;
05 importimport means to make the classes and/or packages available in this program wiki.*;
06 //end auto-imports
07
08 importimport means to make the classes and/or packages available in this program fang.*;
09 importimport means to make the classes and/or packages available in this program java.awt.*;
10 importimport means to make the classes and/or packages available in this program java.awt.geom.*;
11
12 /**
13 * All about my game.
14 * @authorthis is the Javadoc tag for documenting who created the source code My Name Here
15 */
16 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 MazeGraphicsExample extendsextends means to customize or extend the functionality of a class Game
17 {open braces start code blocks and must be matched with a close brace
18 privateprivate is used to restrict access to the current class only Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays maze;
19
20 /**sets up the game*/
21 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value setup()
22 {open braces start code blocks and must be matched with a close brace
23 charchar is the type for a single letter or symbol and it is short for character[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays textMaze=this assignment operator makes the left side equal to the right sidegetMazeText("Maze3.txt");
24 maze=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Sprite[brackets are typically used to declare, initialize and index (indicate which element of) arraystextMaze.length]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraystextMaze[brackets are typically used to declare, initialize and index (indicate which element of) arrays0]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
25 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer r=this assignment operator makes the left side equal to the right side0; r<maze.length; r++this is the increment operator, which increases the variable by 1)
26 {open braces start code blocks and must be matched with a close brace
27 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer c=this assignment operator makes the left side equal to the right side0; c<maze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays.length; c++this is the increment operator, which increases the variable by 1)
28 {open braces start code blocks and must be matched with a close brace
29 ifif executes the next statement only if the condition in parenthesis evaluates to true(textMaze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays==this is the comparison operator which evaluates to true if both sides are the same'.')
30 maze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor OvalSprite(0.01, 0.01);
31 elseelse is what happens when the if condition is false
32 maze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor RectangleSprite(0.1, 0.1);
33 maze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays.setLocation(c*0.1+adds two numbers together or concatenates Strings together0.1, r*0.1+adds two numbers together or concatenates Strings together0.1);
34 addSprite(maze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays);
35 }close braces end code blocks and must match an earlier open brace
36 }close braces end code blocks and must match an earlier open brace
37 }close braces end code blocks and must match an earlier open brace
38
39 privateprivate is used to restrict access to the current class only charchar is the type for a single letter or symbol and it is short for character[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays getMazeText(String filename)
40 {open braces start code blocks and must be matched with a close brace
41 Scanner scanner=this assignment operator makes the left side equal to the right sidenullnull is the value used to refer to a non-existant object;
42 trytry is for executing a code block that may experience exceptions (errors)
43 {open braces start code blocks and must be matched with a close brace
44 scanner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Scanner(Wiki.getInputStream(filename));
45 }close braces end code blocks and must match an earlier open brace
46 catchcatch means to handle an exception that may occur(IOException e)
47 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
48 intint is the type for whole numbers and it is short for integer rows=this assignment operator makes the left side equal to the right sidescanner.nextInt();
49 intint is the type for whole numbers and it is short for integer cols=this assignment operator makes the left side equal to the right sidescanner.nextInt();
50 charchar is the type for a single letter or symbol and it is short for character[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays maze=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor charchar is the type for a single letter or symbol and it is short for character[brackets are typically used to declare, initialize and index (indicate which element of) arraysrows]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arrayscols]brackets are typically used to declare, initialize and index (indicate which element of) arrays;
51 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer r=this assignment operator makes the left side equal to the right side0; r<rows; r++this is the increment operator, which increases the variable by 1)
52 {open braces start code blocks and must be matched with a close brace
53 forfor is a looping structure for repeatedly executing a block of code(intint is the type for whole numbers and it is short for integer c=this assignment operator makes the left side equal to the right side0; c<cols; c++this is the increment operator, which increases the variable by 1)
54 {open braces start code blocks and must be matched with a close brace
55 maze[brackets are typically used to declare, initialize and index (indicate which element of) arraysr]brackets are typically used to declare, initialize and index (indicate which element of) arrays[brackets are typically used to declare, initialize and index (indicate which element of) arraysc]brackets are typically used to declare, initialize and index (indicate which element of) arrays=this assignment operator makes the left side equal to the right sidescanner.next().charAt(0);
56 }close braces end code blocks and must match an earlier open brace
57 }close braces end code blocks and must match an earlier open brace
58 returnreturn means to provide the result of the method and/or cease execution of the method immediately maze;
59 }close braces end code blocks and must match an earlier open brace
60
61 /**handle input and game events*/
62 publicpublic is used to indicate unrestricted access (any other class can have access) voidvoid means the method does not return a value advance()
63 {open braces start code blocks and must be matched with a close brace}close braces end code blocks and must match an earlier open brace
64 }close braces end code blocks and must match an earlier open brace
|