Warning If you run this code as-is while connected to FAST hardware, it will send commands that could damage your hardware. This is because your hardware isn't the same as mine, so it could send commands that will configure or trigger the wrong coils in the wrong ways, which could start a fire or cause serious injury including death.
NodeJS and NPM required, download here.
npm install
npm run start
Connect USB port on host computer to FAST Neuron Controller.
Open http://localhost:3000 with Chrome web browser (no other browsers supported, get Chrome).
The first time you will need to tell Chrome that this site is allowed to connect to the FAST serial port. To do this, open the console (F12) and enter this command and press enter:
window.onclick = () => {navigator.serial.requestPort({filters: [{usbVendorId: 11914, usbProductId: 4155}]})}
Then click anywhere in the browser window. A prompt should open asking you to select a port. Make sure you have figured out which one is the NET processor (usually the one with the lowest number, but not always) and select that one. Now reload the page (F5).
Optionally - you can try clicking on the splashscreen image that is displayed which should run the above command for you.
You should now be looking at the game running in your browser.
Unless your physical hardware is identical to mine, this game will not actually work. It isn't designed for everyone, just for me and one of my games. You will need to modify things for your game.
Find the code that looks like this: run({hardware: fast}), and change "fast" to "keyboard" (and update imports). Then go look at keyboard.ts to see what you can do with different keystrokes to emulate hardware and see how the UI reacts. This is not a virtual pinball game that you can play and have fun with without hardware, this is just a way to play with the code and see how things work when you don't have a physical pinball machine yet.
You can create a new file like fast.ts to support whatever hardware you have. It just needs to implement the Hardware interface, and it can be any code (that runs in Chrome) you want in that file -- you could make some totally random virtual hardware for example, or just some minor changes to the serial commands to make it work with FAST Nano or other serial based pinball hardware.
If you see code in here that isn't being used, I just forgot to delete it. I don't believe in having any unused code, or writing any code that I don't yet need. If I don't need it today, I don't need it tomorrow (until I do).
Keep it simple stupid. I'm stupid, so I write stupid code, but this is a good thing if you are also stupid, because maybe you will understand it. Stop learning, you were born smart enough, and go play pinball!
At any time, holding down the Select button for more than 1 second will toggle mute.
Any time while not playing, except during boot, holding down the Start button for more than 1 second will start a "Free Play" game.
UI showing various video clips full screen. Music playing full songs. Light show playing.
Select button shows a slide with options that flippers can change:
- View High Scores
- Flippers toggle between scores and option list slide
- View Last Game
- Flippers toggle between last game stats and option list slide
-
Song Select
-
Volume
-
Lights (on/dim/off)
Pressing select moves through each option above. Selected option flashes/blinks.
Pressing Start while options slide is showing will hide it. Pressing Start while not open will start Game Setup mode.
Select number of players and set initials.
UI also displays number of credits with "insert coin" or "press start" (when enough credits) info.
Press select to toggle through setup options and use flippers to adjust options.
Has a "Free Play" option which starts a single player game without any modes and does not require or use any credits, and always sets the initials to "MIA".
After 10 seconds of inactivity returns to Attract Mode.
If player tries to start a game and the machine isn't in the correct state yet, this mode runs until the machine is returned to normal state.
UI displays one of the switch names not in expected state, to assist service tech (if more than one, only one is shown at a time).
Holding Start button for more than 1 second will eject a ball, if possible, for scenarios where a ball could be used to unstick another ball or switch without opening the machine.
Advances to Playing & Mode Select mode when machine is in normal state.
After 60 seconds, if machine not in normal state, returns to Attract mode.
The same UI is shared during playing and mode select. The only difference is mode select happens while only 1 ball in play and that ball is sitting on the plunger switch ready to launch.
Playing UI displayed which contains sections:
-
Top line with players scores, initials, ball counts, with current player highlighted.
-
Next section reserved for dynamic status updates. Shows points earned, combo shot bonuses, tasks completed. Info not displayed for very long, slightly longer for more important achievements.
-
Lower Left corner displays to do list, so player knows what tasks they need to do and what they have completed for current mode.
- In Free Play mode, this section just displays some generic "free play" image/text.
- Lower right corner shows video clips. During mode select the clip changes as you cycle through modes and shows a little clip related to the mode. During game play videos related to completed tasks will play as each task is complete, short clips.
When game ends, return to Attract Mode, but default to showing slide with previous game stats.
While playing, Start button is used to eject ball at start of each new players turn. This helps make it obvious when it is the next turn vs just another ball for same player. In a single-player game, Start button is not used.
While playing, Select button skips song.
During mode select, pressing Select opens options menu (same as Attract Mode). Pressing Start returns to mode select. Launching ball will also close options menu since that will cause mode select to end.
During mode select, flippers are used to change modes. In Free Play mode flippers do nothing during mode select.
All modes are a collection of 1 to 3 steps. Each step has 1 to 4 tasks. Each task has a related target switch. Each target switch has an image related to it, as well as 1 or more video clips. The image is displayed on the UI and also on the playfield with an LED to indicate active targets (flashing) and complete targets (lit). A video clip (selected randomly) plays when task switch is hit (task complete).
Shots are a collection of 2 or more switches. Each shot has a flag for ordered/unordered, if ordered the switches must be hit in order. Each shot has a dificulty value, a multiplier used to calculate points earned if shot is completed. Each shot has 0 or more video clips that will be played (1 selected randomly) if shot is completed. Each shot has a name that will be displayed in the dynamic status update area of the UI if shot is completed.
Each switch has a dificulty value, a multiplier used to calculate points. Points are earned each time a switch is hit.
When ready to run game in the final setup run:
npm run build
This will run the production build and output the files to the folder setup in webpack.config.js which I have set to a shared folder on my host PC. The local path for the shared folder is c:\pinball\ and the network (UNC) path is \fastandfurious\pinball.
Setup a command similar to the following to run when your OS boots, to launch Chrome in kiosk mode (fullscreen without any other UIs or overlays visible) and load the app:
start /min serve "c:\pinball"
"C:\Program Files\Google\Chrome\Application\chrome.exe" --autoplay-policy=no-user-gesture-required --kiosk "http://localhost:3000"
If testing the --kiosk option you need to make sure Chrome is fully shutdown before running the command, otherwise it will be ignored.
Above example is using an npm package for the serve command. I was not able to avoid having a web server because Chrome does not save the serial port access when run using the file:// protocol.