Discuss Scratch

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

Hello fellow scratchers, I've been having trouble making a script for collisions. I'm making a nextbot game, I want the background to stop when the player hit box touches the building sprite. Here's the link to the game, https://scratch.mit.edu/projects/768133787/editor/ .

Last edited by Kaungy_2009 (Jan. 3, 2023 21:16:45)


Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

mchen2010
Scratcher
39 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

Sorry, I cannot understand your project, I will keep trying. Question1: is the gravity downwards, parallel to the computer screen, or is it parallel to the screen? Question2: do you have a ground sprite? I can not find a ground. Thank you for asking, and I am happy to help. Happy coding!


Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

mchen2010 wrote:

Sorry, I cannot understand your project, I will keep trying. Question1: is the gravity downwards, parallel to the computer screen, or is it parallel to the screen? Question2: do you have a ground sprite? I can not find a ground. Thank you for asking, and I am happy to help. Happy coding!


Answer1: There is no gravity its just a top down view.
Answer2: The ground sprite being the background is named 1

Theres a bigger sprite with a grass texture but you can ignore that.
Thanks for questioning!

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

“Bump”

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

mchen2010 wrote:

Sorry, I cannot understand your project, I will keep trying. Question1: is the gravity downwards, parallel to the computer screen, or is it parallel to the screen? Question2: do you have a ground sprite? I can not find a ground. Thank you for asking, and I am happy to help. Happy coding!
For clarification, I already have a collision script for buildings, I just hid them for an update next year. The scripts are very buggy and an inefficient use of code.
To explain how my Very buggy collision script works:

There are 4 sprites on each side of the scratch cat (your player) and when for example the right one is touching the building, it will broadcast code to the background to move to the right more, which acts like a movement away from the wall.

I saw you also left a comment on my project talking about nextbot collisions, Im more focused on the player right now and ill use nodes for the next bot ai soon after buildings are implemented.

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

Bump

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

I'm not sure if anyone knows how to make a collision script for a scrolling background.

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

Bump

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

The scrolling has acceleration so the scroll will not stop immediately when the keys are released.

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

bump

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

groggs
Scratcher
100+ posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

I don't understand “I want the backdrop to stop”, could you elaborate more about that point?
Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

groggs wrote:

I don't understand “I want the backdrop to stop”, could you elaborate more about that point?

Its not a backdrop, the background being a sprite that scrolls when wasd are pressed. You can check out the game to see it.
I want the sprite to stop when the player hits an object or wall. Im trying to add buildings to my game but im not sure how to add collisions.

Last edited by Kaungy_2009 (Jan. 3, 2023 22:05:38)


Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

Bump

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

SupaYoshiBro
Scratcher
100+ posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

There's a Scratch Wiki page about this: Scrolling Background Collisions & Code

Highlight the first letter of my signature
then shift+down arrow
when green flag clicked
forever
eat apple
end

// there was a kumpquat here but he was so hungry he ate himselt XD
My 60th post
My 100th post
say [#A9EF01] :: looks

Check out my profile here!
Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

SupaYoshiBro wrote:

There's a Scratch Wiki page about this: Scrolling Background Collisions & Code

Its not really gonna work for my type of scrolling.

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

Kaungy_2009
Scratcher
44 posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

Bump

Need help with a collision script for my game!!!
⬇Game⬇V.1.00.00

⬇Discuss about it it over here⬇
My Nextbot Game!!,Hp Display,Collision scripts for a scrolling backround
say [Compactor heheheh] for (2) secs

deck26
Scratcher
1000+ posts

Help with collision scripts for a scrolling background. HELP NEEDED!!

My advice is to check for collisions as if it is not a scroller first. Validate the move and undo it in platformer mode. Then, if the move was valid, make it again in scroll mode and broadcast to the other objects so they can move to their new positions.

This is, in my opinion, much better than changing the scroll variables and having to check multiple items for collisions and possibly have to undo multiple moves. The player's test move all hapens in the same frame as the real move so is not seen by the player.

Powered by DjangoBB