Concept
For this exercise, I wanted to merge two things: playful interactivity and meaningful (well almost) outcome. I came up with this Tetris-like game where instead of geometric blocks, words fall from the sky. Players can move these word blocks left or right with arrow keys to stack them into bizarre sentences or whatever they like.
The sentences hardly make sense; in fact, the randomness of the generated words is something that makes the results funny. This can be perceived as a silly project but it’s fun. Stack words – make nonsense – laugh.
Inspiration
The inspiration came from two souces:
- Tetris game
- Text Rain (by Camille Utterback, where letters fall and interact with the human body)
I wanted to combine the two ideas intro something playful but also generative, where the player becomes either a poet or a chaotic builder (or both) depending on the words that randomly fall and where they place them.
Code Structure
Here is the list of things I implemented this with:
- Array of words (tried to include nouns, verbs, adjectives, adverbs, connectors; however, this can be modified for the code meaning user can use any array of any words they like)
- fallingWord object that moves down the grid
- blocks array to store all placed word, and collision detection so blocks stack on top of each other or store at the floor.
- Keyboard controls to move words left and right within the canvas
- A small function to resize text dynamically. This was done keeping in mind that is user wants longer words in the array and they will be able to do so as the font size will be adjusted as needed.
Every new word is randomly chosen from the array, dropped from the top, and the loop continues.
Reflection
I liked how this project was fairly simple yet becomes engaging once the player is allowed to have some control. This is a result of both randomness (of the word array) and control (the stacking mechanism).
Challenges:
- Making sure words didn’t move out of canvas. I tried to put this condition in the same one as if keyPressed but that wasn’t to work. It turned out I have to create a nested condition to implement this.
- Handling long words that wouldn’t fit in the blocks. I thought whether to allocate more than 1 blocks for long words, but i realized that adjusting the font size is much convenient.
Future Improvements
- Add scoring system: If a player completes a sentence, they get a point. This requires the rules of grammar and is too difficult for me at present.
- Make the termination case: for now, I didn’t instruct the code what to do when the canvas is full. I think this is necessary for a game, but mine isn’t yet.