Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a range (or limit rather)
- 2Flashbacks
-
Scratcher
80 posts
How to make a range (or limit rather)
So I'm making a game based off of griffpatch's 3d game tutorial (however I'm keeping mine 2d), which will be called “in the dark.” Right now I want to make a flashlight that will have different “power levels” (How far it goes, and how wide it is.) Right now I have a system that makes it stay within the flashlight, but whenever I go over a “strength/FOV” of 60 it goes outside of the flashlight, more noticeable at 90 “FOV” and past.
Heres my current blocks:
Heres my current blocks:
define RaycastThe move part at the start makes it so that it comes out of the flashlight end part of the sprite, however, as I said, it doesnt really work past 70 “FOV,” so I'm just wondering, should I just give up and use an
go to [Player v]
move ((FOV) / (4)) steps
set [x v] to (x position)
set [y v] to (y position)
turn ccw ((FOV) / (2)) degrees
repeat (FOV)
Single Ray (8)
turn cw (1) degrees
end
define Single Ray (Speed)
go to x: (x) y: (y)
pen down
repeat until <touching [level v] ?>
move (Speed) steps
end
repeat until <not <touching [ v] ?>>
move (-0.5) steps
end
pen up
if <> thenblock or if theres a mathematical equation that stops it above a certain distance, without looping back to 0 like mod?
else
end
Last edited by 2Flashbacks (March 8, 2022 19:26:34)
- 2Flashbacks
-
Scratcher
80 posts
How to make a range (or limit rather)
Some images for reference:



Also my raycaster sprite's hitbox is 8x8 in size so thats why I have it move by 8



Also my raycaster sprite's hitbox is 8x8 in size so thats why I have it move by 8
Last edited by 2Flashbacks (March 8, 2022 19:33:54)
- Discussion Forums
- » Help with Scripts
-
» How to make a range (or limit rather)
