You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There were no comments describing any of the access modifiers, as well as the methods: npcSpawn() and npcKill(). This commit provides documentation that describes what the NPC methods do, and also provides context for some mutators that can be potentially ambiguous (e.g. setMap(String Map_str)). This makes the code much easier to understand, especially since the integer values describing colour are hard to understand without supporting documentation (e.g. 500 is red). Not all access modifiers are documented since many are self-explanatory and would only create code clutter.
Copy file name to clipboardExpand all lines: src/com/redomar/game/Game.java
+60-50Lines changed: 60 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -32,58 +32,58 @@ public class Game extends Canvas implements Runnable {
32
32
privatestaticfinallongserialVersionUID = 1L;
33
33
privatestaticfinalStringgame_Version = "v1.8.3 Alpha"; // Current version of the game
34
34
privatestaticfinalintWIDTH = 160; // The width of the screen
35
-
privatestaticfinalintHEIGHT = (WIDTH / 3 * 2); // The height of the screen (two thirds of the width)
36
-
privatestaticfinalintSCALE = 3; // Scales the size of the screen (in either the x-direction, y-direction, or both)
35
+
privatestaticfinalintHEIGHT = (WIDTH / 3 * 2); // The height of the screen (two thirds of the width)
36
+
privatestaticfinalintSCALE = 3; // Scales the size of the screen (in either the x-direction, y-direction, or both)
37
37
privatestaticfinalStringNAME = "Game"; // The name of the JFrame panel
38
38
privatestaticGamegame;
39
39
privatestaticTimetime = newTime(); // Date object that represents the calender's time value, in hh:mm:ss
40
40
41
41
// The properties of the player, npc, and fps/tps
42
-
privatestaticintJdata_Host; // The host of a multiplayer game (only available in earlier versions)
42
+
privatestaticintJdata_Host; // The host of a multiplayer game (only available in earlier versions)
43
43
privatestaticStringJdata_UserName = ""; // The player's username (initialized as an empty string)
44
-
privatestaticStringJdata_IP = "127.0.0.1"; // Displays an IP address
44
+
privatestaticStringJdata_IP = "127.0.0.1"; // Displays an IP address
45
45
privatestaticbooleanchangeLevel = false; // Determines whether the level should change (initialized to not change)
46
-
privatestaticbooleannpc = false; // Non-player character (NPC) initialized to non-existing
47
-
privatestaticintmap = 0; // Map of the level, initialized to no map (0)
48
-
privatestaticintshirtCol; // The colour of the character's shirt
49
-
privatestaticintfaceCol; // The colour (ethnicity) of the character (their face)
46
+
privatestaticbooleannpc = false; // Non-player character (NPC) initialized to non-existing
47
+
privatestaticintmap = 0; // Map of the level, initialized to no map (0)
48
+
privatestaticintshirtCol; // The colour of the character's shirt
49
+
privatestaticintfaceCol; // The colour (ethnicity) of the character (their face)
50
50
privatestaticboolean[] alternateCols = newboolean[2]; // Boolean array with 2 elements (for determining shirt and face colour), all initialized to false
51
-
privatestaticintfps; // The frame rate (frames per second), frequency at which images are displayed on the canvas
52
-
privatestaticinttps; // The ticks (ticks per second), unit measure of time for one iteration of the game logic loop.
51
+
privatestaticintfps; // The frame rate (frames per second), frequency at which images are displayed on the canvas
52
+
privatestaticinttps; // The ticks (ticks per second), unit measure of time for one iteration of the game logic loop.
53
53
privatestaticintsteps;
54
-
privatestaticbooleandevMode; // Determines whether the game is in developer mode
55
-
privatestaticbooleanclosingMode; // Determines whether the game will exit
54
+
privatestaticbooleandevMode; // Determines whether the game is in developer mode
55
+
privatestaticbooleanclosingMode; // Determines whether the game will exit
56
56
57
57
// Audio, input, and mouse handler objects
58
-
privatestaticJFrameframe; // Frame with support for JFC/swing component architecture
58
+
privatestaticJFrameframe; // Frame with support for JFC/swing component architecture
59
59
privatestaticAudioHandlerbackgroundMusic; // AudioHandler object that can play music in the background (but can't turn it off)
60
-
privatestaticbooleanrunning = false; // Determines whether the game is currently in process (i.e. whether the game is running)
61
-
privatestaticInputHandlerinput; // InputHandler object that accepts keyboard input and follows the appropriate actions
62
-
privatestaticMouseHandlermouse; // MouseHandler object that tracks mouse movement and clicks, and follows the appropriate actions
63
-
privatestaticInputContextcontext; // InputContext object that provides methods to control text input facilities
60
+
privatestaticbooleanrunning = false; // Determines whether the game is currently in process (i.e. whether the game is running)
61
+
privatestaticInputHandlerinput; // InputHandler object that accepts keyboard input and follows the appropriate actions
62
+
privatestaticMouseHandlermouse; // MouseHandler object that tracks mouse movement and clicks, and follows the appropriate actions
63
+
privatestaticInputContextcontext; // InputContext object that provides methods to control text input facilities
64
64
privateinttickCount = 0;
65
65
66
66
// Graphics
67
-
privateBufferedImageimage = newBufferedImage(WIDTH, HEIGHT, // Describes a rasterized image with dimensions WIDTH and HEIGHT, and RGB colour
68
-
BufferedImage.TYPE_INT_RGB); // Set to TYPE_INT_ARGB to support transparency
67
+
privateBufferedImageimage = newBufferedImage(WIDTH, HEIGHT, // Describes a rasterized image with dimensions WIDTH and HEIGHT, and RGB colour
68
+
BufferedImage.TYPE_INT_RGB);
69
69
privateint[] pixels = ((DataBufferInt) image.getRaster().getDataBuffer()) // Array of red, green and blue values for each pixel, as well as an alpha value (if there is an alpha channel)
0 commit comments