Hotline miami sprite rotation.

Can someone give me a script for sprite rotations like in hotline Miami? In hotline Miami the sprite rotates smoothly, here's a video for the effect I wanna achieve.


You see how the heads rotate? that's the effect I wanna achieve
 
Last edited:

obscene

Member
You don't need a script to rotate something.

Increase the image_angle to make it rotate counterclockwise.
Decrease it to go the other way.
 

rIKmAN

Member
Store a min / max rotation in some variables and rotate between the two values, swapping the rotation direction when the min / max rotation is hit.
 

rIKmAN

Member
I don't know what values you want to rotate between, so I can't give you code - and if I did how would you learn? :)

@Nux gave you a big hint above, use image_angle.

Draw a sprite to the screen and draw the "image_angle" (or output to console) - then add/subract 1 from the image_angle every time you press a key (left/right arrow for example).

When you have the 2 values for the left and right rotation that you think look good, note them down.
Then in your code, set these as 2 variables minRot / maxRot, and another variable to store the current rotation direction.

In the step event of the talking head object you can then add/subtract from the image_angle until it = minRot or maxRot (depending which way it's rotating), and when it hits the min/max value reverse the direction of the rotation by switching up the value you add to image angle (+1 or -1) so it will rotate the other way.
 
I don't know what values you want to rotate between, so I can't give you code - and if I did how would you learn? :)

@Nux gave you a big hint above, use image_angle.

Draw a sprite to the screen and draw the "image_angle" (or output to console) - then add/subract 1 from the image_angle every time you press a key (left/right arrow for example).

When you have the 2 values for the left and right rotation that you think look good, note them down.
Then in your code, set these as 2 variables minRot / maxRot, and another variable to store the current rotation direction.

In the step event of the talking head object you can then add/subtract from the image_angle until it = minRot or maxRot (depending which way it's rotating), and when it hits the min/max value reverse the direction of the rotation by switching up the value you add to image angle (+1 or -1) so it will rotate the other way.
THANK YOU!! :D
 
No worries, if you get in a muddle trying to get your code working come back and post it and I'm sure you'll get help.
It's always good to try and attempt it yourself first though as that's the best way to learn! :)
Lol. ran into a problem m8
Code:
image_angle -= 1
repeat (1000)
{
    if (image_angle = minR)
    {
        image_angle += 1
    }
    if (image_angle = maxR)
    {
        image_angle -= 1
    }
}
minR = -40
maxR = 40

Hehe..
Problem.

The bricks don't rotate the other way instead then stop for a few seconds and then goes the same way. :( HALP (I just noticed I spelled rotating wrong *facepalm*)
 
Last edited:

rIKmAN

Member
Lol. ran into a problem m8
Well that didn't take long, you didn't try very hard ;)
Although you are on the right lines.

In your code the "if" checks are only true if the image_angle is EXACTLY equal to minR or maxR, so whenever it isn't equal the code inside will not be run - that's not what you want. Also the logic is wrong.

Here is a quick project I knocked up for you to look at, hopefully you can see how it works and in conjuction with the manual entry I linked you to you can apply it to your talking heads. :)

edit: Or bricks, whatever it is you are rotating lol.
 

KurtBlissZ

Member
You notice using repeat like isn't going to do much. ;p That's only gona work when image_angle is = to -40 or 40.
Know if you where to use your own image_angle speed variable then apply it to image_angle each step that would make more sense, and if ya take out the repeat function.
 
LOL
Well that didn't take long, you didn't try very hard ;)
Although you are on the right lines.

In your code the "if" checks are only true if the image_angle is EXACTLY equal to minR or maxR, so whenever it isn't equal the code inside will not be run - that's not what you want. Also the logic is wrong.

Here is a quick project I knocked up for you to look at, hopefully you can see how it works and in conjuction with the manual entry I linked you to you can apply it to your talking heads. :)

edit: Or bricks, whatever it is you are rotating lol.
Lol thanks XD It's working :) Thank you :)
 
Top