art-w / gamelle

2d game engine for OCaml
https://art-w.github.io/gamelle/gamelle/Gamelle/
MIT License
45 stars 1 forks source link

Inconsistent box-drawing semantics between sdl and js #3

Open ElectreAAS opened 2 months ago

ElectreAAS commented 2 months ago

In native mode (or sdl if I understand correctly), Box.fill .. (Box.v (Size.v 0.0 0.0) (Size.v 10.0 10.0)) will draw a box spanning pixels 0 to 10 included. If you do not want overlap between boxes, you then replace the 10s with 9s. However, in js mode, the code with 9s will leave blank pixels in between each box. See pictures for clarification.

ElectreAAS commented 2 months ago

Intended behaviour (with boxes drawn from 0 to 9 in sdl) image

The same code in js image

Not pictured is the 0 to 10 behaviour in js as it is the same as the first one, it works like intended.

Lastly, 0 to 10 behaviour in sdl with overlaps:

image

I could pass off the grid lines in the ghost blocks as stylistic choices, but you can also notice a weird overlap between the J block (dark blue) and the yellow square on the right (not the ghost one)

Plz fix

EmileTrotignon commented 2 months ago

I think this is related to the fact that JS uses float, and sdl ints. As gamelle made the choice of using floats, we should modify our sdl overlay to fit the JS behaviour and not the opposite.