Discuss Scratch

MPWreal
Scratcher
3 posts

Pen Flashlight..... Maybe?

Now, this may not make sense. I'm making a 2D top-down horror game and I need a flashlight. Simple, right? Well, it's not. I'm trying to create a cone of light that emits from the player and follows the mouse. I want the light to start small but slowly get bigger as it is farther away from the origin sprite as if in a cone-ish shape. How would I do this? I'm thinking I could have a simple Pen script that goes from one point to another gradually getting bigger until it reaches its final point. Like this.
whenclickedpendownforeverpointtowardsendpointwhenclickedrepeatuntiltouchingendpoint?move1stepschangepensizeby1
deck26
Scratcher
1000+ posts

Pen Flashlight..... Maybe?

Other projects have done this. This was something vaguely similar that I did https://scratch.mit.edu/projects/61593394/ - obviously you'd have to change the shape of the light being shone but it should be adaptable to suit your needs.
MPWreal
Scratcher
3 posts

Pen Flashlight..... Maybe?

The problem with this is that I need something that can continuously change its shape to always be originating from its first point. I could change the shape, yes, but then it would just be a triangle gap that doesn't start at the player. Make sense?
deck26
Scratcher
1000+ posts

Pen Flashlight..... Maybe?

If you mean the light stops when it hits something then, yes, the shape keeps changing and you need to look at raycasting projects. Otherwise the shape doesn't change, it just rotates according to where the flashlight is being shone.

You can also make sure any obstacles are in front of the flashlight sprite so the light does appear to be stopped by them.
MPWreal
Scratcher
3 posts

Pen Flashlight..... Maybe?

Thanks, that's what I thought might have to be. I'll still figure out how to do the pen way sooner or later, but for now, I think I'm satisfied.
StratfordJames
Scratcher
100+ posts

Pen Flashlight..... Maybe?

hi
gggoldgamer_returned
Scratcher
2 posts

Pen Flashlight..... Maybe?

then you make it follow the character like this a great example is my game im creating and here is the code in motion https://scratch.mit.edu/projects/762871505/
whenclickedforevergotoend

Last edited by gggoldgamer_returned (Nov. 29, 2022 01:48:38)

TheWeeklyReader
Scratcher
100+ posts

Pen Flashlight..... Maybe?

Are you not able to just make the flashlight part of the player costume?
kk445376
Scratcher
3 posts

Pen Flashlight..... Maybe?

wdym what. do you mean

Powered by DjangoBB