[SOLVED]question about rotate transform

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

[SOLVED]question about rotate transform

#1 Post by nananame » Sun May 24, 2020 7:42 am

I'm playing around with rotate and have a problem I can't wrap my head around.

This is the transform:

Code: Select all

transform turnit:#rotates image
    linear 1 rotate a+36##rotate through 1 second
The image is shown first time like so:

Code: Select all

show image:
    rotate a #a is default a = 0
This is the part which modifies a and b and shows the rotation:

Code: Select all

show image at turnit
$a+=36
Simple. The image is shown at the last position (rotate a), whenever the button is pressed it runs the transform (turning it by 36) and setting a to a+36. Work great.
the problem is if I start at somewhere other than 0. For example a=180. The image is shown correctly but when I turn it it jumps strangely for the first turn and then continues normally.

This is when starting from 0 - it works quite nicely. I end it at 180 (so number 5 is on top)
Image

This is when starting from 180. Notice how it "jumps" then continues normally. Please be aware the calculations remains as it should. So if I click to rotate once the image will jump and appear to be at number 9 on top. But it will actually be at 216 degrees (a) and once I come back show 6 on top as meant to be.
Image


So the problem is the first rotation if starting from other than 0. I tried inserting "rotate a" as starting position to the transform as well but it didn't work. Can anyone pplease enlighten me as I am losing my mind here :)
Last edited by nananame on Wed May 27, 2020 10:22 am, edited 1 time in total.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: question about rotate transform

#2 Post by hell_oh_world » Sun May 24, 2020 7:59 am

Not really helpful, but if you want to make the rotation appear smoother and not jagged, enable `subpixel`

Code: Select all

transform turnit:#rotates image
    subpixel True
    linear 1 rotate a+36##rotate through 1 second

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: question about rotate transform

#3 Post by MaydohMaydoh » Sun May 24, 2020 10:22 am

Can't seem to reproduce this problem, but the only thing I can think of trying is increasing a before running the transform:

Code: Select all

transform turnit:
    linear 1 rotate a
    
$ a += 36
show image at turnit
Whether that would work or not, I have no idea.

User avatar
gas
Miko-Class Veteran
Posts: 838
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: question about rotate transform

#4 Post by gas » Sun May 24, 2020 11:21 am

In fact even the first picture jump... it jump of 0 degrees :).

How the code is done is that you linked the rotation to a global variable.
You show the image unchanged, then rotated by the delta of previous a, then again linearly by the final amount.

I suggest you to avoid globals. Use local variables instead.

Code: Select all

transform turnit(deg):
    linear 1 rotate deg

show pin at turnit(35)
That 'should' do the trick. Set the amount of degrees to rotate. If you want to keep the value (like, for example, a score or a datetime) use another variable.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

[SOLVED]Re: question about rotate transform

#5 Post by nananame » Wed May 27, 2020 10:22 am

Thank you everyone for your attempts. None of these worked :(
However, I figured out it's the fact that the transform rotation always believes to be at 0 when starting, and if I push him something else to start from it will rotate the image again (when it is already rotated!). I might have a hard time explaining it but in the end I simply had to find how much I rotated the images previously and then take that into ccount when doing the new rotation. Math to the rescue!

Post Reply

Who is online

Users browsing this forum: Google [Bot], TioNick