Skip to content

Commit f731bf5

Browse files
authored
Merge pull request #170 from litecanvas/next
Next
2 parents 8fb598e + 88b6e4b commit f731bf5

File tree

3 files changed

+31
-39
lines changed

3 files changed

+31
-39
lines changed

bun.lock

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
"workspaces": {
44
"": {
55
"name": "litecanvas",
6-
"dependencies": {
7-
"tap-min": "^3.0.0",
8-
},
96
"devDependencies": {
10-
"@swc/core": "^1.12.1",
7+
"@swc/core": "^1.12.3",
118
"ava": "^6.4.0",
129
"esbuild": "^0.25.5",
1310
"gzip-size": "^7.0.0",
1411
"prettier": "^3.5.3",
12+
"tap-min": "^3.0.0",
1513
},
1614
},
1715
},
@@ -84,27 +82,27 @@
8482

8583
"@sindresorhus/merge-streams": ["@sindresorhus/[email protected]", "", {}, "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg=="],
8684

87-
"@swc/core": ["@swc/[email protected].1", "", { "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.23" }, "optionalDependencies": { "@swc/core-darwin-arm64": "1.12.1", "@swc/core-darwin-x64": "1.12.1", "@swc/core-linux-arm-gnueabihf": "1.12.1", "@swc/core-linux-arm64-gnu": "1.12.1", "@swc/core-linux-arm64-musl": "1.12.1", "@swc/core-linux-x64-gnu": "1.12.1", "@swc/core-linux-x64-musl": "1.12.1", "@swc/core-win32-arm64-msvc": "1.12.1", "@swc/core-win32-ia32-msvc": "1.12.1", "@swc/core-win32-x64-msvc": "1.12.1" }, "peerDependencies": { "@swc/helpers": ">=0.5.17" }, "optionalPeers": ["@swc/helpers"] }, "sha512-aKXdDTqxTVFl/bKQZ3EQUjEMBEoF6JBv29moMZq0kbVO43na6u/u+3Vcbhbrh+A2N0X5OL4RaveuWfAjEgOmeA=="],
85+
"@swc/core": ["@swc/[email protected].3", "", { "dependencies": { "@swc/counter": "^0.1.3", "@swc/types": "^0.1.23" }, "optionalDependencies": { "@swc/core-darwin-arm64": "1.12.3", "@swc/core-darwin-x64": "1.12.3", "@swc/core-linux-arm-gnueabihf": "1.12.3", "@swc/core-linux-arm64-gnu": "1.12.3", "@swc/core-linux-arm64-musl": "1.12.3", "@swc/core-linux-x64-gnu": "1.12.3", "@swc/core-linux-x64-musl": "1.12.3", "@swc/core-win32-arm64-msvc": "1.12.3", "@swc/core-win32-ia32-msvc": "1.12.3", "@swc/core-win32-x64-msvc": "1.12.3" }, "peerDependencies": { "@swc/helpers": ">=0.5.17" }, "optionalPeers": ["@swc/helpers"] }, "sha512-c4NeXW8P3gPqcFwtm+4aH+F2Cj5KJLMiLaKhSj3mpv19glq+jmekomdktAw/VHyjsXlsmouOeNWrk8rVlkCRsg=="],
8886

89-
"@swc/core-darwin-arm64": ["@swc/[email protected].1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-nUjWVcJ3YS2N40ZbKwYO2RJ4+o2tWYRzNOcIQp05FqW0+aoUCVMdAUUzQinPDynfgwVshDAXCKemY8X7nN5MaA=="],
87+
"@swc/core-darwin-arm64": ["@swc/[email protected].3", "", { "os": "darwin", "cpu": "arm64" }, "sha512-QCV9vQ/s27AMxm8j8MTDL/nDoiEMrANiENRrWnb0Fxvz/O39CajPVShp/W7HlOkzt1GYtUXPdQJpSKylugfrWw=="],
9088

91-
"@swc/core-darwin-x64": ["@swc/[email protected].1", "", { "os": "darwin", "cpu": "x64" }, "sha512-OGm4a4d3OeJn+tRt8H/eiHgTFrJbS6r8mi/Ob65tAEXZGHN900T2kR7c5ALr0V2hBOQ8BfhexwPoQlGQP/B95w=="],
89+
"@swc/core-darwin-x64": ["@swc/[email protected].3", "", { "os": "darwin", "cpu": "x64" }, "sha512-LylCMfzGhdvl5tyKaTT9ePetHUX7wSsST7hxWiHzS+cUMj7FnhcfdEr6kcNVT7y1RJn3fCvuv7T98ZB+T2q3HA=="],
9290

