Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how do i make a solid block that sprites cant pass through
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
i already new that i just need it to be like a wall and not kill it or respawn it/teleport i need it to be like a wall
- Locomule
-
Scratcher
1000+ posts
how do i make a solid block that sprites cant pass through
Use a purple more block with the Edit option “Run without screen refresh” checked to do the collision checking unseen and super-fast. You can use an entire layer/sprite for the walls and/or the ground. When the player moves, move that direction only and see if it the player sprite hit the wall sprite? If so, move back until not touching the wall and set that velocity to 0. This handles collisions in all directions and works with a velocity/gravity system.
Here is a work-in-progress demo of that type of system. It is a work in progress, but you can see this style of collision detection working for both the player and randomly sized enemy clones. Use the space to shoot enemies and move right to scroll. The ground level is changed randomly. Any time after the game has loaded, press the C button to spawn or re-spawn random floating blocks.
As you can see, this collision system works very well, even for the randomly moving enemies. Also not that the player actually consists of a ghosted rectangle that handles all the collision checking and an overlaid sprite that handles all the sprite costume animations.
Here is a work-in-progress demo of that type of system. It is a work in progress, but you can see this style of collision detection working for both the player and randomly sized enemy clones. Use the space to shoot enemies and move right to scroll. The ground level is changed randomly. Any time after the game has loaded, press the C button to spawn or re-spawn random floating blocks.
As you can see, this collision system works very well, even for the randomly moving enemies. Also not that the player actually consists of a ghosted rectangle that handles all the collision checking and an overlaid sprite that handles all the sprite costume animations.
Last edited by Locomule (June 22, 2015 22:44:57)
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
Use a purple more block with the Edit option “Run without screen refresh” checked to do the collision checking unseen and super-fast. You can use an entire layer/sprite for the walls and/or the ground. When the player moves, move that direction only and see if it the player sprite hit the wall sprite? If so, move back until not touching the wall and set that velocity to 0. This handles collisions in all directions and works with a velocity/gravity system.
Here is a work-in-progress demo of that type of system. It is a work in progress, but you can see this style of collision detection working for both the player and randomly sized enemy clones. Use the space to shoot enemies and move right to scroll. The ground level is changed randomly. Any time after the game has loaded, press the C button to spawn or re-spawn random floating blocks.
As you can see, this collision system works very well, even for the randomly moving enemies. Also not that the player actually consists of a ghosted rectangle that handles all the collision checking and an overlaid sprite that handles all the sprite costume animations.
- Locomule
-
Scratcher
1000+ posts
how do i make a solid block that sprites cant pass through
I whipped up a simplified version of this collision system with complete script commentary so be sure to Look Inside. One difference between this one and the last one was that the previous project, although more complex, used squares against a rectangle to check collisions. This simpler version includes slope detection, giving you more options as far as how you go about drawing your floors, walls, and game maps in general. My other map consisted of 138 scrolling 20x20 tiles to create the ground. This project uses a simple vector image sprite for the walls, floors, etc that requires no scripts.
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
thank you locomule but i just want something simple and not too long t=
- purplebook163
-
Scratcher
500+ posts
how do i make a solid block that sprites cant pass through
The ST made one of these. I suggest you look at it. It has comments inside to explain the programming, but if you have any more questions please ask me on my profile.
Hope this helps!
Hope this helps!
- -Robo-Cube-
-
New Scratcher
3 posts
how do i make a solid block that sprites cant pass through
Ex:
The color is the color of the wall
when green flag clicked
forever
if <not <touching color [#000000] ?>> then
move (speed) steps
end
end
The color is the color of the wall
- ScratchMagic2002
-
Scratcher
65 posts
how do i make a solid block that sprites cant pass through
how do I make a solid block pleasethis is wut i use https://scratch.mit.edu/projects/69558796/#player
- swagmaster_bru
-
Scratcher
36 posts
how do i make a solid block that sprites cant pass through
when green flag clicked
forever
if <touching color [#ff0088] ?> then
change y by (1)
end
end
- superben100
-
Scratcher
1000+ posts
how do i make a solid block that sprites cant pass through
Here! The legit script is…
when green flag clicked
forever
if <touching color [#ff0088] ?> then
move (-10) steps
end
end
Put this on the sprite that move in a maze for example. The touching color block should be the color of the barrier block. Sadly though, you can't add this color in the rest of the maze other then barrier blocks.
Last edited by superben100 (July 7, 2015 01:49:16)
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
Here! The legit script is…when green flag clicked
forever
if <touching color [#ff0088] ?> then
move (-10) steps
end
end
Put this on the sprite that move in a maze for example. The touching color block should be the color of the barrier block. Sadly though, you can't add this color in the rest of the maze other then barrier blocks.[/quote]
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
that wont work because what if you were on a y axis it would just make you fly directly upwards so no its not legit therfore does not work
- superben100
-
Scratcher
1000+ posts
how do i make a solid block that sprites cant pass through
You should also take into account that that code was ripped STRAIT from the ScratchTeam Maze Starter project. So the code is 100% official.
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
dude this strings in this forum is how to make a solid block not a maze dude

- codeslayer00
-
Scratcher
2 posts
how do i make a solid block that sprites cant pass through
if flag clicked if touching wall then bounce back
- doublesnowcony
-
Scratcher
30 posts
how do i make a solid block that sprites cant pass through
@codeslayer00 their is no script that bounces back -_- only a script “if on edge bounce”
- liam48D
-
Scratcher
1000+ posts
how do i make a solid block that sprites cant pass through
GAHHH THE NECROBUMPS ON THIS POST GAHHHHHHHH I CAN'T STAND IT.
Lol. But yeah, there are some pretty good answers here.
Lol. But yeah, there are some pretty good answers here.
- ROLLOPOLLO
-
Scratcher
16 posts
how do i make a solid block that sprites cant pass through
easy
when green flag clicked
forever
if <key [D v] pressed?> then
point in direction (90 v)
move (3) steps
if <touching color [#ff0000] ?> then
move (-3) steps
end
end
end
- Discussion Forums
- » Help with Scripts
-
» how do i make a solid block that sprites cant pass through











