gregorycannon / tetristrainer Goto Github PK
View Code? Open in Web Editor NEWA web-based tetris client that allows you to enter custom piece sets to practice builds.
A web-based tetris client that allows you to enter custom piece sets to practice builds.
Recently, the Tetris pieces have been moving significantly faster than normal. After a bit of testing, it seems that the pieces are moving at roughly 60Hz, or twice the maximum possible rolling speed. While fun, that's not exactly a realistic setting.
I don't recall exactly when I noticed this, but it was no more than a few days ago. This suggests the bug was either caused by your latest batch of commits, or by upgrading Firefox to version 122.0.
I play on Firefox. When I tried it on Chrome, the pieces moved at normal speed. I suppose it's possible that one of my browser settings is relevant, but I don't know how to test that.
Steps to reproduce:
As a side note, I notice that the piece movement is slightly inconsistent. In the testing strategy above, sometimes the seventeenth I reaches the left, and sometimes it doesn't. I suspect this inconsistency is also a bug, but I don't know if it's part of the same bug, or an unrelated bug that I only noticed because I was testing this one.
When a game control key is an arrow key, pressing the key will scroll the webpage too.
For now I can zoom out the web page so that there is no scrolling possible, but wonder if there can be improvement in the code that can help with that.
Thanks for making this - I think this might be a really handy tool for practicing maintaining DAS for me!
Although it's actually nice for some practice to be slowing things down I do wonder if there's a performance issue that I'm seeing or maybe this implementation doesn't currently support real-time simulation?
I currently only get about 10-30fps with the default settings. I have i7-67k 4GHz Skylake PC, 32GB RAM plus an GTX 970 GPU. The GPU isn't that high-end but overall the system is reasonably decent, so I'd guess it should be able to easily simulate at 60fps to match the original NTSC NES fps.
A quick profiler recording in Chrome shows frames e.g. taking ~100ms
From there the gpu work looks like it's taking trivial amounts of time like 0.2ms
Looking at the stack traces on the main thread it looks like multiple frames are being processed in javascript for each frame presented - I'm not entirely sure why that would be the case but in general it looks like the javascript execution is also only taking a trivial amount of time.
The rasterizer thread looks like it's saturated so I suppose the issue with the canvas rendering the playfield on the cpu.
Since I have a 4k monitor so I guessed it might just be too high of a resolution and I tried dropping my monitor's resolution right down to 1024x768 just to experiment but was still seeing the same kind of performance.
I wonder if this is currently expected, or if not I wonder if there might be any known tricks for getting things running at a smooth 60fps?
The game should let one know the level they have chosen is not supported by the back end.
The game returns a cryptic error message
A helpful error message exists in the json request response, displayed below.
If the json parse fails, then the error could be set to the plain text of the response.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.