2.15.2 • Published 2 years ago

easy-educational-games v2.15.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Easy educational games

Documentation

https://hutnikus.github.io/easy-educational-games/

Template project

You can find the template project repository at https://github.com/hutnikus/easy-educational-games-testing

About

This module makes creating simple educational games simple.

How to use this module

  1. Create a new project. Use the command npm init -y
  2. Install this package with npm install easy-educational-games --save
  3. Create index.js file in the root of your project
  4. Paste this code into index.js
const g = require("easy-educational-games")
const path = require("path");
//set static folder
g.app.use(g.express.static(path.join(__dirname,"public")))
g.app.listen(g.PORT,"0.0.0.0",
    ()=>console.log(`Server running on port ${g.PORT}`)
)
  1. Create a new folder in your project called public, here will be the source code for your app and also the displayed page.
  2. If you only have 1 page, create files called index.html, script.js and a directory named resources in the public folder.
  3. If you want to use multiple pages, create a new directory for each page.
  4. Somewhere in the body of the html add a canvas element with the id game.
  5. On the end of the index.html file, paste the code <script src="script.js" type="module"></script> to include the source code of your app.
  6. In the script.js file, paste the code
import {Game} from "/modules/index.js"

const canvas = document.getElementById('game');
canvas.width = 600;
canvas.height = 600;

const game = new Game(canvas);
  1. Run the server with npm start

What does the pasted code in index.js do?

This is what is exported with require("easy-educational-games")

module.exports = {
    app,express,PORT,modulesPath
}
  • app is the express app
  • express is the express module
  • PORT is the port number (default is 3000, or process.env.PORT)
  • modulesPath is the path to the modules folder. In the express app, you can use /modules/index.js to load modules.

How to use this module

In the file script.js is the source code of your app. You import straight from node_modules, for the code to run locally (the path is automatically set).

Through importing you can access classes and some misc functions, that are defined in the documentation.

Look at the template project for an example of how to use this module.

2.11.0

2 years ago

2.2.0

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.6.1

2 years ago

2.6.0

2 years ago

2.8.0

2 years ago

2.5.5

2 years ago

2.15.2

2 years ago

2.15.0

2 years ago

2.15.1

2 years ago

2.13.0

2 years ago

2.3.0

2 years ago

2.12.0

2 years ago

2.5.0

2 years ago

2.10.0

2 years ago

2.7.0

2 years ago

2.5.2

2 years ago

2.5.1

2 years ago

2.9.0

2 years ago

2.5.4

2 years ago

2.7.1

2 years ago

2.5.3

2 years ago

2.14.3

2 years ago

2.14.4

2 years ago

2.14.1

2 years ago

2.14.2

2 years ago

2.14.0

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.11

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago