Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how to make a sprite push another sprite
- firepawz_
- Scratcher
6 posts
how to make a sprite push another sprite
im working on a scratch remake of the king fight for deltarune and there is one attack where he moves a box that the player is suppost to stay inside but when it moves the player just goes right through the box anyone know a way to keep the player inside it?
Last edited by firepawz_ (Nov. 28, 2018 13:51:53)
- firepawz_
- Scratcher
6 posts
how to make a sprite push another sprite
https://scratch.mit.edu/projects/265235853/ on the second attack for the king boss fight the box that the player is suppost to stay in moves around but i dont know how to make it so that it pushes the soul/heart
Last edited by firepawz_ (Nov. 28, 2018 14:40:10)
- JEMA2311
- Scratcher
65 posts
how to make a sprite push another sprite
Hi firepawz, this the solution I could come up with:
Note: all of this has to be done in your heart sprite
1- Create this local variables.
2- Add this script:
3- Modify the script that makes the heart to move like this:
Another note: By doing this, it´s possible that your heart sprite might look like is being dragged by the black box (which is actually true, the heart is trying to keep up with the box coordinates). If that doesn't bother you, then you are good to go, otherwise you will have to create a new object , so the black box AND the heart can follow this new object, and since both are being dragged, boom, problem solved!
Let us know if you need more help!
Note: all of this has to be done in your heart sprite
1- Create this local variables.
(xpos)
(ypos)
2- Add this script:
when I receive [enemy turn v]
set [ypos v] to [0]
set [xpos v] to [0]
repeat until <not <[(turn)] = [enemy]>>
go to x: ((xpos) + ([x position v] of [Sprite5 v])) y: ((ypos) + ([y position v] of [Sprite5 v]))
end
3- Modify the script that makes the heart to move like this:
if <key [up arrow v] pressed?> then
change [ypos v] by (5)
if <(ypos) > [10]> then
set [ypos v] to [10]
end
end
if <key [down arrow v] pressed?> then
change [ypos v] by (-5)
if <(ypos) < [-30]> then
set [ypos v] to [-30]
end
end
if <key [left arrow v] pressed?> then
change [xpos v] by (-5)
if <(xpos) < [-55]> then
set [xpos v] to [-55]
end
end
if <key [right arrow v] pressed?> then
change [xpos v] by (5)
if <(xpos) > [45]> then
set [xpos v] to [45]
end
end
Another note: By doing this, it´s possible that your heart sprite might look like is being dragged by the black box (which is actually true, the heart is trying to keep up with the box coordinates). If that doesn't bother you, then you are good to go, otherwise you will have to create a new object , so the black box AND the heart can follow this new object, and since both are being dragged, boom, problem solved!
Let us know if you need more help!
Last edited by JEMA2311 (Nov. 28, 2018 16:42:02)
Keep Doing What You Like
………..JEMA2311………..
Check out my Clone Scrolling Method
and also my custom block “Move (X) (S/N) steps”,
which simplifies the character's motion
- Sqperdoo
- Scratcher
100+ posts
how to make a sprite push another sprite
No, no, no, no, there is a finest solution that you could make in two scripts: Hi firepawz, this the solution
Let us know if you need more help!
· In the pushing sprite you do
when green flag clicked· In the pushed sprite you do
forever
set rotation style [don't rotate v]
if <touching [Pushed v] ?> then
point towards [Pushed v]
set [Direction v] to (direction)
broadcast [Push v]
end
end
when I receive [Push v]If you want you can change the block "Set rotation style" to whatever you want
point in direction (Direction)
set rotation style [don't rotate v]
move (10) steps
if on edge, bounce
Last edited by Sqperdoo (Nov. 28, 2018 17:11:18)
- firepawz_
- Scratcher
6 posts
how to make a sprite push another sprite
Sqperdoo sorry but, this script seems to be trying to keep the char outside the box, the char is suppost to stay inside the box, not outside
- JEMA2311
- Scratcher
65 posts
how to make a sprite push another sprite
You have to keep in mind that the title you wrote says “how to PUSH a sprite”, but at the end you don't need anything to be pushed (if I understood correctly) Sqperdoo sorry but, this script seems to be trying to keep the char outside the box, the char is suppost to stay inside the box, not outside
Sqperdoo is giving you the solution the title is asking for (push a sprite with another sprite).
Please give it a try with the solution I suggested, hopefully it is what you need. If it is not, let me/us know, so we can try something different
Keep Doing What You Like
………..JEMA2311………..
Check out my Clone Scrolling Method
and also my custom block “Move (X) (S/N) steps”,
which simplifies the character's motion
- deck26
- Scratcher
1000+ posts
how to make a sprite push another sprite
For the box your best bet might be to use the distance to block. If the player moves and the centre of the box goes above a certain distance from the player the box needs to move as well.
Then use the scripts above to move the object that the block pushes. Do this via broadcasts rather than forever loops so the scripts stay in sync.
Then use the scripts above to move the object that the block pushes. Do this via broadcasts rather than forever loops so the scripts stay in sync.
- firepawz_
- Scratcher
6 posts
how to make a sprite push another sprite
i accually managed to find a solution (im fairly knew to scratch so i dont know how to close a discussion)
Last edited by firepawz_ (Nov. 30, 2018 12:37:00)
- deck26
- Scratcher
1000+ posts
how to make a sprite push another sprite
There should be an option for you, as the owner, to close a topic after 24 hours. I think it appears at the bottom of the topic thread. i accually managed to find a solution (im fairly knew to scratch so i dont know how to close a discussion)
- Jimbob4444
- Scratcher
1 post
how to make a sprite push another sprite
Yes but how can you use an or block for to sprites
- game_pr0grammer
- Scratcher
500+ posts
how to make a sprite push another sprite
Yes but how can you use an or block for to sprites
Despite the small chance that you will see this message, you have just necroposted. I know you are new to forums in general, so it is not your fault you don't know that what you just did is a criminal offense. If you reply to a topic, it gets pushed to the top of the forums. But this is a really old topic so nobody cares about this and people find this annoying.
tl;dr no replying to old topics it's bad
SPEAK UP TO KUMQUAT EQUALITY Kumquats are not bad! Kumquat lives matter!
hi i am myself, i make projects that take like a week or month to make whenever i feel like it (which isn't often) and then they only get 10 views because i'm a nobody. and i cannot change that. i am just one singular person in the sea of many that are on scratch. my stuff don't matter. i don't matter. i am going to die in 70 years anyway, and 99.99% of people on the world will not even know, or really care if they know. also i am good at programming i made an opengl so ha take that nuuubs. (i am legally required to say that statement does not accurately reflect my views i wrote that because i thought it was funny)
all my good projects. are here here are examples of my good Projects
shoot that's it basically lol they're all platformers. play them and talk about it so i get clout plz. thank.
- OOOFREE9050
- Scratcher
12 posts
how to make a sprite push another sprite
im trying to make this doggo undertale battle but i definitley agree with the pictures
i just wanna put some code here
to move up:
i just wanna put some code here
to move up:
when green flag clicked
if <> then
<key [^] pressed?>
change y by (3)
- OOOFREE9050
- Scratcher
12 posts
how to make a sprite push another sprite
my bad
when green flag clicked
if <key [^] pressed?> then
change y by (3)
end
- potatohead_1011
- Scratcher
100+ posts
how to make a sprite push another sprite
im trying to make this doggo undertale battle but i definitley agree with the pictures
i just wanna put some code here
to move up:when green flag clickedif <> then
<key [^] pressed?>
change y by (3)[/quote]
Whyyyyyyyyyyyyyyyyyyyyyyyyy
Burgers Chicken, Fish, and Veggie Breakfast Salads and Wraps Desserts Beverages Burgers Whopper Whopper with Cheese Double Whopper Double Whopper with Cheese Triple Whopper Texas Whopper Texas Double Whopper Sandwich Whopper Jr. Whopper Jr. with Cheese Hamburger Cheeseburger Double Hamburger Double Cheeseburger BK Bacon Burger Bacon Cheeseburger Double Bacon Cheeseburger BK Single Stacker BK Double Stacker BK Triple Stacker BK Quad Stacker Chicken, Fish, and Veggie Tendergrill Chicken Tendercrisp Chicken Original Chicken Chicken Crisp Classic Chicken Crisp Spicy Home-style Chicken Strips Chicken Nuggets Tacos Country Pork Sandwich Premium Alaskan Fish Sandwich BK Veggie Burger Breakfast Quaker Oatmeal Maple and Brown Sugar Quaker Oatmeal Original Sausage Breakfast Burrito Southwestern Breakfast Burrito BK Breakfast Muffin Sandwich Croissan'wich Double Croissan'wich Biscuit Sandwich Cinnabon Roll Hash Browns French Toast Sticks BK Garden Fresh Salads and Wraps Garden Fresh Salad Chicken Caesar with Tendergrill Garden Fresh Salad Chicken Caesar with Tendercrisp Garden Fresh Salad Chicken BLT with Tendergrill Garden Fresh Salad Chicken BLT with Tendercrisp Garden Fresh Salad Chicken Apple & Cranberry with Tendergrill Garden Fresh Salad Chicken Apple & Cranberry with Tendercrisp Side Garden Fresh Salad and Ranch Dressing Ranch Crispy Chicken Wrap Ranch Grilled Chicken Wrap Honey Mustard Crispy Chicken Wrap Honey Mustard Grilled Chicken Wrap Ceasar Crispy Chicken Wrap Ceasar Grilled Chicken Wrap Crispy Chicken Apple and Cranberry Wrap Grilled Chicken Apple and Cranberry Wrap Crispy BLT Salad Wrap Grilled BLT Salad Wrap Desserts Dutch Apple Pie Hershey's Sundae Pie Soft Serve Cone Soft Serve Cup Caramel Sundae Chocolate Fudge Sundae Strawberry Sundae Oreo Sundae Mini M&M's Sundae Warm Oreo Brownie Sundae Chocolate Chip Cookies White Chocolate Macadamia Nut Cookies Oatmeal Raisin Cookies Beverages Strawberry Banana
- Discussion Forums
- » Help with Scripts
- » how to make a sprite push another sprite