Code Monkey home page Code Monkey logo

lwc-oss-snake-game's Introduction

๐Ÿ LWC OSS Snake Game

GitHub CI

The project was born out of pure interest in using Lightning Web Components outside of the Salesforce platform. I was inspired to the Snake idea by the following blog article and reused some of the game code:

How to Build the Snake Game Using Lightning Web Components

If you are also interested in LWC OSS you can find more info here: https://lwc.dev/

Preview

preview

Project Setup

The directory structure looks like this:

src/
  โ”œโ”€โ”€ assets/           // static assets
  โ”‚   โ””โ”€โ”€ fonts/
  โ”‚   โ””โ”€โ”€ icons/
  โ”‚   โ””โ”€โ”€ images/
  โ”‚   โ””โ”€โ”€ styles/
  |   โ””โ”€โ”€ favicon.ico
  โ””โ”€โ”€ layouts/          // lwc layouts
  โ”‚   โ””โ”€โ”€ main.html
  โ””โ”€โ”€ modules/          // lwc modules
      โ””โ”€โ”€ snake/
          โ””โ”€โ”€ app/
              โ”œโ”€โ”€ app.css
              โ”œโ”€โ”€ app.html
              โ””โ”€โ”€ app.js
          โ””โ”€โ”€ game/
              โ”œโ”€โ”€ game.css
              โ”œโ”€โ”€ game.html
              โ””โ”€โ”€ game.js
lwr.config.json         // lwr configuration
package.json            // npm packaging configuration

Configuration

The LWR server is configured in lwr.config.json, at the root of the project. It has two LWC module and one server-side route.

{
  "lwc": { "modules": [{ "dir": "$rootDir/src/modules" }, { "npm": "lightning-base-components" }] },
  "routes": [
    {
      "id": "snake",
      "path": "/",
      "rootComponent": "snake/app",
      "layoutTemplate": "$layoutsDir/main.html",
      "bootstrap": {
        "syntheticShadow": true
      }
    }
  ],
  "assets": [
    {
      "alias": "assetsDir",
      "dir": "$rootDir/src/assets",
      "urlPath": "/assets"
    },
    {
      "dir": "$rootDir/src/assets/fonts",
      "urlPath": "/fonts"
    },
    {
      "alias": "favicon",
      "file": "$rootDir/src/assets/favicon.ico",
      "urlPath": "/favicon.ico"
    }
  ]
}

Running Linter and Prettier

Run Prettier to check all files for formatting issues:

yarn run prettier

Run ESLint to check for linting issues:

yarn run lint

Running the Project in Dev Mode

Install all required dependencies:

yarn install

Start the local development server:

yarn dev

Open the site at http://localhost:3000

Statically Generate and Preview the Site

Build the project:

yarn build

Preview the generated site:

yarn start

Open the site at http://localhost:3000

lwc-oss-snake-game's People

Contributors

dependabot[bot] avatar svierk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.