Implemented Electron packaging support

This commit is contained in:
Marcel
2017-12-16 11:14:20 +01:00
parent d89defae7e
commit 05a4f1abd3
3 changed files with 56 additions and 2 deletions

35
main.js Normal file
View File

@@ -0,0 +1,35 @@
const {app, BrowserWindow} = require('electron');
const path = require('path');
const url = require('url');
let win;
function createWindow () {
win = new BrowserWindow({width: 975, height: 600, minHeight: 300, minWidth: 975});
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}));
win.openDevTools();
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', () => {
if (win === null) {
createWindow()
}
});

18
package.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "Tetris.js",
"version": "0.0.1",
"main": "main.js",
"description": "Tetris.js is a decent but cool clone of the retro game classic Tetris",
"scripts": {
"start": "electron main.js",
"package": "asar pack Tetris.js-win32-x64/resources/app Tetris.js-win32-x64/resources/app.asar",
"build": "electron-packager . Tetris.js"
},
"author": "KingOfDog",
"license": "MIT",
"devDependencies": {
"asar": "^0.14.0",
"electron": "^1.7.9",
"electron-packager": "^10.1.0"
}
}

View File

@@ -23,17 +23,18 @@ body {
font-weight: 900;
font-size: 40px;
top: 50%;
left: 25%;
right: 75%;
transform: translate(-50%, -50%);
color: #fff;
}
#score:before {
content: 'Score:';
content: 'Score: ';
}
#controls {
left: 75%;
right: 0;
font-size: 20px;
font-weight: 300;
transform: translate(0, -50%);