Movie with UI elements

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
Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Movie with UI elements

#1 Post by Exiscoming » Tue Sep 10, 2019 12:42 pm

I've been struggling with this one for a while now. I know there's different ways to add a movie to Ren'py, but non of them do 'exactly' what I was hoping to do.
I'm hoping to do the following:

1. Play a random clip from a pool of choices.
2. When the clip ends, randomly pick another one from the pool.
3. Have a screen overlay that adds an imagebutton that allows you skip to the next clip.

So far I've done these two:

Code: Select all

            label jumpHere:
                $ randomClip = renpy.random.randint(1, 2)
                if randomClip == 1:
                    $ renpy.movie_cutscene("ani1.ogv")
                    jump jumpHere
                if randomClip == 2:
                    $ renpy.movie_cutscene("ani2.ogv")
                    jump jumpHere
Problem with that is that it hides your mouse and covers up any imagebuttons you might have. On top of that, if I manage to keep both of these, what will happen when when I use an imagebutton to go to the next clip? Will it cancel the current clip playing, or will both play at the same time?

Option 2:

Code: Select all

image ani1 movie = Movie(play="ani1.ogv")
image ani2 movie = Movie(play="ani2.ogv")
label jumpHere:
	$ randomClip = renpy.random.randint(1, 2)
	if randomClip == 1:
		show ani1 movie				# Show the clip here
		$ renpy.pause(3.0, hard='True')		# pause to let the animation play
		hide ani1 movie				# Hide the clip here
	if randomClip == 2:
		show ani2 movie
		$ renpy.pause(3.3, hard='True')		# pause to let the animation play
		hide ani2 movie
      	jump jumpHere
With this one I can add imagebuttons to it, but it immediately jumps to the next line of code, forcing me to put in a hard pause.
Which can be kind of awkward.

So as you can see, both of them have their drawbacks. Which of the two (or possibly another way) would you suggest I use and how do I fix my problems?

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: Movie with UI elements

#2 Post by hell_oh_world » Tue Sep 10, 2019 2:20 pm

Exiscoming wrote:
Tue Sep 10, 2019 12:42 pm
I've been struggling with this one for a while now. I know there's different ways to add a movie to Ren'py, but non of them do 'exactly' what I was hoping to do.
I'm hoping to do the following:

1. Play a random clip from a pool of choices.
2. When the clip ends, randomly pick another one from the pool.
3. Have a screen overlay that adds an imagebutton that allows you skip to the next clip.

So far I've done these two:

Code: Select all

            label jumpHere:
                $ randomClip = renpy.random.randint(1, 2)
                if randomClip == 1:
                    $ renpy.movie_cutscene("ani1.ogv")
                    jump jumpHere
                if randomClip == 2:
                    $ renpy.movie_cutscene("ani2.ogv")
                    jump jumpHere
Problem with that is that it hides your mouse and covers up any imagebuttons you might have. On top of that, if I manage to keep both of these, what will happen when when I use an imagebutton to go to the next clip? Will it cancel the current clip playing, or will both play at the same time?

Option 2:

Code: Select all

image ani1 movie = Movie(play="ani1.ogv")
image ani2 movie = Movie(play="ani2.ogv")
label jumpHere:
	$ randomClip = renpy.random.randint(1, 2)
	if randomClip == 1:
		show ani1 movie				# Show the clip here
		$ renpy.pause(3.0, hard='True')		# pause to let the animation play
		hide ani1 movie				# Hide the clip here
	if randomClip == 2:
		show ani2 movie
		$ renpy.pause(3.3, hard='True')		# pause to let the animation play
		hide ani2 movie
      	jump jumpHere
With this one I can add imagebuttons to it, but it immediately jumps to the next line of code, forcing me to put in a hard pause.
Which can be kind of awkward.

So as you can see, both of them have their drawbacks. Which of the two (or possibly another way) would you suggest I use and how do I fix my problems?
How about this?
Use screen to achieve what you're trying to do.

Code: Select all

screen random_videos:
	default video_list = [("ani1", 5.0), ("ani2", 3.0), ("ani3", 2.0)] ## This list is consist of tuples, the first part of the tuple is the name of the movie, excluding the file extension, the second part is the duration of the video.
	default video_to_play = renpy.random.choice(video_list)
	
	timer video_to_play[1] action SetScreenVariable("video_to_play", renpy.random.choice(video_list)) ## The timer that will automatically play something upon the end of the video.
	
	add Movie(play=video_to_play[0] + ".ogv", loop=False):
		align (0.5, 0.5)
		
	imagebutton:
		action SetScreenVariable("video_to_play",  renpy.random.choice(video_list))
		
label start:
	"Some dialogue..."
	show screen random_videos
	"Some dialogue..."
	hide screen random_videos
Also, you could also use your 2nd method. But instead of using the function renpy.pause() use an ordinary pause statement with no duration.

Code: Select all

image ani1 movie = Movie(play="ani1.ogv")
image ani2 movie = Movie(play="ani2.ogv")
label jumpHere:
	$ randomClip = renpy.random.randint(1, 2)
	if randomClip == 1:
		show ani1 movie				# Show the clip here
		pause	# pause to let the animation play
		hide ani1 movie				# Hide the clip here
	if randomClip == 2:
		show ani2 movie
		pause		# pause to let the animation play
		hide ani2 movie
      	jump jumpHere
Lemme know if both works.

Exiscoming
Regular
Posts: 127
Joined: Tue Apr 29, 2014 5:37 pm
Contact:

Re: Movie with UI elements

#3 Post by Exiscoming » Wed Sep 11, 2019 4:08 am

Thanks for the feedback! Unfortunately, it's still not working the way I'd like.
Basically the animation as several stages, each stage with a variation.

Stage 1:
-Variation 1
-Variation 2
-Variation 3
-Variation 4

Stage 2:
-Variation 1
-Variation 2
-Variation 3
-Variation 4

It should randomly cycle through the stage 1 animations until you press the "NEXT" imagebutton and it begins rotating through the stage 2 variations.
Preferably without having to pause it myself. My first method would be good for that, but it hides the UI. Is there a way to prevent this from happening?

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: Movie with UI elements

#4 Post by hell_oh_world » Wed Sep 11, 2019 6:06 am

Exiscoming wrote:
Wed Sep 11, 2019 4:08 am
Thanks for the feedback! Unfortunately, it's still not working the way I'd like.
Basically the animation as several stages, each stage with a variation.

Stage 1:
-Variation 1
-Variation 2
-Variation 3
-Variation 4

Stage 2:
-Variation 1
-Variation 2
-Variation 3
-Variation 4

It should randomly cycle through the stage 1 animations until you press the "NEXT" imagebutton and it begins rotating through the stage 2 variations.
Preferably without having to pause it myself. My first method would be good for that, but it hides the UI. Is there a way to prevent this from happening?
I don't know if you can manipulate the layers somehow so that it will be atop of other elements. Because it is stated in the documentation that:
renpy.movie_cutscene(filename, delay=None, loops=0, stop_music=True)
This displays a movie cutscene for the specified number of seconds. The user can click to interrupt the cutscene. Overlays and Underlays are disabled for the duration of the cutscene.
Anyways, does the code work? or not? because if it is working, especially my first suggestion, then you can easily modify those to create the variation that you want to achieve. Just adding some variables, etc. would probably get it to work, that of course if the initial code does work in the first place.

Post Reply

Who is online

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