I'm just trying to pull off a simple rotation. I think the problem originates with the unchanging rotation variable...

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
DraymondDarksteel
Newbie
Posts: 13
Joined: Mon Sep 05, 2016 1:51 pm
Contact:

I'm just trying to pull off a simple rotation. I think the problem originates with the unchanging rotation variable...

#1 Post by DraymondDarksteel »

It really seems like it should be easier to pull off than this, doesn't it? In any case, I'm having... immense difficulty figuring out how to rotate something.

This is the relevant code, in my screens.rpy.

Code: Select all

transform rotateshort:
    rotate (284 - minutes) / 284 * 360

transform alpha_dissolve:
    xpos 0.85
    ypos 0.2
    xanchor 0.5
    yanchor 0.5
    alpha 0.0
    linear 0.5 alpha 1.0
    on hide:
        linear 0.5 alpha 0
    ##This is to fade in the clock.

screen ticktock:
    add "clockback.png" at alpha_dissolve
    add "clockhand.png" at alpha_dissolve, rotateshort 
The relevant variable, is declared in variable.rpy, in the following format...

Code: Select all

init:
    $ minutes = 284
And, finally, the value of minutes is modified elsewhere, in a custom file, 01functions.rpy, where it says...

Code: Select all

label addtime(amount):
    show screen ticktock
    play sound "sounds/ticktock.wav"
    pause(2)
    $ minutes -= amount * 20
    halt ""
    hide screen ticktock
    return
I created this as a custom function, because I'm expecting to use it multiple times. The rest of the function is called, and executes, correctly, so I don't know what the malfunction is here. The clock simply isn't rotated at all, and, for some reason, it appears on the left hand side of the screen instead of the right hand the first time the ticktock screen is run. But only the first time. Of note, however, is that the image will rotate if I replace "(284 - minutes) / 284 * 360" with an actual number. So the problem must be in minutes... somehow. I've confirmed elsewhere that the minutes variable does actually decrease when that addtime function is called, so I really can't understand what I'm doing wrong. Still, if you can, please help. I've been going insane trying to figure this out all day.

philat
Eileen-Class Veteran
Posts: 1926
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: I'm just trying to pull off a simple rotation. I think the problem originates with the unchanging rotation variable.

#2 Post by philat »

Make minutes a parameter in the transform.

User avatar
Randomiser
Newbie
Posts: 7
Joined: Fri Sep 28, 2018 2:07 pm
Contact:

Re: I'm just trying to pull off a simple rotation. I think the problem originates with the unchanging rotation variable.

#3 Post by Randomiser »

I think there's a sneaky math error going on.

Code: Select all

(284 - minutes) / 284 * 360
(284 - minutes) / 284 is guaranteed to be less than 1. However, because 284 and minutes are both integers, python rounds this down to 0! You can write either 284 or minutes as a float to force it to retain accuracy.

Code: Select all

rotate (284 - minutes) / 284.0 * 360
will return a float instead of 0.

DraymondDarksteel
Newbie
Posts: 13
Joined: Mon Sep 05, 2016 1:51 pm
Contact:

Re: I'm just trying to pull off a simple rotation. I think the problem originates with the unchanging rotation variable.

#4 Post by DraymondDarksteel »

Randomiser wrote: Sun Sep 30, 2018 1:42 amI think there's a sneaky math error going on.
Yes, that was it! There was an additional problem in that the screen wasn't updating, but I've solved that too. Thank you very much!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]