newguy
newguy

Reputation: 5976

Should HTML5 canvas coordinates use floating point or integer?

Hi I am developing a game using HTML5 canvas. In the game I use a lot of the coordinate x and y, but sometimes they are floating point values. I am not sure if this has positive effects to the performance of the game and the accuracy of the sprites movement in the game. Is it correct to use floating point values of x and y or do I need to convert them into integers?

Upvotes: 3

Views: 1028

Answers (2)

Aleksey Dubinskiy
Aleksey Dubinskiy

Reputation: 184

newguy!

If you need use float values, you can use it, sometimes it's necessary.

1) Make a game;

2) If this game has low performance, try to optimize.

Upvotes: 0

martin
martin

Reputation: 96949

I doubt it has any performance benefits or drawbacks.

However, you might encounter blurred shapes when using just integer values but it depends on what you're trying to do. See similar question: Canvas drawings, like lines, are blurry.

Upvotes: 1

Related Questions