John_90 wrote:

Or do you have any other method to achieve it? To make the sprite to move forward smoothly? I really need help for this function to be working. Thank you.

Well, if you dare to leave the kindergarten of "sprites", the reminiscent of 1970x, the HTML5

`Canvas`

feature will allow you to play with much richer graphics models in absolutely smooth way.

It will take considerable effort, but what you can do is quite impressive:

http://net.tutsplus.com/articles/web-roundups/21-ridiculously-impressive-html5-canvas-experiments/[

^].

You can find several engines already designed, in particular, for creation of vector graphics, which can also be interactive:

Raphaël:

http://raphaeljs.com/[

^],

CAKE:

http://code.google.com/p/cakejs/[

^],

Paper.js, a vector-graphics scripting network:

http://paperjs.org/[

^],

Burst Engine:

https://github.com/rwaldron/burst-core[

^].

See also this Mozilla tutorial:

https://developer.mozilla.org/en-US/docs/Web/Guide/Graphics/Drawing_graphics_with_canvas?redirectlocale=en-US&redirectslug=HTML%2FCanvas%2FDrawing_Graphics_with_Canvas[

^].

—SA
—SA

How is it related to atan2?

—SA

I still see no problem with atan2, which is a really trivial thing, as soon as you already know this "trick" of using it...

—SA

—SA

—SA

—SA

Simple example with those angles:

In traditional school, children first learn trigonometry, which algebra (sin, cos, atan, and so on...) is pretty tricky to in calculations. Only later, they introduce complex numbers. Conceptually, many have problems understanding them. However, all trigonometry can be rewritten in complex numbers, and all trigonometric functions can be excluded, replaced with exponents/powers/logarithms. It greatly simplifies calculations and make them more regular, less heuristic.

—SA