ippa / jaws

Jaws - HTML5 canvas javascript 2D Game Framework
https://jawsjs.ippa.se
GNU Lesser General Public License v3.0
363 stars 75 forks source link

Problem with viewport.move(x,y), when argument is float #63

Closed tabok closed 11 years ago

tabok commented 11 years ago

Hi. I have a problem with viewport when it's moved by non-integer numbers. There is modified example#12:

http://dreamella.pl/jaws/examples/example12,5.html

I change the droids moving speed from 2.00 to 2.11 and add red background to canvas. If you move droid to position, for example, 400, 400 you will see red lines. This problem appear in Fire Fox 18, Opera Next 12.12 and Internet Explorer 9. In Google Chrome 23.0.1271.97 m (latest version) work fine.

My OS is Windows 7 Proffesional up to date.

MalphasWats commented 11 years ago

what would be the purpose of moving things by non-integer amounts? It's all pixels, which are generally indivisible...

tabok commented 11 years ago

In my game, objects can move with different speeds - for example character move 134 pixels per second. Server shifts objects inside memory, so it knows the speed of objects Jaws have to display object on map in correct position including zoom and FPS rate (on my netbook is only 18-20 FPS, on my phone 8-10 FPS and on my PC 45-50 FPS)

Distance per frame may be different and its often non-integer value. Of course I can shift by integer values, if it is neccesary but it is time-consuming for me.

MalphasWats commented 11 years ago

I see. Somewhere along the line, it gets converted to an integer and what you're seeing is each browser's different attempt at doing so. You'd be better off doing explicitly before you draw anything, it'll ensure a consistent experience - you can't draw 0.11 of a pixel after all.

ippa commented 11 years ago

Fixed in https://github.com/ippa/jaws/commit/906101d806364f53af9e207ca6485a1504a2f8df , new builds on github and jawsjs.com .. just flooring the numbers in viewport.centerAround() for now.