A simple demo showing off how OpenAI's ChatGPT and CapacitorJS can be used with Phaser to create a simple, mobile, AI-powered game.
This project requires a .env
file at root which contains the following line :
VITE_OPENAI_API_KEY=your-open-ai-api-key
To get an API key, you will first need to sign up with their developer site and generate the key on the API key page.
Once this is in place, run
npm install
to install the node packages required to run the site, then
npm run dev
to run the site locally on your computer.
Because you need an environment variable, deploying on GH pages is not a viable option. However, there are several static site hosts that would be a good fit. I personally prefer Vercel but all of them will support some version of this feature.
This project uses CapacitorJS to convert the site in to a working iOS or Android app. If you would like to do the same to your own app, simply run the following series of npm/npx commands.
npm install @capacitor/core @capacitor/cli
npx cap init
npm run build
npm install @capacitor/ios @capacitor/android
npx cap add ios // or npx cap add android for the android version of the same.