93-
"@swc/core-linux-arm-gnueabihf": ["@swc/[email protected].1", "", { "os": "linux", "cpu": "arm" }, "sha512-76YeeQKyK0EtNkQiNBZ0nbVGooPf9IucY0WqVXVpaU4wuG7ZyLEE2ZAIgXafIuzODGQoLfetue7I8boMxh1/MA=="],
91+
"@swc/core-linux-arm-gnueabihf": ["@swc/[email protected].3", "", { "os": "linux", "cpu": "arm" }, "sha512-DQODb7S+q+pwQY41Azcavwb2rb4rGxP70niScRDxB9X68hHOM9D0w9fxzC+Nr3AHcPSmVJUYUIiq5h38O5hVgQ=="],
9492

95-
"@swc/core-linux-arm64-gnu": ["@swc/[email protected].1", "", { "os": "linux", "cpu": "arm64" }, "sha512-BxJDIJPq1+aCh9UsaSAN6wo3tuln8UhNXruOrzTI8/ElIig/3sAueDM6Eq7GvZSGGSA7ljhNATMJ0elD7lFatQ=="],
93+
"@swc/core-linux-arm64-gnu": ["@swc/[email protected].3", "", { "os": "linux", "cpu": "arm64" }, "sha512-nTxtJSq78AjeaQBueYImoFBs5j7qXbgOxtirpyt8jE29NQBd0VFzDzRBhkr6I9jq0hNiChgMkqBN4eUkEQjytg=="],
9694

97-
"@swc/core-linux-arm64-musl": ["@swc/[email protected].1", "", { "os": "linux", "cpu": "arm64" }, "sha512-NhLdbffSXvY0/FwUSAl4hKBlpe5GHQGXK8DxTo3HHjLsD9sCPYieo3vG0NQoUYAy4ZUY1WeGjyxeq4qZddJzEQ=="],
95+
"@swc/core-linux-arm64-musl": ["@swc/[email protected].3", "", { "os": "linux", "cpu": "arm64" }, "sha512-lBGvC5UgPSxqLr/y1NZxQhyRQ7nXy3/Ec1Z47YNXtqtpKiG1EcOGPyS0UZgwiYQkXqq8NBFMHnyHmpKnXTvRDA=="],
9896

99-
"@swc/core-linux-x64-gnu": ["@swc/[email protected].1", "", { "os": "linux", "cpu": "x64" }, "sha512-CrYnV8SZIgArQ9LKH0xEF95PKXzX9WkRSc5j55arOSBeDCeDUQk1Bg/iKdnDiuj5HC1hZpvzwMzSBJjv+Z70jA=="],
97+
"@swc/core-linux-x64-gnu": ["@swc/[email protected].3", "", { "os": "linux", "cpu": "x64" }, "sha512-61wZ8hwxNYzBY9MCWB50v90ICzdIhOuPk1O1qXswz9AXw5O6iQStEBHQ1rozPkfQ/rmhepk0pOf/6LCwssJOwg=="],
10098

101-
"@swc/core-linux-x64-musl": ["@swc/[email protected].1", "", { "os": "linux", "cpu": "x64" }, "sha512-BQMl3d0HaGB0/h2xcKlGtjk/cGRn2tnbsaChAKcjFdCepblKBCz1pgO/mL7w5iXq3s57wMDUn++71/a5RAkZOA=="],
99+
"@swc/core-linux-x64-musl": ["@swc/[email protected].3", "", { "os": "linux", "cpu": "x64" }, "sha512-NNeBiTpCgWt80vumTKVoaj6Fa/ZjUcaNQNM7np3PIgB8EbuXfyztboV7vUxpkmD/lUgsk8GlEFYViHvo6VMefQ=="],
102100

103-
"@swc/core-win32-arm64-msvc": ["@swc/[email protected].1", "", { "os": "win32", "cpu": "arm64" }, "sha512-b7NeGnpqTfmIGtUqXBl0KqoSmOnH64nRZoT5l4BAGdvwY7nxitWR94CqZuwyLPty/bLywmyDA9uO12Kvgb3+gg=="],
101+
"@swc/core-win32-arm64-msvc": ["@swc/[email protected].3", "", { "os": "win32", "cpu": "arm64" }, "sha512-fxraM7exaPb1/W0CoHW45EFNOQUQh0nonBEcNFm2iv095mziBwttyxZyQBoDkQocpkd5NtsZw3xW5FTBPnn+Vw=="],
104102

