Skip to content

Commit

Permalink
v0.0.37 Update frame id by the end of the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed May 28, 2024
1 parent 065ad3e commit 1b287f9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
73 changes: 37 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
{
"name": "@vole-engine/core",
"version": "0.0.36",
"description": "Tiny 2D game engine",
"repository": "https://github.com/dinomintstudio/vole",
"author": "ivanjermakov",
"bugs": {
"url": "https://github.com/dinomintstudio/vole/issues"
},
"type": "module",
"license": "MIT",
"private": false,
"keywords": [
"vole",
"game-engine",
"game-engine-2d"
],
"scripts": {
"build:dev": "tsc",
"build:prod": "tsc -p tsconfig.prod.json && cp package.json dist",
"clean": "rm -r dist",
"test": "jest --watchAll",
"ci": "jest --ci"
},
"devDependencies": {
"@types/node": "~18.16.3",
"@types/jasmine": "~4.3.1",
"typescript": "~5.0.4",
"ts-node": "~10.9.1",
"jest": "~29.5.0",
"@jest/globals": "~29.5.0",
"@swc/core": "~1.3.56",
"@swc/jest": "~0.2.26"
},
"dependencies": {
"rxjs": "~7.8.1"
}
"name": "@vole-engine/core",
"version": "0.0.37",
"description": "Tiny 2D game engine",
"repository": "https://github.com/dinomintstudio/vole",
"author": "ivanjermakov",
"bugs": {
"url": "https://github.com/dinomintstudio/vole/issues"
},
"type": "module",
"license": "MIT",
"readme": "README.md",
"private": false,
"keywords": [
"vole",
"game-engine",
"game-engine-2d"
],
"scripts": {
"build:dev": "tsc",
"build:prod": "tsc -p tsconfig.prod.json && cp package.json dist",
"clean": "rm -r dist",
"test": "jest --watchAll",
"ci": "jest --ci"
},
"devDependencies": {
"@types/node": "~18.16.3",
"@types/jasmine": "~4.3.1",
"typescript": "~5.0.4",
"ts-node": "~10.9.1",
"jest": "~29.5.0",
"@jest/globals": "~29.5.0",
"@swc/core": "~1.3.56",
"@swc/jest": "~0.2.26"
},
"dependencies": {
"rxjs": "~7.8.1"
}
}
7 changes: 4 additions & 3 deletions src/engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ export class Engine {
this.requestId = this.requestFrame(gameLoop)

const delta = frameFireTime - (this.frameInfo?.lastFrameMillis ?? 0)
this.frameInfo.id = ++this.frameCount
this.frameInfo.lastFrameMillis = frameFireTime
this.frameInfo.lastFrameDelta = delta

const beforeUpdate = performance.now()
this.eventDispatcher.beforeUpdate.next(delta)
Expand All @@ -79,6 +76,10 @@ export class Engine {
this.performanceInfo.fps = 1000 / delta
this.performanceInfo.fpsPotential = 1000 / this.performanceInfo.updateDelta
this.frameInfo.frameRequestMillis = afterUpdate

this.frameInfo.id = ++this.frameCount
this.frameInfo.lastFrameMillis = frameFireTime
this.frameInfo.lastFrameDelta = delta
}

gameLoop(performance.now())
Expand Down

0 comments on commit 1b287f9

Please sign in to comment.