Implemented Electron packaging support
This commit is contained in:
35
main.js
Normal file
35
main.js
Normal 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
18
package.json
Normal 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"
|
||||
}
|
||||
}
|
@@ -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%);
|
||||
|
Reference in New Issue
Block a user