Discuss Scratch

AJILity
Scratcher
33 posts

How do you make a sprite "solid"?

i am making a project where you move the character with the arrows (so basically just a normal platform game), and i want to make it so that it if its touching a sprite, that sprite will act solid, and stop it from passing through. but i want it to still be able to move after touching it, just not pass through. can someone please help me?
thanks,
Indi
AJILity
Scratcher
33 posts

How do you make a sprite "solid"?

also, is there a way you can make a COLOUR “solid”?
rpglurker
Scratcher
100+ posts

How do you make a sprite "solid"?

Here is a great way to make things “solid” It is an algorithm that checks to see if movement is safe with a shadow…and then follows with the sprite…You can add whatever movement rules you want to the shadow…If the move follows the rules, the original follows; otherwise it resets back to where it was…because the shadow is ghosted you do not see it jiggling back and forth if you try to make an invalid move over and over…You just see the sprite which moves smoothly…
ECLIPSE-STUDIOS
Scratcher
100+ posts

How do you make a sprite "solid"?

Hi,

There are two methods. The easy method, and the hard method. The easy method is make your level our of a sprite with no background and use simply say if touching that sprite, u do the last movement or make all walls the same colour and use if touching that colour. While this works, it can create a jittering/jumping effect. The harder method is to do this with an invisible version of the player, and you move the hidden character using the checks I mentioned above and then say that once the hidden character is in an acceptable position, them move the visible player to the hidden player.

I hope this helps!
AJILity
Scratcher
33 posts

How do you make a sprite "solid"?

can you perhaps show me the script for that if its not to hard?
thanks
AJILity
Scratcher
33 posts

How do you make a sprite "solid"?

sorry I just didn't quite understand,
mstone326
Scratcher
1000+ posts

How do you make a sprite "solid"?

AJILity wrote:

i am making a project where you move the character with the arrows (so basically just a normal platform game), and i want to make it so that it if its touching a sprite, that sprite will act solid, and stop it from passing through. but i want it to still be able to move after touching it, just not pass through. can someone please help me?
thanks,
Indi

Here is a simple project example that shows how to stop your sprite from passing through an object. Basically if you are moving 5 steps right, and touch an obstable, you undo the move and move -5 steps.

https://scratch.mit.edu/projects/153809448/
Laddie12
Scratcher
100+ posts

How do you make a sprite "solid"?

If you are looking for something easy, just write a simple script like so
forever
if <key [up arrow v] pressed?> then
change y by (5)
if <touching color [#0d5a1a] ?> then
change y by (-5)
end
end
end
This should make it appear “solid” when moving.

If you are looking for something more advanced, you can research rigid body dynamics. I wouldn't recommend doing that for a scratch project, but if you want an example. check this out.
ML-10
Scratcher
28 posts

How do you make a sprite "solid"?

come up with ideas here.(platforming game)
ECLIPSE-STUDIOS
Scratcher
100+ posts

How do you make a sprite "solid"?

AJILity wrote:

can you perhaps show me the script for that if its not to hard?
thanks

First youll want to lock the direction of your visible character by clicking the i icon next its icon in the sprite menu and choose left ans right only. Then make a copy of the sprite and tell it to hide. Delete all the controls from inside the visible player, so that the invisible one is thebonly one thatnmoves (for now). Npw, in the invisible copy of your player have a script like:

forever
if <key [left arrow v] pressed?> then
point in direction (-90 (or whatever left is) v)
move (5) steps
end
end


Inside the forever loop, have an if for each of the arrow keys or wasd depending on which you are using. When you jump you'll want to tell it to point upwards (it makes the next bit easier if you do each direction). Then add to the forever loop:

if <touching color [#ffe4eb] ?> then
change y by (-5)
repeat until <not <touching color [#ffe4eb] ?>
change y by (1)
end
end
if <touching color [#ffe4eb] ?> then
repeat until <not <touching color [#ffe4eb] ?>
move (-1) steps
end
end
broadcast [Move player v]

In the above scriot just change the colour to the colour of your walls/floors are. If you are using a backgriundless sprite as the level, you can also swap out the touching colour block for a touching sprite one. Just make sure it is the last thing to happen in the forever loop. Then in the player have a script like this:

when I receive [Move Player v]
go to [Invisible Player Sprite v]

This will work with basic physics. If you want to use more advanced physics, let me know and I'll set up the scripts in the project for you.

I hope his helps!
p-pizza
Scratcher
15 posts

How do you make a sprite "solid"?

make this script
forever
if <touching color [jour color] ?> then
change y by (1)
end
change y by (-1)
end
i hope it works
rpglurker
Scratcher
100+ posts

How do you make a sprite "solid"?

necroposting is when you revive a dead thread by posting something (yes even an emoticon can be a necropost)….And spamming is posting junk that does not add to the discussion…. As we have seen here, it is possible to do both…reviving a thread that is more than a year old by spamming an emoticon…. Please do not spam or necropost or both….
KidoftheEnder45
Scratcher
1000+ posts

How do you make a sprite "solid"?

rpglurker wrote:

necroposting is when you revive a dead thread by posting something (yes even an emoticon can be a necropost)….And spamming is posting junk that does not add to the discussion…. As we have seen here, it is possible to do both…reviving a thread that is more than a year old by spamming an emoticon…. Please do not spam or necropost or both….
Oh, I didn't notice the time stamps. My bad.
caed2010_
Scratcher
11 posts

How do you make a sprite "solid"?

if <touching color [#15413c] ?> then 


move (-2) steps
repeat until <not <touching color [#15413c] ?>>

end

else

end
caed2010_
Scratcher
11 posts

How do you make a sprite "solid"?

wait let me try again

when green flag clicked
if <touching color [#f8599f] ?> then
repeat until <not <touching color [#f8599f] ?>>
change x by (-1)

end
end
deck26
Scratcher
1000+ posts

How do you make a sprite "solid"?

caed2010_ wrote:

wait let me try again

when green flag clicked
if <touching color [#f8599f] ?> then
repeat until <not <touching color [#f8599f] ?>>
change x by (-1)

end
end
Please don't necropost.
caed2010_
Scratcher
11 posts

How do you make a sprite "solid"?

deck26 wrote:

caed2010_ wrote:

wait let me try again

when green flag clicked
if <touching color [#f8599f] ?> then
repeat until <not <touching color [#f8599f] ?>>
change x by (-1)

end
end
Please don't necropost.
what ?
caed2010_
Scratcher
11 posts

How do you make a sprite "solid"?

when green flag clicked
forever
if <key [left arrow v] pressed?> then
change x by (-3)
if <touching color [#30d484] ?> then
repeat until <not <touching color [#30d484] ?>>
change x by (3)
when green flag clicked
if <key [right arrow v] pressed?> then
change x by (3)
if <touching color [#30d484] ?> then
repeat until <not <touching color [#30d484] ?>>
change x by (-3)
end
end
end
end
sportstarxa9
New Scratcher
1 post

How do you make a sprite "solid"?

excuse me but I don't know how to make a solid object. sorry to disturb you, but I'm pretty new
Harakou
Scratcher
1000+ posts

How do you make a sprite "solid"?

sportstarxa9 wrote:

excuse me but I don't know how to make a solid object. sorry to disturb you, but I'm pretty new
Hi! This thread is pretty old, and there are a number of answers to it already. You're probably going to find that most people aren't going to scroll down to see your question, and so any more specific help you need is likely to go unanswered. Instead, try making a new thread by clicking the “new topic” button and explaining what you need help with. If you think something in this thread would be useful as a reference, you can always copy the link and include it in your new topic too.

Powered by DjangoBB