
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?
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
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)
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.
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?
Code: Select all
screen mouser:
mousearea:
area (0, 0, 50, 50)
hovered Jump("boom")
Code: Select all
window hide
Code: Select all
window show
Users browsing this forum: No registered users