Flashlight effect?
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.
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.
- GlassHeart
- Regular
- Posts: 105
- Joined: Fri Mar 11, 2011 12:13 pm
- Completed: Hand in hand with destiny, Out of Sight, Summer Found Me (Again), Signed X, Trapped
- itch: https://selavi.itch.
- Location: Romania
- Contact:
Flashlight effect?
This is what I want :
Basically you have a black background and you use the cursor as a flashlight. The area around the cursor's location will be "lit up" revealing an image. Any ideas if this is even possible?
Basically you have a black background and you use the cursor as a flashlight. The area around the cursor's location will be "lit up" revealing an image. Any ideas if this is even possible?
- kkffoo
- Regular
- Posts: 133
- Joined: Wed Sep 22, 2010 3:17 am
- Completed: Tea For Two [KN]
- Location: UK
- Contact:
Re: Flashlight effect?
Have a black layer on top larger than bottom layer, cut feathered hole, move black layer around?
Tea for Two - Kinetic Novel - Free http://lemmasoft.renai.us/forums/viewto ... 11&t=17528
- GlassHeart
- Regular
- Posts: 105
- Joined: Fri Mar 11, 2011 12:13 pm
- Completed: Hand in hand with destiny, Out of Sight, Summer Found Me (Again), Signed X, Trapped
- itch: https://selavi.itch.
- Location: Romania
- Contact:
Re: Flashlight effect?
That's not a bad idea... I have no idea how I would move it around to follow the cursor, but it's a place to start. Thank you!
-
- Eileen-Class Veteran
- Posts: 1261
- Joined: Fri Mar 16, 2012 11:38 am
- Projects: Rika
- Organization: Solo (for now)
- IRC Nick: Trick
- Location: Tokyo, Japan
- Contact:
Re: Flashlight effect?
Well, it is possible to change the mouse pointer to another image, but it has some problems.
Either it will only change for a very short period, then revert back to the original mouse pointer, or it will stay on your custom pointer permanently. I presume neither of those would be suitable for what you need.
As for getting an image to follow the mouse pointer, I'm fairly sure it's impossible.
Either it will only change for a very short period, then revert back to the original mouse pointer, or it will stay on your custom pointer permanently. I presume neither of those would be suitable for what you need.
As for getting an image to follow the mouse pointer, I'm fairly sure it's impossible.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Flashlight effect?
You can get an image to follow the mouse cursor, but you need a CDD to do it. You'd also want to use the AlphaBlend displayable to do the flashlight effect - there's an example of it in the tutorial.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
-
- Eileen-Class Veteran
- Posts: 1261
- Joined: Fri Mar 16, 2012 11:38 am
- Projects: Rika
- Organization: Solo (for now)
- IRC Nick: Trick
- Location: Tokyo, Japan
- Contact:
Re: Flashlight effect?
CDD is really complicated for non-programmers.
I messed around with the code for a snowblossom demo that was somewhere in the wiki (sorry, couldn't find it again to link).
There was some code for a repulsor, so I messed around with that, and eventually managed to get an image to follow the mouse cursor.
Anyway, if you still need it, here is the code. As I said, I just modified code from the wiki, so there are probably much better ways to do it. Also, it could look a bit weird if the player goes fullscreen.
script.rpy:
whateveryouwanttocallit.rpy:
This is set up for a window size of 800x600. It's fairly easy to adjust for other sizes.
There are 2 extra files I used: http://i49.tinypic.com/309585j.png and http://i47.tinypic.com/2h5pld5.jpg
That's it. Perhaps it will be of use to you or someone else, or perhaps someone will be able to make improvements to it.
I messed around with the code for a snowblossom demo that was somewhere in the wiki (sorry, couldn't find it again to link).
There was some code for a repulsor, so I messed around with that, and eventually managed to get an image to follow the mouse cursor.
Anyway, if you still need it, here is the code. As I said, I just modified code from the wiki, so there are probably much better ways to do it. Also, it could look a bit weird if the player goes fullscreen.
script.rpy:
Code: Select all
image bg creepyroom = "Background.jpg"
label start:
scene black
"Where is that light switch...?"
scene bg creepyroom
call repulsor_demo
"That was really creepy! I'm glad it's over!"
return
Code: Select all
init python:
import math
def repulsor_update(st):
# If we don't know where the mouse is, give up.
if repulsor_pos is None:
return .01
px, py = repulsor_pos
# For each sprite...
for i in repulsor_sprites:
distance = 0.5 # Shouldn't really matter, as the image will jump to the mousepointer.
i.x = px - (config.screen_width * 1.25) # Half the size of the "flashlight" image
i.y = py - (config.screen_height * 1.25) # Half the size of the "flashlight" image
# The flashlight image is basically 2.5 times the width and height of the game window. (800x600)
#It could look a bit odd if the player switches to fullscreen.
return .01
# On an event, record the mouse position.
def repulsor_event(ev, x, y, st):
store.repulsor_pos = (x, y)
label repulsor_demo:
python:
# Create a sprite manager.
repulsor = SpriteManager(update=repulsor_update, event=repulsor_event)
repulsor_sprites = [ ]
repulsor_pos = None
# Ensure we only have one image displayable.
smile = Image("Flashlight2.png") #Flashlight
# Add a number of sprites. Left this in, as there may be uses to have more than one sprite. And I'm lazy.
for i in range(1):
repulsor_sprites.append(repulsor.create(smile))
# Position the sprites.
for i in repulsor_sprites:
i.x = renpy.random.randint(2, 798)
i.y = renpy.random.randint(2, 598)
del smile
del i
# Add the repulsor to the screen.
show expression repulsor as repulsor
" " #To wait for a mouse click.
hide repulsor
# Clean up.
python:
del repulsor
del repulsor_sprites
del repulsor_pos
return
There are 2 extra files I used: http://i49.tinypic.com/309585j.png and http://i47.tinypic.com/2h5pld5.jpg
That's it. Perhaps it will be of use to you or someone else, or perhaps someone will be able to make improvements to it.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
- GlassHeart
- Regular
- Posts: 105
- Joined: Fri Mar 11, 2011 12:13 pm
- Completed: Hand in hand with destiny, Out of Sight, Summer Found Me (Again), Signed X, Trapped
- itch: https://selavi.itch.
- Location: Romania
- Contact:
Re: Flashlight effect?
TrickWithAKnife, that was perfect. I've coupled it with a $ mouse_visible = False and it looks even better. Thank you soooo much!
Re: Flashlight effect?
That's pretty much wonderful.TrickWithAKnife wrote:That's it. Perhaps it will be of use to you or someone else, or perhaps someone will be able to make improvements to it.Code: Select all
init python: import math def repulsor_update(st): # If we don't know where the mouse is, give up. if repulsor_pos is None: return .01 px, py = repulsor_pos # On an event, record the mouse position. def repulsor_event(ev, x, y, st): store.repulsor_pos = (x, y)
If i'm not mistaken, with changes in the code above this could be combined with mousearea, so when the "light" hovers over something, a certain action ensues?
It would be a real light in the darkness for horror visual novels... maybe.
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.
-
- Veteran
- Posts: 347
- Joined: Sat Sep 08, 2012 4:16 am
- Projects: DreamWalker; History; Adversity Competition
- Contact:
Re: Flashlight effect?
or those CSI style glow-in-the dark luminol things.Levrex wrote:That's pretty much wonderful.TrickWithAKnife wrote:That's it. Perhaps it will be of use to you or someone else, or perhaps someone will be able to make improvements to it.Code: Select all
init python: import math def repulsor_update(st): # If we don't know where the mouse is, give up. if repulsor_pos is None: return .01 px, py = repulsor_pos # On an event, record the mouse position. def repulsor_event(ev, x, y, st): store.repulsor_pos = (x, y)
If i'm not mistaken, with changes in the code above this could be combined with mousearea, so when the "light" hovers over something, a certain action ensues?
It would be a real light in the darkness for horror visual novels... maybe.
-
- Eileen-Class Veteran
- Posts: 1261
- Joined: Fri Mar 16, 2012 11:38 am
- Projects: Rika
- Organization: Solo (for now)
- IRC Nick: Trick
- Location: Tokyo, Japan
- Contact:
Re: Flashlight effect?
Ahh, I didn't think of that, but it's very useful for something I'm working on. Thanks.GlassHeart wrote:TrickWithAKnife, that was perfect. I've coupled it with a $ mouse_visible = False and it looks even better. Thank you soooo much!
I'd love to have something like that. Right now I'm trying to figure out how to get the image that is following the mouse to stay on screen when using imagemaps.Levrex wrote:If i'm not mistaken, with changes in the code above this could be combined with mousearea, so when the "light" hovers over something, a certain action ensues?
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
- Arowana
- Miko-Class Veteran
- Posts: 531
- Joined: Thu May 31, 2012 11:17 pm
- Completed: a2 ~a due~
- Projects: AXIOM.01, The Pirate Mermaid
- Organization: Variable X, Navigame
- Tumblr: navigame-media
- itch: navigame
- Contact:
Re: Flashlight effect?
What a cool idea! Thanks so much for the code, TrickWithAKnife! I'm definitely bookmarking it for future use. xD
Complete: a2 ~a due~ (music, language, love)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
In progress: The Pirate Mermaid (fairytale otome)
On hold: AXIOM.01 (girl detective game)
-
- Eileen-Class Veteran
- Posts: 1261
- Joined: Fri Mar 16, 2012 11:38 am
- Projects: Rika
- Organization: Solo (for now)
- IRC Nick: Trick
- Location: Tokyo, Japan
- Contact:
Re: Flashlight effect?
Everyone is being very kind, but this code is far from complete.
I'm having trouble with other interactions while the image that follows the mouse cursor is being shown.
I hope if someone someone else figures out how to improve this code, they will share with the rest of us, or perhaps make a simply explained cookbook guide.
I'm having trouble with other interactions while the image that follows the mouse cursor is being shown.
I hope if someone someone else figures out how to improve this code, they will share with the rest of us, or perhaps make a simply explained cookbook guide.
"We must teach them through the tools with which they are comfortable."
The #renpy IRC channel is a great place to chat with other devs. Due to the nature of IRC and timezone differences, people probably won't reply right away.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
If you'd like to view or use any code from my VN PM me. All code is freely available without restriction, but also without warranty or (much) support.
Re: Flashlight effect?
Answering my own question about "something" and "certain action"...
Well, while trying to implement "hovered" and "unhovered" into the function itself, i quickly realised that it's a lot easier to stop trying to reinvent the wheel and add mousearea screen in the label directly, like you would do normally.
Example screen:
Well, while trying to implement "hovered" and "unhovered" into the function itself, i quickly realised that it's a lot easier to stop trying to reinvent the wheel and add mousearea screen in the label directly, like you would do normally.
Example screen:
Code: Select all
screen mouser:
mousearea:
area (0, 0, 50, 50)
hovered Jump("boom")
If your question is solved, please add [Solved] to theme's name by editing its first post, so that the helpful guys out there wouldn't mistakenly think the problem is still unanswered and waste their time.
Re: Flashlight effect?
This is very cool, but what could be causing the CTC and quick menu to show in the screen while I move the flashlight. Is there a way to hide them while the user moves the flashlight around?
FREE and easy 3D customization, posing, and animation software with pre-made people and environments:
DAZ Studio Pro 4.9
Re: Flashlight effect?
Try to add this lineto hide textbox with ctc-indicator and quick menu - later you could show it up again by this line
Code: Select all
window hide
Code: Select all
window show
Who is online
Users browsing this forum: Semrush [Bot]