flipper-zero-tutorials/subghz/plugins/rock_paper_scissors/README.md

180 lines
6.9 KiB
Markdown
Raw Normal View History

# Rock Papper Scissors
2023-03-25 03:23:31 +00:00
![Flipper Zero Game](./prebuilt/win.png)
2023-03-04 21:17:45 +00:00
2023-02-15 16:26:53 +00:00
## Introduction
2023-03-04 21:17:45 +00:00
2023-03-25 03:23:31 +00:00
This is a multi-player game of Rock, Paper, Scissors! In version 1, we use the [Flipper Zero](https://flipperzero.one/) Sub-GHz radio to find other players, communicate moves, and exchange contact information.
2023-02-15 16:26:53 +00:00
2023-03-25 03:23:31 +00:00
Watch on [YouTube](https://youtu.be/eGOv6Gbar7I).
## Quick install directions for Flipper Zero running Official Firmware!
2023-03-25 04:06:02 +00:00
- Download the latest FAP file matching your firmware version. Copy the downloaded FAP file to the SD Card/apps/Games folder (using qFlipper or by ejecting the SD Card and inserting it into your PC).
- Official Firmware [Release 0.79.1](https://github.com/jamisonderek/flipper-zero-tutorials/raw/main/subghz/plugins/rock_paper_scissors/prebuilt/v1.0/official-firmware/release-0.79.1/Rock_Paper_Scissors.fap)
- Official Firmware [RC 0.80.0](https://github.com/jamisonderek/flipper-zero-tutorials/raw/main/subghz/plugins/rock_paper_scissors/prebuilt/v1.0/official-firmware/rc-0.80.0/Rock_Paper_Scissors.fap)
- [Archived releases](./prebuilt/v1.0/official-firmware) _(games may not have latest fixes & features)_
2023-03-25 03:23:31 +00:00
- If you have a different firmware, see the [installation directions](#installation-directions) below.
## Playing the game
These directions assume you are starting at the flipper desktop. If not, please press the back button until you are at the desktop.
2023-03-04 21:17:45 +00:00
2023-03-25 03:23:31 +00:00
- On both Flippers, launch the "Rock Paper Scissors" application.
- Press the OK button on the flipper to pull up the main menu.
- Choose "Applications" from the menu.
- Choose "Games" from the sub-menu.
- Choose "Rock Paper Scissors"
2023-03-06 04:18:32 +00:00
2023-03-25 03:23:31 +00:00
- On both Flippers, choose "Edit contact info".
- Enter your Discord name, or Facebook name, or whatever you want to share with other players.
- Hold the backspace button (top right) to clear the field.
- Hold a letter button to choose lowercase letters.
- Use the enter button (bottom right) to save your contact info.
2023-03-04 21:17:45 +00:00
2023-03-25 03:23:31 +00:00
- On Flipper 1, choose "Host game".
- select a valid frequency. (like "433.92" in US region)
- choose a game number (like "042")
- click OK button to start game.
- On Flipper 2, choose "Join game".
- select the same valid frequency as Flipper 1.
- "game none" should change to show the game number from Flipper 1 & its name.
- click OK button to join game.
- Once two players are joined:
- Press "OK" to send "1". The other player should also press "OK" to send "1" back - Press "OK" to send "2". The other player should also press "OK" to send "2" back - Press "UP" to send a "Rock", or "RIGHT" to send a "Paper", or "DOWN" to send a "Scissors".
- Rules:
- Rock beats Scissors.
- Paper beats Rock.
- Scissors beat Paper.
- Two identical items tie.
- Play again screen will show the results of the game.
- Click "Right" to select "No".
- Click "Left" to select "Yes" (the default).
- Click "OK" to answer the prompt.
- Short press the BACK button for the main menu.
- Long press the BACK button to exit the game.
## Status
V1 completed features:
- The game logic is complete (two flippers can play against each other.)
2023-02-15 16:26:53 +00:00
- UI to show Flipper images instead of just debug text.
2023-03-25 03:23:31 +00:00
- Allow changing contact information (discord, Facebook, etc.)
- Allow changing frequency, in case one Flipper is in a restricted region.
- Allow changing game number, in case multiple games at a conference.
2023-03-06 04:18:32 +00:00
- Show games found & let user pick the game to join.
2023-03-06 17:40:58 +00:00
- Receiving a Join game does an ACK (to cause game on joiner to start).
2023-03-25 03:23:31 +00:00
- A join ACK removes it from the list of available games.
- Vibro on button press (valid move).
- "Song" when win/loss/draw.
- Log game results & contact info onto SD card.
2023-03-07 01:51:41 +00:00
- Allow viewing past games/scores.
2023-03-24 13:12:37 +00:00
- Relaxed timing, so Count 1/Count 2/RPS no longer have to be timed tightly.
2023-03-25 03:23:31 +00:00
- Added a "Play again" screen.
- Play again from one Flipper Zero auto-starts/exit other Flipper Zero.
2023-03-04 21:17:45 +00:00
2023-03-25 03:23:31 +00:00
Planed work for V1.1:
2023-03-24 13:12:37 +00:00
- Wrap user content to two lines on Past Games screen.
2023-03-25 03:23:31 +00:00
- Allow for replacement of keyboard layout/keys.
2023-02-15 16:26:53 +00:00
- Refactor the code, so it has less duplication.
- Write tutorial.
2023-03-25 03:23:31 +00:00
2023-02-15 16:26:53 +00:00
Future ideas:
2023-03-04 21:17:45 +00:00
2023-03-24 13:12:37 +00:00
- Add game ending animations.
2023-02-15 16:26:53 +00:00
- Create stand-alone hardware badges that can play the game too.
2023-03-06 17:40:58 +00:00
- Uses Princeton signals for second player.
2023-02-15 16:26:53 +00:00
- Instead of subghz, use IR.
- Instead of subghz, use GPIO.
2023-03-25 03:23:31 +00:00
## Installation Directions
2023-03-04 21:17:45 +00:00
This project is intended to be overlayed on top of an existing firmware repo.
2023-03-04 21:17:45 +00:00
- Clone, Build & Deploy an existing flipper zero firmware repo. See this [tutorial](/firmware/updating/README.md) for updating firmware.
2023-03-25 03:23:31 +00:00
- Copy the "rock_paper_scissors" [folder](..) to the \applications_user\rock_paper_scissors folder in your firmware.
2023-03-04 21:17:45 +00:00
- Build & deploy the firmware. See this [tutorial](/firmware/updating/README.md) for updating firmware.
2023-03-25 03:23:31 +00:00
- NOTE: You can also copy rock_paper_scissors.FAP from latest\.extapps folder and use qFlipper to copy the file to the SD Card/apps/Misc folder.
2023-03-04 21:17:45 +00:00
## HackRF One
2023-03-04 21:17:45 +00:00
- If you do not have two Flipper Zero devices, you can use a HackRF One to record messages & broadcast those messages at a future date. I made a [YouTube](https://www.youtube.com/watch?v=S0sgcDQrVOc) video demo of how to record and broadcast messages.
- To record a message: (replace "flipper-chat.rf" with the file name you want to use, such as "select-rock.rf".)
2023-03-04 21:17:45 +00:00
```
sudo hackrf_transfer -r flipper-chat.rf -f 433920000 -s 8000000
```
2023-03-04 21:17:45 +00:00
- To broadcast a message: (replace "flipper-chat.rf" with the saved file name.)
```
sudo hackrf_transfer -r flipper-chat.rf -f 433920000 -s 8000000 -x 47
```
- What I typically do is:
2023-03-04 21:17:45 +00:00
- Use the Flipper Zero to send a messasge that I record, then I play back that message at a later time when I want to pretend the other Flipper Zero is sending a message. You can use the chat app in https://lab.flipper.net/cli, like shown in the video to send a specific packet (or you can use your own code to create the packet.)
2023-03-25 03:23:31 +00:00
- Use the HackRF One to record the message from my Flipper Zero. Then later I use the chat app in https://lab.flipper.net/cli, to see what the message was (or I replay the message to see how my application would respond.)
## Details about the project files
2023-03-04 21:17:45 +00:00
- application.fam
2023-03-04 21:17:45 +00:00
- specifies the name of our application.
- specifies the entry point for our application.
- specifies we use the GUI.
- specifies our icon is the rock_paper_scissors.png file.
2023-03-06 04:18:32 +00:00
- specifies our application can be found in the "Game" category.
- rock_paper_scissors.png
2023-03-04 21:17:45 +00:00
2023-03-06 04:18:32 +00:00
- The icon for our application.
- rock_paper_scissors.c
2023-03-25 03:23:31 +00:00
- This is the game applcation (tutorial coming soon).
2023-03-21 23:14:46 +00:00
## Example data
- Beacon for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:BA042
- Not Beacon for game 042:
Lumyphut: RPS:NA042
2023-03-21 23:14:46 +00:00
- Join game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:JA042NYourNameHere
2023-03-21 23:14:46 +00:00
- Join-ack for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:AA042NYourNameHere
2023-03-21 23:14:46 +00:00
- Count 1 for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:MA0421
2023-03-21 23:14:46 +00:00
- Count 2 for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:MA0422
2023-03-21 23:14:46 +00:00
- Rock for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:MA042R
2023-03-21 23:14:46 +00:00
- Paper for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:MA042P
2023-03-21 23:14:46 +00:00
- Scissors for game 042:
2023-03-23 18:24:24 +00:00
Lumyphut: RPS:MA042S