Jump to content

[HELP]How to make a image spin


Recommended Posts

  • 2 months later...

you can use 

getTickCount() / 20 % 360)

example:

    dxDrawImage((***/***)*sWidth, (***/***)*sHeight, (***/***)*sWidth, (***/***)*sHeight, "Yourimg.png", getTickCount() / 20 % 360)

 

Edited by Guest
Link to comment
  • 2 weeks later...
On 24/07/2018 at 21:04, Scarfas said:

you can use 


getTickCount() / 20 % 360)

example:


    dxDrawImage((***/***)*sWidth, (***/***)*sHeight, (***/***)*sWidth, (***/***)*sHeight, "Yourimg.png", getTickCount() / 20 % 360)

 

I think that / 20 makes no diff

Link to comment

If anything, it's the modulo operator that's redundant here, as the rotation argument will take any number, not necessarily one that is truly between 0 and 360.

Regarding the division, it should make a difference -- diving the tick count will slow it down, in this case, the ticks will increment 20× slower, meaning a 20× slower rotation speed, from 1000 deg·s-1 to 50 deg·s-1 

Edited by MrTasty
  • Like 1
Link to comment

I think it makes no difference if you divide gettickcount for 20 or 1000 because % is going to reset the number every 360. getTickCount gets computer uptime isn't? its not going to make a diff because onClientRender doesn't trigger every ms. It triggers more like every 5 ms I think
 

(getTickCount() % 360) / 20

I think this may do what you said. But still it wouldn't make a 360 rotation like he said cuz the max rotation would be like 18deg


 

Link to comment

Let's assume tick count is 1000 this frame, and 1016.6666667 on the next frame (60 FPS). That is a 16.6666667 increase in tick count.

1000.0000000 ÷ 20 = 50.0000000
1016.6666667 ÷ 20 = 50.8333333

This is a 0.8333333 increase rather than a 16.6666667 increase, an increase 20 times lower, thus making the rotation per frame slower by 20.

Note that the modulo operation doesn't reset the tick count number but only the resulting number of the modulo operation.

On the other hand, if you did modulo first and division later, you wouldn't be able to get a degree higher than 360° / 20, that is, 18°, which isn't what was intended in this situation.

Edited by MrTasty
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...