satoshinm / netcraft Goto Github PK
View Code? Open in Web Editor NEWWeb-based fork of fogleman/Craft ⛺
Home Page: https://satoshinm.github.io/NetCraft/
License: MIT License
Web-based fork of fogleman/Craft ⛺
Home Page: https://satoshinm.github.io/NetCraft/
License: MIT License
Follow on to #39 - but instead of on initial load, when a user action causes pointer lock to disable itself:
Click to enable pointer lock, then Cmd-[ or otherwise lose focus, then Cmd-] back to the game. Move your mouse, and mouse look triggers. This is because the game believes the GLFW mouse cursor is still disabled. Possible fix: register for emscripten pointer lock callback https://kripken.github.io/emscripten-site/docs/api_reference/html5.h.html#pointerlock and when it is lost, re-enable the glfw cursor. (or could/should emscripten glfw port consider its cursor "disabled" when pointer lock is lost?)
Build for wasm in addition to asm.js, expected faster but less compatible (requires prerelease browsers at the time of this writing). Build for both and let the user choose, or fallback automatically.
Add -s WASM=1
to emcc, and BINARYEN_METHOD native-wasm and/or asmjs, refer to: https://github.com/kripken/emscripten/wiki/WebAssembly
https://kripken.github.io/emscripten-site/docs/optimizing/Optimizing-Code.html#avoid-memory-spikes-by-separating-out-asm-js says --separate-asm can improve performance / page load times by separating out the asm.js code from other JavaScript, ought to try this.
https://github.com/satoshinm/WebSandboxMC would need updating to serve the separate files, and when deploying on gh-pages, would also need to add this file too.
Develop small test cases and possible fixes for emscripten instead of only working-around in this repo.
This is all on emscripten 1.37.0, current latest emsdk.
With workarounds:
glfwGetInputMode(g->window, GLFW_CURSOR) == GLFW_CURSOR_DISABLED
after glfwSetInputMode(g->window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
- expect no-op/fail since can't request pointer lock (=GLFW_CURSOR_DISABLED) without user action? and/or glfwGetInputMode(GLFW_CURSOR) should get actual pointer lock status, like emscripten_get_pointerlock_status()
. #39 Mouse look triggers even when pointer lock inactive on first load added in https://github.com/satoshinm/emglfwbugs/blob/gh-pages/test_glfw_cursor_disabled/test_glfw_cursor_disabled.c
pointerlockchange
should re-enable cursor, since it is ~equivalent to pointer lock: glfwSetInputMode(g->window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
#44 Mouse look triggers even when pointer lock inactivated added in https://github.com/satoshinm/emglfwbugs/blob/gh-pages/test_glfw_cursor_disabled/test_glfw_cursor_disabled.c
glfwSetCharCallback
should not be called when Cmd is down, since that's not typing a charcater: #46 Cmd-Backquote types the Backquote keystroke to write on signs, instead of doing nothing added in https://github.com/satoshinm/emglfwbugs/blob/gh-pages/test_glfw_char_callback/test_glfw_char_callback.c
Without yet, may require emscripten fixes:
onblur
should reset key state for glfwGetKey()
etc.: #40 Keys stick - missing keyup event when losing focus? added in https://github.com/satoshinm/emglfwbugs/blob/gh-pages/test_glfw_get_key_stuck/test_glfw_get_key_stuck.c, partial workaround (ignore on blur, but sticks when refocus) and also changed #51emscripten_enter_soft_fullscreen()
shouldn't remove <body>
that's crazy: #49 Soft fullscreen removes <body>
element so document.body.style causes null deref added in https://github.com/satoshinm/emglfwbugs/blob/gh-pages/test_fullscreen_fullwindow_toggle/test_fullscreen_fullwindow_toggle.c, #52Testing on Chrome, press F11 to enter fullscreen, F11 again to exit, then this exception is thrown:
Uncaught TypeError: Cannot read property 'style' of null
at HTMLDocument.restoreOldStyle (craft.js:9026)
because emscripten's soft fullscreen seems to remove all other elements in the html document including <body>
, so document.body is null!
Attempted in #48 to workaround this by doing my own "windowed full" mode, but it stretches the canvas undesirably, so using soft fullscreen in emscripten is desirable but this is probably a bug in its implementation (who removes body from html? bad idea?).
Sometimes the game loads the player underground and they have to dig their way out:
or another workaround is to type /offline
to reload, this usually places them above ground:
What causes this, was it related to my changes? Could it be a race condition introduced with the refactoring in #36 multiplayer?
emcc is giving this warning when building with the current options:
cmake -DCMAKE_TOOLCHAIN_FILE=$EMSCRIPTEN/cmake/Modules/Platform/Emscripten.cmake ..
make
warning: emitted code will contain very large numbers of local variables, which is bad for performance (build to JS with -O2 or above to avoid this - make sure to do so both on source files, and during 'linking')
On a clean startup, the time is -7am (negative time?), which is very dark. This makes it hard to see the beautiful voxels. Instead the default time should be sometime in the day, either early morning or noon.
Especially important since on the web version there is no saving yet, so you see night whenever you reload.
$ grep CRAFT_KEY src/config.h
#define CRAFT_KEY_FORWARD 'W'
#define CRAFT_KEY_BACKWARD 'S'
#define CRAFT_KEY_LEFT 'A'
#define CRAFT_KEY_RIGHT 'D'
#define CRAFT_KEY_JUMP GLFW_KEY_SPACE
#define CRAFT_KEY_FLY GLFW_KEY_TAB
#define CRAFT_KEY_OBSERVE 'O'
#define CRAFT_KEY_OBSERVE_INSET 'P'
#define CRAFT_KEY_ITEM_NEXT 'E'
#define CRAFT_KEY_ITEM_PREV 'R'
#define CRAFT_KEY_ZOOM GLFW_KEY_LEFT_SHIFT
#define CRAFT_KEY_ORTHO 'F'
#define CRAFT_KEY_CHAT 't'
#define CRAFT_KEY_COMMAND '/'
#define CRAFT_KEY_SIGN '`'
The use of backquote to write in signs is not documented in the readme https://github.com/satoshinm/NetCraft/blob/master/README.md#controls or https://www.michaelfogleman.com/craft/ or anywhere I could find except the code.
Also not in the defines above, but Ctrl-click toggles a block as a light source.
After documenting, keep updated if:
At least document in readme, but ideally also in-game (next: configurable keys).
The console log shows tons of WebGL errors, track down where these come from and why:
craft.html:1249 Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:6871 WebGL: INVALID_ENUM: disable: invalid capability
craft.js:7409 WebGL: INVALID_VALUE: enableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_VALUE: vertexAttribPointer: index out of range
craft.js:7548 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:6940 WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
craft.js:7354 WebGL: INVALID_OPERATION: drawArrays: no buffer is bound to enabled attribute
craft.js:7708 WebGL: INVALID_ENUM: enable: invalid capability
craft.js:7708 WebGL: too many errors, no more errors will be reported to the console for this context.
Implement a simple inventory item system:
Allow moving more carefully when holding down the "shift key", aka crouching or sneaking. Slows down movement and prevents falling off an edge of the blocks. Important for survival.
Chests to store items in the world (tile entities), and an inventory dialog when right-clicking to manipulate the contents of the chest.
Needs first #18 Inventory, otherwise no purpose since blocks are infinite.
Later, afterwards expanding on this concept: workbench, crafting, recipes...
A handy keyboard shortcut to enter into the fullscreen mode. Should work at least on the web version, ideally also native (similar to clicking the maximize button).
Web fullscreen API: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
Similar to how the native Craft lets you give the server name/port on the command line, to automatically connect on launch, the web-based version should somehow allow automatically connecting to a given server.
Some ideas: parsing the document location hash (after #) or query string (after ?), interpreting as argv.
Important for sharing connections to servers as web links.
When you press Cmd-Backquote on the web-based port, this will switch to different windows within the same browser app, as expected, but the app also receives the backquote as a keystroke. This causes it to enter text typing mode to write some text as a sign, annoying.
The keystroke should be ignored, maybe ignore keys when modifiers (command, shift, control) are pressed, if this is possible? Or what does glfw receive?
Flying is toggled by pressing the "tab" key, but double jump (by double-tapping) space would be more intuitive.
Right now you have to click repeatedly to repeatedly break or build. This is a lot of clicking. You should instead be allowed to hold down a mouse button and have it repeat at some reasonable repeat rate.
Native platforms:
Web platform release types, see #1 and https://github.com/satoshinm/NetCraft#web-builds:
https://github.com/fogleman/Craft/network shows 612 forks, building on fogleman's original work, is there any which is the latest and greatest worth rebuilding on instead? Or are there forks or pull requests https://github.com/fogleman/Craft/pulls adding new features or fixes worth merging? Review all that is out there.
Currently the y coordinate ranges from 0 to 255, and chunks are identified by (p,q). To allow building higher and lower arbitrarily, just as it is possible to build in the X and Z directions arbitrarily, would be nice to change chunks from 32x256x32 to 32x32x32 and add another identifying coordinate (p,q,r), extending the Y dimension as far as X or Z.
Emscripten gives a warning about the library dl missing:
build $ make
Scanning dependencies of target craft
[ 5%] Building C object CMakeFiles/craft.dir/src/main.c.o
[ 11%] Linking C executable craft.html
WARNING:root:emcc: cannot find library "dl"
Unknown consequences.
Craft includes in deps/sqlite/sqlite3.c the "sqlite amalgamation" https://www.sqlite.org/amalgamation.html a very large file containing all of SQLite. Used for storing the world on disk, but slow to compile and takes up a lot of space.
There has to be a better way to do this on the web. Could either remove it entirely and rely on servers for persisting changes, or change the backend database to something more web-friendly:
Currently blocks break instantly when right-clicked. This is fine for "creative mode", but for an engaging survival experience, blocks should vary in hardness and some take longer to mine, where you have to click and hold to complete the mining process.
Interacts with #8 Repeat rate for left/right click, hold to continuously break/build
Continuation of #40 Keys stick - glfwGetKey() continues to return GLFW_PRESS even after onblur, loses focus
With the partial fix, this still happens:
At step 4, the game acts if Cmd is pressed, so that right-click+Cmd = illuminates a block and left-click+Cmd = right-click. Quite frustrating.
Until a possible emscripten fix (see GH-40), a practical workaround may only be to reassign this Cmd key to not be used for these purposes (swapping and illumination).
Can the definition of 'control' be narrowed? From src/main.c:
void on_key(GLFWwindow *window, int key, int scancode, int action, int mods) {
int control = mods & (GLFW_MOD_CONTROL | GLFW_MOD_SUPER);
this includes both Control and Command.
You can still look around with the mouse by moving it over the canvas, whether or not pointer lock is active. This could be considered a feature (for compatibility for browsers without pointer lock support?), but can also be annoying, moving the camera around when it is not desired. Pressing escape a few times disables this for some reason. Maybe if the browser supports pointer lock, only process mouse events if pointer lock is enabled?
Building on tall grass is difficult, because right-clicking on the tall grass block with another block seems to have no effect (hitbox related?). It should instead place the block in the same place as the tall grass, replacing it.
Reassign zoom to some key that is not shift. It makes taking screenshots awkward and is unfamiliar.
Shift should instead be crouch/sneak, once available: #4
What key for zoom? Control/Command? Z?
Play sound effects when things happen: breaking a block, placing a block, walking over a block, etc.
Should be possible to support both web and native through a suitable API. SDL audio APIs via emscripten to Web Audio API (or was Mozilla Audio API?), or OpenAL which "uses Web Audio and has buffer streaming support currently in the master branch.": http://stackoverflow.com/questions/18350537/getting-emscripten-streaming-audio-to-work
And then: music (mp3s streaming?)
Allow game content to be added at runtime.
If by the user, then JavaScript is a natural choice for the web, but then how would it be available in the native version? (embed JS interpreter?) JavaScript API to add new blocks, items?
Some mice make it too easy to inadvertently scroll through items, so having an option to disable this feature would be nice. Leave it on by default since users expect it, but allow turning it off (save in a cookie? IndexedDB-mounted filesystem of "local preferences"?) if desired by the user, just like https://github.com/stephank/mcdisablewheel/blob/master/README.md
The server code server.py
is written in Python, find out how it can be finagled to run in a web browser ala Craft written C compiled using emscripten, so users can host games in the browsers.
Would be more useful after #12 multiplayer support in web, to allow LAN-style parties
Allow the block texture sets (and other textures) to be dynamically changed by the user at runtime. "Reskinning" such as by dragging a new texture pack file onto the web client, reloading the GL atlases and redrawing the blocks.
Host a server somewhere (not in my browser at least until #14) open to anyone, for helping test and providing a live working environment.
fogleman has an official Craft server connectable with https://github.com/fogleman/Craft#client /online craft.michaelfogleman.com
in native, but web will necessarily not be compatible without changes (plain TCP vs WebSockets). After #12 multiplayer support in web version.
Space ascends when flying, but there is no opposite control to descend, you have to move the mouse to face downwards then press 'W'. There should be a key to descend directly, probably 'Shift'.
As an alternative or in addition to #12 multiplayer support connecting to servers in web version (websockets), consider some kind of peer-to-peer system where the world state is synced across nodes in a decentralized mesh network fashion instead of having a central server arbitrating truth.
WebRTC looks promising for this purpose: https://en.wikipedia.org/wiki/WebRTC
Maybe the idea is cooler than it sounds. But combined with #14 server code running in web browser, the idea would be you could create a world, have your friend join it seamlessly, and other friends join as well without bothering to setup and maintain or manage a central server in some datacenter somewhere.
The native version of Craft allows connecting to servers, using TCP sockets. The web version port should support it, too, probably using WebSockets with a specialized (WebSocket-capable) server.
https://en.wikipedia.org/wiki/WebSocket
See https://github.com/fogleman/Craft#multiplayer-1
Multiplayer
Multiplayer mode is implemented using plain-old sockets. A simple, ASCII, line-based protocol is used. Each line is made up of a command code and zero or more comma-separated arguments. The client requests chunks from the server with a simple command: C,p,q,key. “C” means “Chunk” and (p, q) identifies the chunk. The key is used for caching - the server will only send block updates that have been performed since the client last asked for that chunk. Block updates (in realtime or as part of a chunk request) are sent to the client in the format: B,p,q,x,y,z,w. After sending all of the blocks for a requested chunk, the server will send an updated cache key in the format: K,p,q,key. The client will store this key and use it the next time it needs to ask for that chunk. Player positions are sent in the format: P,pid,x,y,z,rx,ry. The pid is the player ID and the rx and ry values indicate the player’s rotation in two different axes. The client interpolates player positions from the past two position updates for smoother animation. The client sends its position to the server at most every 0.1 seconds (less if not moving).
Client-side caching to the sqlite database can be performance intensive when connecting to a server for the first time. For this reason, sqlite writes are performed on a background thread. All writes occur in a transaction for performance. The transaction is committed every 5 seconds as opposed to some logical amount of work completed. A ring / circular buffer is used as a queue for what data is to be written to the database.
In multiplayer mode, players can observe one another in the main view or in a picture-in-picture view. Implementation of the PnP was surprisingly simple - just change the viewport and render the scene again from the other player’s point of view.
websockify mentioned in emscripten-core/emscripten#595 (comment)
https://github.com/novnc/websockify previously wsproxy, "Websockify is a WebSocket to TCP proxy/bridge. This allows a browser to connect to any application/server/service. Implementations in Python, C, Node.js and Ruby."
Haven't track down the steps yet, but both the native and web-based clients are affected: sometimes, a key acts as if it is continuously held down, even when it isn't, usually occurs when switching in/out of focus to the app. For example, "A" may be held down and keep moving the player left. Pressing and releasing the key again unsticks it, but shouldn't it losing focus also release all keys?
Sometimes you want to see better but it is nighttime, all you can do now that I have found is to wait until the time changes. A command such as /time to alter the time would be indeed useful. Possible aliases /time day, /time night, /day, /night, perhaps even an option to freeze time and disable the daylight cycle.
/time 0 to 24, /daylength 0 freezes time at noon
The blocks array is 8-bit, supporting up to 256 block types:
// src/item.c
const int blocks[256][6] = {
// src/item.h
extern const int blocks[256][6];
Consider increasing this to 16-bit (for a total of 65536 block types), and testing to ensure elsewhere in the game (save file format, sqlite?) works well with it. Having this many block types may not be necessary yet, but it would be a good idea to plan ahead for future expansion e.g. to support variants of blocks in different orientations fogleman/Craft#116.
If Craft, native version only, is launched and it can't find adjacent texture/shader resource files, it crashes abruptly:
$ ./craft
error 78: failed to open file for reading
Bus error: 10
Should handle gracefully, but better yet, embed the resources in the executable as to allow relocation (similar to emscript --embed-file, so you don't have to worry about bringing over related files).
Light reading:
http://stackoverflow.com/questions/4158900/embedding-resources-in-executable-using-gcc - bin2c? satoshinm/nanogui@4aa9374
http://stackoverflow.com/questions/72616/embed-data-in-a-c-program
https://www.reddit.com/r/gamedev/comments/1k0tvy/i_need_some_help_with_wrapping_up_my_game_before/
ld -r -b binary
xxd -i file
Allow the client to interoperate with non-Craft server software. After support for Craft is working #12 multiplayer support for web version, expand to other servers. Make a short list for review.
When you are playing in the web-based version, the mouse works as expected with pointer lock, as do keystrokes, but the keys doubly interact: first with the game, and then with the webpage.
As an example, press space: it jumps, and pages down the site.
Capture and cancel these events to avoid unintended browser interaction (key preventDefault?)
Objects of arbitrary 3d models not locked to the world grid, unlike blocks.
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.