A fun HTML5 cave flyer game inspired by SFCave (https://www.sunflat.net/), with high scores and mobile support.
You can play the game at: https://bonewitz.net/jbcave/
- Smooth gameplay on both desktop and mobile devices
- Particle effects for crashes
- Local and global high score tracking
- Fully responsive design
- Time-based animation for consistent gameplay across devices
- Mobile-friendly controls and interface
jbcave/
├── css/ # Stylesheet files
│ └── style.css # Main game styles
├── js/ # JavaScript files
│ └── game.js # Game logic and rendering
├── php/ # Server-side code for high scores
│ ├── config.template.php # Database configuration template
│ ├── get_scores.php # API to fetch high scores
│ └── submit_score.php # API to submit new scores
├── index.html # Main game HTML
└── README.md # This file
-
Clone the repository:
git clone https://github.com/jbfly/jbcave.git cd jbcave -
If you want database features (global high scores):
- Copy
php/config.template.phptophp/config.php - Update database credentials in
config.php - Create the required MySQL/MariaDB table (see Database Setup below)
- Copy
-
Start a local web server in the project directory:
# Using PHP's built-in server (if PHP is installed) php -S localhost:8000 # OR using Python 3 python3 -m http.server 8000 # OR using Python 2 python -m SimpleHTTPServer 8000
-
Open your browser to http://localhost:8000
The global high score feature requires a MySQL/MariaDB database with the following structure:
CREATE DATABASE jbcave_db;
USE jbcave_db;
CREATE TABLE jbcave_highscores (
id INT AUTO_INCREMENT PRIMARY KEY,
player_name VARCHAR(20) NOT NULL,
score INT NOT NULL,
date_added TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create a dedicated user for the game (replace 'your_password' with a secure password)
CREATE USER 'jbcave_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT SELECT, INSERT, UPDATE, DELETE ON jbcave_db.* TO 'jbcave_user'@'localhost';
FLUSH PRIVILEGES;The game can be configured by editing the CONFIG object at the top of js/game.js:
const CONFIG = {
// API settings
apiBaseUrl: '/jbcave/php', // Path to PHP files
useServerFeatures: true, // Set to false to use localStorage only
// Game settings
targetFPS: 60,
// ... other settings
};Set useServerFeatures to false to disable database features and use only localStorage for high scores. This allows the game to be used without setting up a database.
This section describes how to set up a GitHub-based deployment workflow for the game.
-
SSH into your server:
ssh jbfly@bonewitz.net
-
Back up existing files if needed:
cd /srv/http/jbcave cp -r . ../jbcave-backup-$(date +%Y%m%d)
-
Install Git on your server if not already present:
# For Arch Linux sudo pacman -S git -
Clone the repository to your web directory:
cd /srv/http mv jbcave jbcave-old # If directory already exists git clone https://github.com/jbfly/jbcave.git
-
Set proper permissions:
sudo chown -R http:http jbcave chmod 655 /srv/http/jbcave/php/*.php -
Set up the database configuration:
cd /srv/http/jbcave/php cp config.template.php config.php nano config.php # Edit with your credentials
To avoid typing your password each time you deploy:
-
Generate an SSH key on your development machine (if you don't have one):
ssh-keygen -t ed25519 -C "your_email@example.com" -
Copy the key to your server:
ssh-copy-id jbfly@bonewitz.net
-
Create a deployment script in your development directory:
cd ~/git/jbcave-dev nano deploy.sh
-
Add this content to the script:
#!/bin/bash echo "Deploying JBCave to production..." # Push local changes to GitHub git add . git commit -m "Deployment: $(date)" git push # SSH into server and pull changes ssh jbfly@bonewitz.net 'cd /srv/http/jbcave && git pull' echo "Deployment complete!"
-
Make the script executable:
chmod +x deploy.sh
Whenever you want to deploy changes to production:
- Make changes in your local repository
- Test the changes locally
- Run the deployment script:
./deploy.sh
This will:
- Commit your changes to Git
- Push them to GitHub
- Pull the changes on your server
- If the script fails to connect to your server, check your SSH configuration
- If Git operations fail, ensure you have proper permissions
- If database features don't work, verify your config.php settings
- If your config.php gets overwritten, check that it's in your .gitignore file
- Original concept inspired by SFCave
- Developed by John Bonewitz