Discuss Scratch

The_Legendary_Jello
Scratcher
10 posts

help with script for Physics and Collisions with a scrolling project

There is this project im trying to make. I need help with four way collision scripts that build of the collision scripts already there (link to the project below) and allow for going up hills and being hit by moving objects.




link: https://scratch.mit.edu/projects/933869482/

I am inevitable!!
when this sprite clicked
say [Well... I'm... Iron Man]
delete [this v] project
MasterofTheBrick
Scratcher
1000+ posts

help with script for Physics and Collisions with a scrolling project

All collision detection scripts can be reduced down to the basics - initiating incremental movement, then running a conditional to check for contact with any platforms/objects and reverting back to the previous coordinates if needed. The project already utilises this using colour detection so it’s a simple matter of replicating it for movement on the x-axis.

This article provides a more in-depth tutorial if needed.
1Milj
Scratcher
6 posts

help with script for Physics and Collisions with a scrolling project

Have you tried making the game check if touching the level runs a custom block without screen refresh to bring it up immediatly? I don't know if it will work and if you use a touching sprite block then you might want to search for a tutorial on how to detect certan collisions.
mhhsg
Scratcher
6 posts

help with script for Physics and Collisions with a scrolling project

scratch message pls add block physics and throwing physics

Last edited by mhhsg (March 30, 2024 23:01:00)

mhhsg
Scratcher
6 posts

help with script for Physics and Collisions with a scrolling project

define (physics)
go to [ block and push]

Last edited by mhhsg (March 30, 2024 23:01:40)

56-s
Scratcher
500+ posts

help with script for Physics and Collisions with a scrolling project

A very simple way of doing it, is this

when green flag clicked
forever
change y by (-10)
if <touching [ ground] ?> then
change y by (10)
end

or you could replace it with a change x by code so you don't go thourgh walls.

Last edited by 56-s (March 30, 2024 23:04:55)


Scratch blocks version detector:
you are using: :: hat custom
1 ( :: #ff6881) ( :: #ff6881) ( :: #ff6881) ( :: #632e9a) ( :: #632e9a) ( :: #632e9a) :: custom
2 ( :: custom) ( :: custom) ( :: #ff6881) ( :: custom) ( :: custom) ( :: #632e9a) :: custom
3 ( :: #ff6881) ( :: #ff6881) ( :: #ff6881) ( :: #632e9a) (:: #632e9a) ( :: #632e9a) :: custom
4 ( :: #ff6881) ( :: custom) ( :: custom) ( :: custom) ( :: custom) ( :: #632e9a) :: custom
5 ( :: #ff6881) ( :: #ff6881) ( :: #ff6881) ( :: #632e9a) ( :: #632e9a) ( :: #632e9a) :: custom
.0! :: custom
Thanks to @AGScratcherBest-2 for the idea and here is the code


"you are using: :: hat custom
1 ( :: #ff6881) ( :: #ff6881) ( :: #ff6881) ( :: #632e9a) ( :: #632e9a) ( :: #632e9a) :: custom
2 ( :: custom) ( :: custom) ( :: #ff6881) ( :: custom) ( :: custom) ( :: #632e9a) :: custom
3 ( :: #ff6881) ( :: #ff6881) ( :: #ff6881) ( :: #632e9a) (:: #632e9a) ( :: #632e9a) :: custom
4 ( :: #ff6881) ( :: custom) ( :: custom) ( :: custom) ( :: custom) ( :: #632e9a) :: custom
5 ( :: #ff6881) ( :: #ff6881) ( :: #ff6881) ( :: #632e9a) ( :: #632e9a) ( :: #632e9a) :: custom
.0! :: custom
"

Powered by DjangoBB