example script for bpm tempo in ren’py

init -1 python:
 
 the_bpm = 130 # change the number to your musics bpm
 one_beat = 60 / float(the_bpm)
 
 two_beat = one_beat * 2
 three_beat = one_beat * 3
 
 one_eighth = one_beat / 2
 one_sixteenth = one_beat / 4
 
 one_bar = one_beat * 4
 two_bar = one_bar * 2
 four_bar = one_bar * 4
 eight_bar = one_bar * 8

## The script of the game goes in this file.

image bpm-ani:
 "bpm ex fr1.png" with Dissolve(one_beat, alpha=True)
 pause two_beat
 "bpm ex fr2.png" with Dissolve(one_beat, alpha=True)
 pause two_beat
 "bpm ex fr3.png" with Dissolve(one_beat, alpha=True)
 pause two_beat
 "bpm ex fr4.png" with Dissolve(one_beat, alpha=True)
 pause two_beat
 repeat
 
image bpm-ani-fast:
 "bpm ex fr1.png" with Dissolve(one_eighth, alpha=True)
 pause one_eighth
 "bpm ex fr2.png" with Dissolve(one_eighth, alpha=True)
 pause one_eighth
 "bpm ex fr3.png" with Dissolve(one_eighth, alpha=True)
 pause one_eighth
 "bpm ex fr4.png" with Dissolve(one_eighth, alpha=True)
 pause one_eighth
 repeat 

define n = Character('')

## The game starts here.

label start:
 
 n "Sorry..."
 
 play music "audio/persecution-3.ogg"
 show bpm-ani
 pause eight_bar
 hide bpm-ani
 stop music 

 n "My eyes always do this when I'm near loud music."
 
 play music "audio/persecution-3.ogg"

 show bpm-ani-fast

 n "I would stop it if I could!"
 
 return