twiddlingbits / twr-wasm

twr-wasm: easily run C/C++ code in a web browser using Web Assembly, with examples
https://twiddlingbits.dev/
MIT License
15 stars 1 forks source link

single player pong unnecessary scrolling due to extra width #38

Open twiddlingbits opened 1 week ago

twiddlingbits commented 1 week ago

Windows 11, Chrome

In single Player pong, it seems to be creating a canvas (or perhaps other HTML element) that is unnecessarily large ot the right (width), that causes a scroll bar to appear and interfere with the right arrow/left arrow movement of the paddle. Using the debug console in chrome to shows this, but i imagine you could also get the issue to appear by reducing the width of the browser window.

image
JohnDog3112 commented 1 day ago

The main problem with this is it seems like changing the canvas size without recreating the render context causes it to just stretch the original resolution to the new one. So I would either need to use the scale function before rendering anything or there needs to be some way to reset the context.

twiddlingbits commented 3 hours ago

as we discussed, i think the best thing is to add something like d2d_resize_canvas (or probably an io_resizetype call that operates on the twrConCanvas.) See io_setfocusfor something roughy similar. Alternaty would be a function to create and delete consoles from C. Something I have been mulling over adding for a while. This concept can be extended to allow the creation, deletion of any twrLibraryderived class from C.