Discuss Scratch

GrayDevScratch
Scratcher
16 posts

Off-Screen Collisions

I'm making a 2d top down scrolling shooter game, but the enemies just phase through walls when off-screen. I tried zooming out, detecting collisions, and then zooming back in but it was both too laggy and just didn't work as intended. Any help?

Also, the map is one sprite, not multiple different ones.

Last edited by GrayDevScratch (March 26, 2024 16:48:54)


Dash: https://scratch.mit.edu/projects/947055709/

If you ever feel stupid, remember that I exist.
ramenecho
Scratcher
100+ posts

Off-Screen Collisions

Ok, if you are using color detection it will just not detect, but im pretty sure the <touching sprite > block still works offscreen, you could use that if possible

Hello there, this is a cool signature! You can even make your own wow! I really need somebody to check my game for bugs, MineQuest Idle its not the highest quality of games, but its an improvement from my previous ones
Malicondi
Scratcher
1000+ posts

Off-Screen Collisions

ramenecho wrote:

Ok, if you are using color detection it will just not detect, but im pretty sure the <touching sprite > block still works offscreen, you could use that if possible
<touching> sensing blocks don't work offscreen. The only way to accurately detect offscreen collision is to use math, and depending on your game the math needed to do so would be different.

post #1000 post #100 i help in the forums post #1 post #500 0 second ninja
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.

coming soon :)


GrayDevScratch
Scratcher
16 posts

Off-Screen Collisions

ramenecho wrote:

Ok, if you are using color detection it will just not detect, but im pretty sure the <touching sprite > block still works offscreen, you could use that if possible

I am using the <touching> sensing block, and It doesn't work off screen at least when I've tried it, but thanks for trying to help! (:

Dash: https://scratch.mit.edu/projects/947055709/

If you ever feel stupid, remember that I exist.
GrayDevScratch
Scratcher
16 posts

Off-Screen Collisions

If anyone has any ideas if they don't even know if they will work please still share them with me, cause my creativity has gone down the drain

Dash: https://scratch.mit.edu/projects/947055709/

If you ever feel stupid, remember that I exist.
-Qlec-
Scratcher
100+ posts

Off-Screen Collisions

Edit: See post below

A more practical solution is splitting up your sprite into tiles and dynamically rendering them based on the camera x and y positions.

Last edited by -Qlec- (March 26, 2024 18:34:44)


scratch fact of the day whenever i feel like changing it: Oddly enough, the (item ( ) of list) and (item # of ( ) in list) blocks can be placed where boolean blocks are supposed to go. This calls on the Boolean() function in JavaScript (the language Scratch is coded in), or whatever other boolean coercion method exists. Numbers and booleans behave as expected, with 0 (but, incorrectly, not -0), “” (empty string), and “false” (the string) converting to false. Everything else converts to true, so stuff like NaN seem to be interpreted as strings.
set [foo v] to [something]
forever {
set [foo v] to (join (foo)(foo))
} :: control
Select this, then press Shift + Down











// just your typical code
green is {
an ({apple :: hat #8fd97e}@addInput::ring #55993a) :: #7bc24f cap
}some text<>{
if not (☁ score :: pen) {
{rainbow [#de0909][#ffaa0d][#ffe70a][#7ccf00][#00cf79][#0072cf][#8d00cf] :: #7bc24f reporter}@addInput :: hat pen
}:: #6a8c32
} block [with v] ([text] :: #a8cc5a) ? :: #6a8c32
Malicondi
Scratcher
1000+ posts

Off-Screen Collisions

-Qlec- wrote:

And you'd have to do this for each of your enemies and every sprite that goes off-screen, every time. This does not work infinitely (e.g. you can't go to (-100000, -100000) probably).
actually you can go offscreen to any coordinates, including coordinates in the billions trillions, and even infinity :) It's really simple, all you have to do is make a empty 0x0 sprite inside of the vector editor, and use this script:
define go to x:(x) y:(y)
switch costume to [0x0 sprite v]
set size to ((1) / (0))
go to x:(x) y:(y)
switch costume to [normal sprite v]
set size to (100) %

Last edited by Malicondi (March 26, 2024 18:18:53)


post #1000 post #100 i help in the forums post #1 post #500 0 second ninja
I recommend reading jvvg's essay about the scratch team before complaining, as it may change your opinion and provide insight on the topic.

coming soon :)


Powered by DjangoBB