Here’s a quick weekend project: tennis, but played by typing. Try it out!
Here’s a quick weekend project: tennis, but played by typing. Try it out!
* I type "hit" to serve (note: for consistency you should require ENTER on this word, too)
* Ball slowly travels, CPU returns it
* Return word appears
* I type the return word and press ENTER
* No matter what I do, once the ball gets close to my side, the "HINT" pops up and won't go away until I start typing the return word again
* Whether I type the word correctly or not, my guy fails to return the ball
Latest Firefox on MacOS.
Hope you get this sorted out -- it looks fun
It would also probably be more effective to not change the mechanics between the starting hit and subsequent ones. Instead of automatically starting after typing "hit," the user should have to hit "Enter" as well.
To clarify, the game actually runs a quick validation when the timer runs out to check if your word is valid. If it is, the ball returns automatically—so you don't have to hit Enter or Space, but doing so early gives you a speed bonus.
As for getting rid of Enter/Space entirely, auto-submitting can be tricky with compound words (e.g., should it submit 'REGULAR' or wait for 'REGULARLY'?).
Fun way to waste 10 minutes, though! :) I like the 8-bit look and sound. Would be nice a little bigger!
EDIT: After winning the second game it’s not as easy.
I was suspicious when I first coded this that it needed a better way to introduce the rules. I've gone ahead and buffed the HINT so that time doesn't resume until you get a chance to type out your first word. I also added a background hint on the return phase instead of just leaving it blank.
Another comment mentioned that the instructions that I put on itch.io made it clearer (and forgot to post on HN, whoops!) so I've pasted them below.
-------------------
HOW TO PLAY
1. Type HIT to serve
2. Type your opponent's word to line up your character with the ball, then type your word to send a volley back
3. Submit your word before the time runs out. The faster you submit your word, the faster your hit!
RULES
1. Words must be 3 letters or longer
2. No repeated words in the same rally
SCORING
1. Tennis rules: 15-30-40-Game
2. Best of 3 games wins the match
CONTROLS
Desktop: Type and press Enter or Space to submit
Mobile: On-screen keyboard
SwiftyBug•1h ago