Eyes following the mouse cursor in the main menu.

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
Diruker
Newbie
Posts: 2
Joined: Mon Dec 25, 2023 11:44 am
Contact:

Eyes following the mouse cursor in the main menu.

#1 Post by Diruker »

Okay I've been thinking, my game is kinda a psychological horror game and I wanted to remake the main menu because its a little.. bland. I have came up with an idea to make it a big image of the main antagonist with eyes following the cursor after an important thing has happened. The problem is.. I don't know how to make the eyes follow the mouse, and I can't find anything that useful on the internet, so I'm asking for help all of you. Any help is appreciated! :D

User avatar
m_from_space
Miko-Class Veteran
Posts: 978
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Eyes following the mouse cursor in the main menu.

#2 Post by m_from_space »

Diruker wrote: Thu Dec 28, 2023 9:44 pm Any help is appreciated! :D
1. Create a screen that is also shown within the main_menu screen you will find in <screens.rpy> (or put all your code into the main menu)
2. Within that screen call renpy.get_mouse_pos() using a repeating timer of let's say 0.1 secs, which gets you the mouse coordinates
3. Calculate the vector from the position of the eyes to the mouse pos (it's actually just the difference of the x and y coordinates I think)
4. Calculate the angle of that vector and save the angle in a persistent variable
5. Use that persistent variable to define the rotation of the eyes

I hope that makes sense.

Diruker
Newbie
Posts: 2
Joined: Mon Dec 25, 2023 11:44 am
Contact:

Re: Eyes following the mouse cursor in the main menu.

#3 Post by Diruker »

m_from_space wrote: Fri Dec 29, 2023 9:44 am
Diruker wrote: Thu Dec 28, 2023 9:44 pm Any help is appreciated! :D
1. Create a screen that is also shown within the main_menu screen you will find in <screens.rpy> (or put all your code into the main menu)
2. Within that screen call renpy.get_mouse_pos() using a repeating timer of let's say 0.1 secs, which gets you the mouse coordinates
3. Calculate the vector from the position of the eyes to the mouse pos (it's actually just the difference of the x and y coordinates I think)
4. Calculate the angle of that vector and save the angle in a persistent variable
5. Use that persistent variable to define the rotation of the eyes

I hope that makes sense.
I will try to do that using this information, thanks!

Post Reply

Who is online

Users browsing this forum: Google [Bot]