My goal is a 2D platform game with additional possibility to draw things on a screen (like with a pencil or a brush in Photoshop). I did everything what is connected with platform game mechanic, I did effect of drawing on a game screen.
When I move pressed mouse with medium or slow speed everything is OK and there is quite smooth line. But there is quite difficult problem when I want to draw something faster. If I try to draw a line faster, application will "catch" only few points of a line. Example:
In my opinion there are 3 possible ways to repair it:
- filling free spaces between dots with ultra-advanced algorithm
- slowing down mouse
- improving application speed
ad1. This is the way I will probably try to do it , but I think it will be quite difficult to invent nice way to make it look smooth and natural. If you have any idea, please help me
Maybe use of y=ax+b and filling every point between these 2 following points?
ad2. This is the way I TRIED to do it. I was setting Mouse Position with setPosition just near last mouse position. It was working but: slowing down mouse is not the best way in my opinion to repair it. I was using y=ax+b to calculate the most accurate position, but of course it wasn't accurate because of sf::Vector2i. It was impossible to make that line connected in 100% with a mouse movement.
ad3. I'm not sure if it was possible. It depends on speed of user's computer so I think it is not the best way.
This is not a problem of bad algorithm of drawing. I was "cout"-ing mouse position in an application with almost nothing and it's just to fast for application to catch every single (x,y) position.
Ok. So I wanted to ask if you have any idea to do it.