From this assignment, I took direct inspiration from the Matrix franchise to recreate their famous wall of green symbols.
At its core, the project consists of two main classes: MatrixSymbol
and Stream
.
-
- MatrixSymbol Class:
- Each character falling down the screen is represented by an instance of the
MatrixSymbol
class. - The
MatrixSymbol
class is responsible for storing properties such as position (x
,y
), character value (value
), speed (speed
), and brightness (brightness
). - Characters are randomly selected from a wide range of Unicode characters, including hiragana and kanji, providing diversity to the falling text effect.
- The
rain()
method handles the downward movement of the symbol, ensuring it wraps back to the top of the screen when reaching the bottom.
- Each character falling down the screen is represented by an instance of the
- Stream Class:
-
- A stream consists of multiple
MatrixSymbol
instances, forming a vertical column of falling text. - Each stream is generated with a random number of symbols (
totalSymbols
) and a random speed (speed
). - The
generateSymbols()
method populates the stream with symbols, positioning them at random vertical offsets to create a staggered appearance. - The
render()
method displays and animates the symbols within the stream, applying color variation to enhance visual appeal.
- A stream consists of multiple
The brightness of each symbol is randomly adjusted, creating subtle variations in color and brightness, adding depth to the visual effect.
Unicode Character Range: By utilizing a wide range of Unicode characters, including hiragana and kanji, I achieve a diverse selection of symbols. -
- MatrixSymbol Class:
Challenges:
Ensuring a balanced distribution of hiragana and kanji characters while maintaining randomness posed a challenge. Fine-tuning the character ranges was necessary to achieve a visually appealing mix.
As well, as the number of symbols and streams increases, performance may degrade. Thus it was important for me to write efficient code which would not suffer from performance degradation.