Skip to content

Commit

Permalink
Set up electron to build distributables.
Browse files Browse the repository at this point in the history
  • Loading branch information
erbridge committed Aug 23, 2015
1 parent 71fb810 commit 17abdc9
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 8 deletions.
18 changes: 18 additions & 0 deletions .electronignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.bundle
/.git
/_site
/build
/dist
/ld32
/node_modules
/promo-art
/raw-assets
*.sublime-*
.bowerrc
.electronignore
.gitignore
Gemfile
Gemfile.lock
README.md
bower.json
packager.json
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.bundle/
_site/
build/
dist/
node_modules/
*.sublime-workspace
78 changes: 70 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,74 @@
# Fatal Attraction

This is a game I made for Ludum Dare 32. The theme was **An Unconventional Weapon**.
> A game about a close encounter with gravity
## Tools
![title screen](/promo-art/title.png)

- [Sublime Text 3](http://www.sublimetext.com/) - IDE
- [Phaser](https://phaser.io/) - Engine
- [Chromium](https://www.chromium.org/) - Browser
- [GIMP](http://www.gimp.org/) - Art
- [Chiptone](http://sfbgames.com/chiptone/) - Audio
- [SunVox](http://www.warmplace.ru/soft/sunvox/) - Audio
This is a game originally made for Ludum Dare 32. The theme was **An Unconventional Weapon**.


## Install

Either play [online](http://erbridge.co.uk/fatal-attraction/) or download the appropriate [distribution for your system](/dist/).


## Develop

This game can be run directly in the browser, or run as a standalone executable using [Electron](http://electron.atom.io).


### Web

Since the site is hosted on GitHub Pages (hence `gh-pages` being the main branch), I use Jekyll when developing it. Any webserver would do, however.


#### Install

```
$ bundle install --path="./bundle"
```


#### Run

```
$ bundle exec jekyll serve --watch
```


### Electron

#### Install

```
$ npm install
```


#### Run

```
$ npm start
```


#### Build

```
$ npm run build
```


#### Distribute

```
$ npm run dist
```


### Assets

The raw audio assets can be found in `raw-assets/`, and are editable in:

- `.cpt` - [Chiptone](http://sfbgames.com/chiptone/)
- `.sunvox` - [SunVox](http://www.warmplace.ru/soft/sunvox/)
45 changes: 45 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

const app = require('app');
const BrowserWindow = require('browser-window');
const crashReporter = require('crash-reporter');

// Report crashes to the Electron project.
crashReporter.start();

// Prevent the main window from being GCed.
let mainWindow;

function onClosed() {
mainWindow = null;
}

function createMainWindow() {
const win = new BrowserWindow({
width: 1820,
height: 1024,
resizable: true
});

win.loadUrl(`file://${__dirname}/index.html`);

win.on('closed', onClosed);

return win;
}

app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate-with-no-open-windows', function () {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});

app.on('ready', function () {
mainWindow = createMainWindow();
});
48 changes: 48 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "fatal-attraction",
"productName": "FatalAttraction",
"version": "0.2.0",
"description": "A game about a close encounter with gravity",
"main": "index.js",
"license": "MIT",
"repository": "erbridge/fatal-attraction",
"author": {
"name": "Felix Laurie von Massenbach",
"email": "felix@erbridge.co.uk",
"url": "erbridge.co.uk"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"start": "electron .",
"clean": "rm -rf ./build",
"clean:linux": "rm -rf ./build/linux",
"clean:darwin": "rm -rf ./build/darwin",
"clean:win32": "rm -rf ./build/win32",
"build": "npm run build:linux && npm run build:darwin && npm run build:win32",
"build:darwin": "npm run clean:darwin && electron-packager . \"$npm_package_productName\" --out=build/darwin --platform=darwin --arch=x64 --version=0.31.0 --ignore=$(cat .electronignore | sed -e 's-^/-\\^/-g' | tr -s '\\n' | tr '\\n' '|' | sed -e 's/|$//g' -e 's/\\./\\\\\\./g' -e 's/\\*/\\.\\*/g') --prune --asar",
"build:linux": "npm run clean:linux && electron-packager . \"$npm_package_productName\" --out=build/linux --platform=linux --arch=x64 --version=0.31.0 --ignore=$(cat .electronignore | sed -e 's-^/-\\^/-g' | tr -s '\\n' | tr '\\n' '|' | sed -e 's/|$//g' -e 's/\\./\\\\\\./g' -e 's/\\*/\\.\\*/g') --prune --asar",
"build:win32": "npm run clean:win32 && electron-packager . \"$npm_package_productName\" --out=build/win32 --platform=win32 --arch=x64 --version=0.31.0 --ignore=$(cat .electronignore | sed -e 's-^/-\\^/-g' | tr -s '\\n' | tr '\\n' '|' | sed -e 's/|$//g' -e 's/\\./\\\\\\./g' -e 's/\\*/\\.\\*/g') --prune --asar",
"dist": "npm run dist:linux && npm run dist:darwin && npm run dist:win32",
"dist:darwin": "npm run build:darwin && mkdir -p \"dist/darwin-$npm_package_version\" && tar -czf \"dist/darwin-$npm_package_version/$npm_package_productName-darwin-x64-$npm_package_version.tar.gz\" -C build/darwin/ \"$npm_package_productName-darwin-x64\"",
"dist:linux": "npm run build:linux && mkdir -p \"dist/linux-$npm_package_version\" && tar -czf \"dist/linux-$npm_package_version/$npm_package_productName-linux-x64-$npm_package_version.tar.gz\" -C build/linux/ \"$npm_package_productName-linux-x64\"",
"dist:win32": "npm run build:win32 && mkdir -p \"dist/win32-$npm_package_version\" && pushd build/win32 && zip -q -r \"../../dist/win32-$npm_package_version/$npm_package_productName-win32-x64-$npm_package_version.zip\" \"$npm_package_productName-win32-x64\" && popd"
},
"files": [
"assets/",
"css/",
"js/",
"lib/",
"index.js",
"index.html",
"LICENSE"
],
"keywords": [
"electron-app"
],
"devDependencies": {
"electron-packager": "^5.0.2",
"electron-prebuilt": "^0.31.0"
}
}

0 comments on commit 17abdc9

Please sign in to comment.