autumn bu gisti düzenledi . Düzenlemeye git
1 file changed, 9 insertions, 2 deletions
game.nv
@@ -21,10 +21,17 @@ | |||
21 | 21 | | '' start a $x by $y game | |
22 | 22 | | '@graphics' . canvas init canvas . set resolution $x $y | |
23 | 23 | 'DOM' ( <query canvas <style display = block margin = [1rem auto] > > ) | |
24 | - | '' game loop | |
24 | + | '' game loop 0 | |
25 | 25 | ||
26 | 26 | | '' next frame | |
27 | 27 | | '' @gas is now 50000 | |
28 | 28 | '@js' window.requestAnimationFrame(nextFrame); | |
29 | 29 | ||
30 | - | || '@js' const nextFrame = (dt) => { f("", "game", "loop", "" + dt); me.run(); } | |
30 | + | || '@js' | |
31 | + | let then = 0; | |
32 | + | const nextFrame = (now) => { | |
33 | + | const dt = now - then; | |
34 | + | then = now; | |
35 | + | f("", "game", "loop", dt); | |
36 | + | me.run(); | |
37 | + | } |
autumn bu gisti düzenledi . Düzenlemeye git
1 file changed, 1 insertion, 1 deletion
game.nv
@@ -27,4 +27,4 @@ | |||
27 | 27 | | '' @gas is now 50000 | |
28 | 28 | '@js' window.requestAnimationFrame(nextFrame); | |
29 | 29 | ||
30 | - | || '@js' const nextFrame = (dt) => { f("", "game", "loop", dt); me.run(); } | |
30 | + | || '@js' const nextFrame = (dt) => { f("", "game", "loop", "" + dt); me.run(); } |
autumn bu gisti düzenledi . Düzenlemeye git
1 file changed, 2 insertions, 2 deletions
game.nv
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | 7 | and you can create a game loop that updates like this : | |
8 | 8 | ||
9 | - | / '' game loop | |
9 | + | / '' game loop $dt | |
10 | 10 | / '' do something | |
11 | 11 | '' do something else | |
12 | 12 | '' next frame | |
@@ -27,4 +27,4 @@ | |||
27 | 27 | | '' @gas is now 50000 | |
28 | 28 | '@js' window.requestAnimationFrame(nextFrame); | |
29 | 29 | ||
30 | - | || '@js' const nextFrame = () => { f("", "game", "loop"); me.run(); } | |
30 | + | || '@js' const nextFrame = (dt) => { f("", "game", "loop", dt); me.run(); } |
autumn bu gisti düzenledi . Düzenlemeye git
1 file changed, 6 insertions
game.nv
@@ -12,6 +12,12 @@ | |||
12 | 12 | '' next frame | |
13 | 13 | ||
14 | 14 | ||
15 | + | || '@include' ( | |
16 | + | lib/gas.nv | |
17 | + | lib/platforms/browser_dom.nv | |
18 | + | lib/platforms/browser_game.nv | |
19 | + | ) | |
20 | + | ||
15 | 21 | | '' start a $x by $y game | |
16 | 22 | | '@graphics' . canvas init canvas . set resolution $x $y | |
17 | 23 | 'DOM' ( <query canvas <style display = block margin = [1rem auto] > > ) |
autumn bu gisti düzenledi . Düzenlemeye git
1 file changed, 24 insertions
game.nv(dosya oluşturuldu)
@@ -0,0 +1,24 @@ | |||
1 | + | | 'DOCUMENTATION' | ~~ | |
2 | + | this game library lets you create a canvas that you can | |
3 | + | update every frame . you can start a game like so : | |
4 | + | ||
5 | + | // '' start a 400 by 600 game | |
6 | + | ||
7 | + | and you can create a game loop that updates like this : | |
8 | + | ||
9 | + | / '' game loop | |
10 | + | / '' do something | |
11 | + | '' do something else | |
12 | + | '' next frame | |
13 | + | ||
14 | + | ||
15 | + | | '' start a $x by $y game | |
16 | + | | '@graphics' . canvas init canvas . set resolution $x $y | |
17 | + | 'DOM' ( <query canvas <style display = block margin = [1rem auto] > > ) | |
18 | + | '' game loop | |
19 | + | ||
20 | + | | '' next frame | |
21 | + | | '' @gas is now 50000 | |
22 | + | '@js' window.requestAnimationFrame(nextFrame); | |
23 | + | ||
24 | + | || '@js' const nextFrame = () => { f("", "game", "loop"); me.run(); } |