Compare commits
4 Commits
ddbde3a954
...
f3b63e0311
Author | SHA1 | Date |
---|---|---|
Alexander Popov | f3b63e0311 | |
Alexander Popov | ea321fc403 | |
Alexander Popov | 7a91471a38 | |
Alexander Popov | 0ca82b9564 |
|
@ -13,7 +13,7 @@
|
||||||
Запустите следующие команды, чтобы запустить процесс сборки `ujs`.
|
Запустите следующие команды, чтобы запустить процесс сборки `ujs`.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install
|
npm install --omit=dev
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -7,12 +7,11 @@
|
||||||
"watch": "ROLLUP_WATCH=true rollup --config rollup.config.js --watch",
|
"watch": "ROLLUP_WATCH=true rollup --config rollup.config.js --watch",
|
||||||
"prettier-check": "prettier --check .",
|
"prettier-check": "prettier --check .",
|
||||||
"prettier-write": "prettier --write .",
|
"prettier-write": "prettier --write .",
|
||||||
"editorconfig-check": "ec -exclude 'node_modules' .",
|
"editorconfig-check": "ec -exclude 'node_modules' ."
|
||||||
"docs-serve": "docsify serve docs"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-terser": "^0.4.4",
|
"@rollup/plugin-terser": "^0.4.4",
|
||||||
"docsify-cli": "^4.4.4",
|
"prettier": "2.8.7",
|
||||||
"prettier": "2.8.7"
|
"rollup": "^4.6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
src/main.js
13
src/main.js
|
@ -12,7 +12,7 @@ export class App {
|
||||||
options = {
|
options = {
|
||||||
backgroundColor: '#ffcc68',
|
backgroundColor: '#ffcc68',
|
||||||
welcome: true,
|
welcome: true,
|
||||||
},
|
}
|
||||||
) {
|
) {
|
||||||
this.#version = 'beeeeeeta';
|
this.#version = 'beeeeeeta';
|
||||||
|
|
||||||
|
@ -31,12 +31,13 @@ export class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scene = new Scene(this.canvas, this.context, w, h);
|
this.scene = new Scene(this.canvas, this.context, w, h);
|
||||||
this.prevTime = Date.now();
|
Settings.prevTime = Date.now();
|
||||||
|
|
||||||
const logStrings = [
|
const logStrings = [
|
||||||
'ujs engine',
|
'ujs engine',
|
||||||
`version: ${this.#version}`,
|
`version: ${this.#version}`,
|
||||||
'feedback: iiiypuk {dog} fastmail.fm',
|
'feedback: iiiypuk {dog} fastmail.fm',
|
||||||
|
'sources: https://git.a2s.su/emilecok/ujs',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (this.options.welcome) {
|
if (this.options.welcome) {
|
||||||
|
@ -51,9 +52,11 @@ export class App {
|
||||||
}
|
}
|
||||||
|
|
||||||
run = () => {
|
run = () => {
|
||||||
let newTime = Date.now();
|
// Calculating FPS
|
||||||
Settings.delta = (newTime - this.prevTime) / 1000;
|
let fpsNewTime = Date.now();
|
||||||
this.prevTime = newTime;
|
Settings.fpsDelta = (fpsNewTime - Settings.fpsPrevTime) / 1000;
|
||||||
|
Settings.fpsPrevTime = fpsNewTime;
|
||||||
|
Settings.fps = Math.round(1 / Settings.fpsDelta);
|
||||||
|
|
||||||
// clear canvas
|
// clear canvas
|
||||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||||
|
|
|
@ -135,10 +135,10 @@ export class TiledSprite extends Sprite {
|
||||||
let copyUpByY = Math.ceil(this.y / this.image().height);
|
let copyUpByY = Math.ceil(this.y / this.image().height);
|
||||||
let copyUpByX = Math.ceil(this.y / this.image().width);
|
let copyUpByX = Math.ceil(this.y / this.image().width);
|
||||||
let copyDownByY = Math.ceil(
|
let copyDownByY = Math.ceil(
|
||||||
(context.canvas.height - this.y - this.image().height) / this.image().height,
|
(context.canvas.height - this.y - this.image().height) / this.image().height
|
||||||
);
|
);
|
||||||
let copyDownByX = Math.ceil(
|
let copyDownByX = Math.ceil(
|
||||||
(context.canvas.width - this.y - this.image().width) / this.image().width,
|
(context.canvas.width - this.y - this.image().width) / this.image().width
|
||||||
);
|
);
|
||||||
|
|
||||||
for (let iy = 0; iy <= copyUpByY; iy++) {
|
for (let iy = 0; iy <= copyUpByY; iy++) {
|
||||||
|
@ -163,12 +163,12 @@ export class TiledSprite extends Sprite {
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
this.image(),
|
this.image(),
|
||||||
this.x + this.image().width * ix,
|
this.x + this.image().width * ix,
|
||||||
this.y - this.image().height * iy,
|
this.y - this.image().height * iy
|
||||||
);
|
);
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
this.image(),
|
this.image(),
|
||||||
this.x - this.image().width * ix,
|
this.x - this.image().width * ix,
|
||||||
this.y - this.image().height * iy,
|
this.y - this.image().height * iy
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -197,12 +197,12 @@ export class TiledSprite extends Sprite {
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
this.image(),
|
this.image(),
|
||||||
this.x + this.image().width * ix,
|
this.x + this.image().width * ix,
|
||||||
this.y + this.image().height * iy,
|
this.y + this.image().height * iy
|
||||||
);
|
);
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
this.image(),
|
this.image(),
|
||||||
this.x - this.image().width * ix,
|
this.x - this.image().width * ix,
|
||||||
this.y + this.image().height * iy,
|
this.y + this.image().height * iy
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class SceneLayer {
|
||||||
objects = Array(),
|
objects = Array(),
|
||||||
options = {
|
options = {
|
||||||
debug: false,
|
debug: false,
|
||||||
},
|
}
|
||||||
) {
|
) {
|
||||||
// TODO: check types
|
// TODO: check types
|
||||||
this.#objects = Array();
|
this.#objects = Array();
|
||||||
|
|
Loading…
Reference in New Issue