Skip to content

This is a racing game for Windows, written in pure JS, converted into an application with Electron js

License

Notifications You must be signed in to change notification settings

mr-crodo/racing-game

Repository files navigation

racing-game

This is a racing game for Windows, written in pure JS, converted into an application with Electron js

Instagramm

Linkedin

Telegram

This repository is a full-fledged little game in the form of a desktop application.

Racing Game

npm Electron

Electron-packager PATH

Electron is a framework for building desktop applications using JavaScript, HTML, and CSS. By embedding Chromium and Node.js into its binary, Electron allows you to maintain one JavaScript codebase and create cross-platform apps that work on Windows, macOS, and Linux — no native development experience required..

Description

The main goal of the project was to make a game out of html, css and native js that would easily run on desktops.

  • The game is realized in 2D.
  • All the necessary photographs of the cars are already in the folder with images in png format.
  • There is also music that runs along with the game, which is located in the audio folder
  • Special JSX flags can be used during compile time to optimize runtime performance at application level
  • Many micro optimizations

Browser support

Build Status

Manual guides

Code Example

To operate Electron, you need to create a JS file with a name different from the main program code

And write down the next set of commands:

const url = require('url').format({
  protocol: 'file',
  slashes: true,
  pathname: require('path').join(__dirname, 'index.html')
});

Initialize Electron JS, And create a win object:

const {app, BrowserWindow} = require('electron');

let win;

After that, we create a wrapper for our program with a width and a length createWindow () function that loads index.html into a new BrowserWindow instance

function createWindow() {
  win = new BrowserWindow({
    width: 500,
    height: 850
  });

  win.loadURL(url);

  win.on('closed', function() {
    win = null;
  });
}

On Windows and Linux, exiting all windows will usually close the application completely.

To do this, listen for the app module's 'window-all-closed' event and call [app.quit ()] [app-quit] if the user is not using macOS (darwin).

app.on('ready', createWindow);

app.on('window-all-closed', function(){
  app.quit();
})

Getting Started

Core package:

npm install 

To run the program:

# to run from terminal
npm start

To create a folder with a Windows application with an .exe extension, enter the following command :

# Creates a folder with a name `racing-game-win32-x64`
electron-packager .

Game screenshots

Racing Game

Racing Game

Racing Game

Racing Game

Sponsors

About

This is a racing game for Windows, written in pure JS, converted into an application with Electron js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published