Remarks: Processing Mazes

From Maze

(Difference between revisions)
Jump to: navigation, search
Line 66:Line 66:
The primary structure for the program is defined by the setup() and draw() blocks. Variables may be defined outside of these blocks, but everything else is sequenced through them. When the program starts, the variables outside of the blocks are declared and assigned. Next, the lines of code inside of setup() are read from top to bottom. Here, the size of the display window is set to be 640 pixels wide and 384 pixels high and the colors for the background and lines are defined. Next, the code inside draw() runs from top to bottom. The draw() block is unique because the code inside runs continuously from top to bottom until the program is terminated. The code defined by the if block within the draw() defines the random value and then draws one of the two possible lines. The code in the if block at the bottom of draw() moves the maze up when the maze line that is current drawing is filled. This code produces a program that behaves and looks more similarly to the original C64 code, but the process defined by the code is different.
The primary structure for the program is defined by the setup() and draw() blocks. Variables may be defined outside of these blocks, but everything else is sequenced through them. When the program starts, the variables outside of the blocks are declared and assigned. Next, the lines of code inside of setup() are read from top to bottom. Here, the size of the display window is set to be 640 pixels wide and 384 pixels high and the colors for the background and lines are defined. Next, the code inside draw() runs from top to bottom. The draw() block is unique because the code inside runs continuously from top to bottom until the program is terminated. The code defined by the if block within the draw() defines the random value and then draws one of the two possible lines. The code in the if block at the bottom of draw() moves the maze up when the maze line that is current drawing is filled. This code produces a program that behaves and looks more similarly to the original C64 code, but the process defined by the code is different.
−
There is a way within Processing to make the 10 PRINT work more similarly to the C64. This method uses the text Console of the Processing Development Environment (PDE) instead of the pixels in the display window. The Console in the PDE is typically used for error messages and writing debug statements through the print() and println() functions which are similar to CHR$() in BASIC. This technique may seem more like the C64, but the console can only print text; programs can't be written there. The other primary difference is the lack of the graphic characters of PETSCII (see p. ??) in the native console font for the PDE. As a result the / and \ characters need to be used in place of diagonal graphics. The result it spaces between the lines, which destroys the illusion of a continuous maze. The Processing program that produces this approximation of 10 PRINT is also a one-line program:
+
There is a way within Processing to make the 10 PRINT work more similarly to the C64. This method uses the text Console of the Processing Development Environment (PDE) instead of the pixels in the display window; this Console is typically used for error messages and writing debug statements through the print() and println() functions, which are similar to CHR$() in BASIC. This technique may seem more like the C64, but the console can only print text; programs can't be written there. The other primary difference is the lack of the graphic characters of PETSCII (see p. ??) in the native console font for the PDE. As a result the / and \ characters need to be used in place of diagonal graphics. The result it spaces between the lines, which destroys the illusion of a continuous maze. The Processing program that produces this approximation of 10 PRINT is also a one-line program:
void draw() { print((random(1) < 0.5) ? '/' : '\\'); }
void draw() { print((random(1) < 0.5) ? '/' : '\\'); }

Revision as of 14:11, 21 July 2011

View this revision of Remarks: Processing Mazes.

Personal tools