Discuss Scratch

TheRealRldFan
Scratcher
36 posts

Collision

I just need more examples of Collision with:
defineBlockname
LANCEBOX1104
Scratcher
100+ posts

Collision

is it 3D or 2D with pen?
TheRealRldFan
Scratcher
36 posts

Collision

LANCEBOX1104 wrote:

is it 3D or 2D with pen?
2D

Last edited by TheRealRldFan (March 25, 2024 16:27:42)

--CHA0S--
Scratcher
100+ posts

Collision

What type of game is it, platformer?
TheRealRldFan
Scratcher
36 posts

Collision

--CHA0S-- wrote:

What type of game is it, platformer?
Movearoundgametypesomoveanywhere

Last edited by TheRealRldFan (March 25, 2024 16:26:43)

TheRealRldFan
Scratcher
36 posts

Collision

Ihave1example:defineCollisionXYchangexbyXchangeybyYiftouchingCollision thing?thensetxtoPreviousXsetytoPreviousYRestexampleinShrek_on_donke’sprofileMy freind basically

Last edited by TheRealRldFan (March 25, 2024 16:24:42)

TheRealRldFan
Scratcher
36 posts

Collision

whenclickedIdohaveagameshutdownforawhileduetocollision!
TheRealRldFan
Scratcher
36 posts

Collision

sayI don’t have much examples and the set up for the block takes a whileforxpositionsecs

Last edited by TheRealRldFan (March 25, 2024 16:44:56)

Malicondi
Scratcher
1000+ posts

Collision

You'll have to be a bit more specific on what you mean by collision, or we won't really be able to help.
TheRealRldFan
Scratcher
36 posts

Collision

Malicondi wrote:

You'll have to be a bit more specific on what you mean by collision, or we won't really be able to help.
Like when you touch something you can’t go past it
Wolf_Link21
Scratcher
100+ posts

Collision

ramenecho
Scratcher
100+ posts

Collision

TheRealRldFan wrote:

I just need more examples of Collision with:
defineBlockname
Ok so if you want something to collide with an object preventing it from moving past it, im assuming you want it to collide with a form of immovable wall, just make it so every time the sprite moves it checks to see if it is touching the object, and if so then you move with the opposite, example:
changexbyxvelocitychangeybyyvelocityiftouchingwall sprite?thenchangexby-1*xvelocitychangeyby-1*yvelocity
I hope this helps!

Last edited by ramenecho (March 25, 2024 17:26:37)

--CHA0S--
Scratcher
100+ posts

Collision

ramenecho wrote:

TheRealRldFan wrote:

I just need more examples of Collision with:
defineBlockname
Ok so if you want something to collide with an object preventing it from moving past it, im assuming you want it to collide with a form of immovable wall, just make it so every time the sprite moves it checks to see if it is touching the object, and if so then you move with the opposite, example:
changexbyxvelocitychangeybyyvelocityiftouchingwall sprite?thenchangexby-1*xvelocitychangeyby-1*yvelocity
I hope this helps!
You could break it down a bit further to detect if it was an x collision or a y collision like this
changexbyxvelocitychangeybyyvelocityiftouchingwall sprite?thenchangexby-1*xvelocityiftouchingwall sprite?thenchangexbyxvelocitychangeyby-1*yvelocityiftouchingwall sprite?thenchangexby-1*xvelocityelsestopthis scriptelsestopthis script
TheRealRldFan
Scratcher
36 posts

Collision

Wolf_Link21 wrote:

something like this? https://scratch.mit.edu/projects/989406212/
ifyeahthen

Last edited by TheRealRldFan (March 25, 2024 19:23:43)

TheRealRldFan
Scratcher
36 posts

Collision

like you can use the following:
PreviousYPreviousXXYdefineCollisionXY
Shrek_em
Scratcher
34 posts

Collision

If every wall is going to be the same color (could just be an outline) then the easiest solution is probably
whenclickedforeverifkeywpressed?andtouchingcolor?thenchangeyby-1

And just copy-paste that if then code for every player input, change the “touching color” to whatever color the thing its colliding with is, and swap out the “change y by” code for “change x by” if it is going horizontal, also make sure to match the “-1” with the speed of the character and remove the “-” if It is going down or left

I think this works idk I'm not sure but if I remember correctly this should work
TheRealRldFan
Scratcher
36 posts

Collision

Shrek_em wrote:

If every wall is going to be the same color (could just be an outline) then the easiest solution is probably
whenclickedforeverifkeywpressed?andtouchingcolor?thenchangeyby-1

And just copy-paste that if then code for every player input, change the “touching color” to whatever color the thing its colliding with is, and swap out the “change y by” code for “change x by” if it is going horizontal, also make sure to match the “-1” with the speed of the character and remove the “-” if It is going down or left

I think this works idk I'm not sure but if I remember correctly this should work
thanks
Shrek_em
Scratcher
34 posts

Collision

TheRealRldFan wrote:

Shrek_em wrote:

If every wall is going to be the same color (could just be an outline) then the easiest solution is probably
whenclickedforeverifkeywpressed?andtouchingcolor?thenchangeyby-1

And just copy-paste that if then code for every player input, change the “touching color” to whatever color the thing its colliding with is, and swap out the “change y by” code for “change x by” if it is going horizontal, also make sure to match the “-1” with the speed of the character and remove the “-” if It is going down or left

I think this works idk I'm not sure but if I remember correctly this should work
thanks

no problem!
TheRealRldFan
Scratcher
36 posts

Collision

Shrek_em wrote:

TheRealRldFan wrote:

Shrek_em wrote:

If every wall is going to be the same color (could just be an outline) then the easiest solution is probably
whenclickedforeverifkeywpressed?andtouchingcolor?thenchangeyby-1

And just copy-paste that if then code for every player input, change the “touching color” to whatever color the thing its colliding with is, and swap out the “change y by” code for “change x by” if it is going horizontal, also make sure to match the “-1” with the speed of the character and remove the “-” if It is going down or left

I think this works idk I'm not sure but if I remember correctly this should work
thanks

no problem!
I am going to follow thanks for the tip!
TheRealRldFan
Scratcher
36 posts

Collision

I need more tips please!

Powered by DjangoBB