fruta 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DOCUMENTATION.MD +874 -0
- package/README.md +54 -0
- package/dist/main.js +1 -0
- package/index.html +9 -0
- package/package.json +37 -0
- package/settings.json +6 -0
- package/src/core/create/_fontCreator.js +11 -0
- package/src/core/create/_saveOrRestore.js +22 -0
- package/src/core/create/_shapeCreator.js +20 -0
- package/src/core/create/fontCreatorMixin.js +167 -0
- package/src/core/create/shapeCreatorMixin.js +656 -0
- package/src/core/fruta.js +22 -0
- package/src/core/game/game.js +30 -0
- package/src/core/game/scene.js +29 -0
- package/src/core/game/tick.js +42 -0
- package/src/core/utils/logStyle.js +8 -0
- package/src/core/utils/utils.js +0 -0
- package/src/methods/constants.js +0 -0
- package/src/methods/creator/_scene.js +0 -0
- package/src/methods/creator/creator.js +0 -0
- package/webpack.config.js +47 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
This is the scene file, where the canvases are created
|
|
4
|
+
and properties are assigned to them.
|
|
5
|
+
*/
|
|
6
|
+
import { consoleStyle } from '../utils/logStyle'
|
|
7
|
+
|
|
8
|
+
export default class Scene {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
this.config = config
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
createScene = () => {
|
|
14
|
+
/**
|
|
15
|
+
* @TODO
|
|
16
|
+
* Refactoring the code
|
|
17
|
+
* Implement more configurations for the canvas
|
|
18
|
+
*/
|
|
19
|
+
const canvas = document.createElement('canvas')
|
|
20
|
+
canvas.setAttribute('id', this.config.id)
|
|
21
|
+
|
|
22
|
+
canvas.width = this.config.w
|
|
23
|
+
canvas.height = this.config.h
|
|
24
|
+
|
|
25
|
+
document.body.appendChild(canvas)
|
|
26
|
+
|
|
27
|
+
consoleStyle("LET'S DO IT BABY!")
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description
|
|
3
|
+
The Tick class will be responsible for keeping track of the game time.
|
|
4
|
+
It will also have a specific method for rendering, which can be used to
|
|
5
|
+
render elements in real-time.
|
|
6
|
+
|
|
7
|
+
To accomplish this, we will use callbacks so that the user can choose which
|
|
8
|
+
things will be updated and which ones will not be updated.
|
|
9
|
+
|
|
10
|
+
(This is still subject to discussion.)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export default class Tick {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.tick = 0
|
|
16
|
+
this.lastFrameTick = Date.now()
|
|
17
|
+
this.updateCallback = null
|
|
18
|
+
this.run()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
run = () => {
|
|
22
|
+
const newTime = Date.now()
|
|
23
|
+
this.tick = this.tick += (newTime - this.lastFrameTick) / 1000
|
|
24
|
+
this.lastFrameTick = newTime
|
|
25
|
+
|
|
26
|
+
this.onRenderFunctionality()
|
|
27
|
+
|
|
28
|
+
requestAnimationFrame(this.run)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* Setters/Getters */
|
|
32
|
+
OnRender = (callback) => {
|
|
33
|
+
this.updateCallback = callback
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* functionalities here */
|
|
37
|
+
onRenderFunctionality = () => {
|
|
38
|
+
if (typeof this.updateCallback === 'function') {
|
|
39
|
+
this.updateCallback(this.tick)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const consoleStyle = (message) => {
|
|
2
|
+
const style =
|
|
3
|
+
'font-weight: bold; font-size: 50px;color: red; text-shadow: 3px 3px 0 rgb(217,31,38) , 6px 6px 0 rgb(226,91,14) , 9px 9px 0 rgb(245,221,8) , 12px 12px 0 rgb(5,148,68) , 15px 15px 0 rgb(2,135,206) , 18px 18px 0 rgb(4,77,145) , 21px 21px 0 rgb(42,21,113)'
|
|
4
|
+
|
|
5
|
+
return console.log(`%c${message}`, style)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { consoleStyle }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
3
|
+
|
|
4
|
+
const isProduction = process.env.NODE_ENV == 'production'
|
|
5
|
+
|
|
6
|
+
const config = {
|
|
7
|
+
entry: './src/core/fruta.js',
|
|
8
|
+
output: {
|
|
9
|
+
path: path.resolve(__dirname, 'dist'),
|
|
10
|
+
},
|
|
11
|
+
devServer: {
|
|
12
|
+
open: true,
|
|
13
|
+
host: 'localhost',
|
|
14
|
+
},
|
|
15
|
+
plugins: [
|
|
16
|
+
new HtmlWebpackPlugin({
|
|
17
|
+
template: 'index.html',
|
|
18
|
+
}),
|
|
19
|
+
|
|
20
|
+
// Add your plugins here
|
|
21
|
+
// Learn more about plugins from https://webpack.js.org/configuration/plugins/
|
|
22
|
+
],
|
|
23
|
+
module: {
|
|
24
|
+
rules: [
|
|
25
|
+
{
|
|
26
|
+
test: /\.(js|jsx)$/i,
|
|
27
|
+
loader: 'babel-loader',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
|
|
31
|
+
type: 'asset',
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
// Add your rules for custom modules here
|
|
35
|
+
// Learn more about loaders from https://webpack.js.org/loaders/
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = () => {
|
|
41
|
+
if (isProduction) {
|
|
42
|
+
config.mode = 'production'
|
|
43
|
+
} else {
|
|
44
|
+
config.mode = 'development'
|
|
45
|
+
}
|
|
46
|
+
return config
|
|
47
|
+
}
|