105-
"@swc/core-win32-ia32-msvc": ["@swc/[email protected].1", "", { "os": "win32", "cpu": "ia32" }, "sha512-iU/29X2D7cHBp1to62cUg/5Xk8K+lyOJiKIGGW5rdzTW/c2zz3d/ehgpzVP/rqC4NVr88MXspqHU4il5gmDajw=="],
103+
"@swc/core-win32-ia32-msvc": ["@swc/[email protected].3", "", { "os": "win32", "cpu": "ia32" }, "sha512-FFIhMPXIDjRcewomwbYGPvem7Fj76AsuzbRahnAyp+OzJwrrtxVmra/kyUCfj4kix7vdGByY0WvVfiVCf5b7Mg=="],
106104

107-
"@swc/core-win32-x64-msvc": ["@swc/[email protected].1", "", { "os": "win32", "cpu": "x64" }, "sha512-+Zh+JKDwiFqV5N9yAd2DhYVGPORGh9cfenu1ptr9yge+eHAf7vZJcC3rnj6QMR1QJh0Y5VC9+YBjRFjZVA7XDw=="],
105+
"@swc/core-win32-x64-msvc": ["@swc/[email protected].3", "", { "os": "win32", "cpu": "x64" }, "sha512-Sf4iSg+IYT5AzFSDDmii08DfeKcvtkVxIuo+uS8BJMbiLjFNjgMkkVlBthknGyJcSK15ncg9248XjnM4jU8DZA=="],
108106

109107
"@swc/counter": ["@swc/[email protected]", "", {}, "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ=="],
110108

package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
22
"name": "litecanvas",
3-
"version": "0.83.3",
3+
"version": "0.83.4",
44
"description": "Lightweight HTML5 canvas 2D game engine suitable for small projects and creative coding. Inspired by PICO-8 and P5/Processing.",
55
"license": "MIT",
66
"author": "Luiz Bills <[email protected]>",
77
"contributors": [],
88
"devDependencies": {
9-
"@swc/core": "^1.12.1",
9+
"@swc/core": "^1.12.3",
1010
"ava": "^6.4.0",
1111
"esbuild": "^0.25.5",
1212
"gzip-size": "^7.0.0",
13-
"prettier": "^3.5.3"
13+
"prettier": "^3.5.3",
14+
"tap-min": "^3.0.0"
1415
},
1516
"homepage": "https://litecanvas.github.io/about.html",
1617
"repository": {
@@ -39,8 +40,7 @@
3940
"2d",
4041
"html5",
4142
"gamedev",
42-
"game",
43-
"engine",
43+
"game engine",
4444
"javascript",
4545
"js13k",
4646
"creative-coding",
@@ -57,8 +57,5 @@
5757
"tests/**/*",
5858
"!tests/_mocks"
5959
]
60-
},
61-
"dependencies": {
62-
"tap-min": "^3.0.0"
6360
}
6461
}

src/index.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,29 +1401,26 @@ export default function litecanvas(settings = {}) {
14011401
* @param {DOMHighResTimeStamp} now
14021402
*/
14031403
function drawFrame(now) {
1404-
let updated = 0,
1405-
frameTime = (now - _lastFrameTime) / 1000
1406-
1407-
_lastFrameTime = now
1404+
let updated = 0
14081405

14091406
if (settings.animate) {
1410-
if (frameTime > 0.3) {
1411-
console.warn('skipping too long frame')
1412-
} else {
1413-
_accumulated += frameTime
1414-
1415-
while (_accumulated >= _deltaTime) {
1416-
updated++
1417-
instance.emit('update', _deltaTime * _timeScale, updated)
1418-
instance.def('T', instance.T + _deltaTime * _timeScale)
1419-
_accumulated -= _deltaTime
1420-
}
1407+
// prevents too long frames
1408+
_accumulated += math.min(0.2, (now - _lastFrameTime) / 1000)
1409+
_lastFrameTime = now
1410+
1411+
while (_accumulated >= _deltaTime) {
1412+
updated++
1413+
instance.emit('update', _deltaTime * _timeScale, updated)
1414+
instance.def('T', instance.T + _deltaTime * _timeScale)
1415+
_accumulated -= _deltaTime
14211416
}
14221417

14231418
// request the next frame
14241419
// check if the last ID exists, because
14251420
// quit() delete it (sets to zero)
1426-
if (_rafid) _rafid = raf(drawFrame)
1421+
if (_rafid) {
1422+
_rafid = raf(drawFrame)
1423+
}
14271424
} else {
14281425
// when the canvas is not animated
14291426
// we force one frame when redraws are triggered

0 commit comments

Comments
 (0)