This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-31 13:18:05

Jasmidge
Scratcher
Registered: 2010-07-30
Posts: 23

Solid objects

How can I make objects, or in my case, walls, solid?
So when I drive my character into them, it doesn't go straight through?
I don't know if this has been asked before, but I cant find the answer.

Oh and I apologize if I don't reply instantly, Im eating  wink


http://i33.tinypic.com/1z2lz48.gif This is Blob. She wants to give you luck on getting you to the front page.

Offline

 

#2 2010-07-31 13:34:37

DistantVisit
Scratcher
Registered: 2010-07-29
Posts: 100+

Re: Solid objects

Jasmidge wrote:

How can I make objects, or in my case, walls, solid?
So when I drive my character into them, it doesn't go straight through?
I don't know if this has been asked before, but I cant find the answer.

Oh and I apologize if I don't reply instantly, Im eating  wink

It's very nice too see that you are asking questions on the scratch forum. Please feel free to do so whenever you need help. Just if you have a question please post it on topic next time. For example, this post belongs in "All About Scratch" but this is understandable since this is your first time on the forums.

About your question:

Yes, in fact it is very possible to make objects solid. Let's say Sprite1 is the character that you are moving and Sprite2 is the wall.

Under Sprite1 you would put a script similar to this one:
[blocks]

<when green flag clicked>
<forever>
<if><touching[ sprite2
<stop all>

[/blocks]

This is of course if you are controlling your character with your mouse or arrow keys. You can also make the character bounce off the wall.

Ask anything whenever you need help.  wink

Offline

 

#3 2010-07-31 13:37:59

Wolfie1996
Retired Community Moderator
Registered: 2009-07-08
Posts: 1000+

Re: Solid objects

As DistantVisit mentioned, this post would fit better in the All About Scratch forum - but don't worry! With just a few clicks of a mouse, myself or another moderator can move it over there for you  big_smile  I'll do that right now  wink


"...Jargon - the practice of never calling a spade a spade, when you might instead call it a manual earth-restructing implement..." - Bill Bryson, Mother Tongue

Offline

 

#4 2010-07-31 13:45:12

Jasmidge
Scratcher
Registered: 2010-07-30
Posts: 23

Re: Solid objects

Thanks DistantVisit, Im going to try that now.  smile 

Thanks Wolfie1996. Sorry that I put it in the wrong forum.


http://i33.tinypic.com/1z2lz48.gif This is Blob. She wants to give you luck on getting you to the front page.

Offline

 

#5 2010-07-31 13:51:09

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Solid objects

DistantVisit's solution is a good start, but of course, if you ever touch a wall, it will stop the entire project... here's an example of a way to fix that. Just add the other keys in with more If blocks.

http://i30.tinypic.com/1zwndxh.gif


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#6 2010-07-31 14:33:31

DistantVisit
Scratcher
Registered: 2010-07-29
Posts: 100+

Re: Solid objects

Harakou wrote:

DistantVisit's solution is a good start, but of course, if you ever touch a wall, it will stop the entire project... here's an example of a way to fix that. Just add the other keys in with more If blocks.

Nice script, Harakou. My script was meant for a simple arrow control not a scrollx control. And, thanks for catching my mistake. I meant to put in a "stop script" block, but of course because of my status under the forums I can't edit that post. I will edit that as soon as I can.

Jasmidge wrote:

Thanks DistantVisit, Im going to try that now.  smile

Make sure to put in a stop script block. Not a stop all. I made a little mistake  tongue

So put in this where the "stop all" belongs:
[blocks]
<stop script>
[/blocks]

I'm happy to help. ^^

Offline

 

#7 2010-07-31 14:40:06

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: Solid objects

If you are going to use distants script you will need to put those blocks in the movement script! And it will only work with very limited sorts of movement.

Harakous way is quite a bit better, but you will need to make 4 of those scripts for each direction and still will not work for all cases.

This question is quite vague as there are many different ways of movement with different ways of stopping them (E.G: Gliding, scroll X, Point and move steps, Change X) which all require different methods, and also what do you want to happen when it hits a wall? (E.G: Bounce back, stop game, start over, die)

Offline

 

#8 2010-07-31 14:43:10

Wolfie1996
Retired Community Moderator
Registered: 2009-07-08
Posts: 1000+

Re: Solid objects

Jasmidge wrote:

Thanks Wolfie1996. Sorry that I put it in the wrong forum.

No problem  smile  Everyone makes mistakes - and the "should I put this in New Members or All About Scratch?" problem is one that catches a lot of people out ^^


"...Jargon - the practice of never calling a spade a spade, when you might instead call it a manual earth-restructing implement..." - Bill Bryson, Mother Tongue

Offline

 

#9 2010-07-31 15:12:15

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Solid objects

Make 2 variables, temporary x and temporary y. Make a script setting temporary x and y to x position and y position. Then, after the movement part, put if touching (whatever), set x to temporary x, y to temporary y. (works for top down/birds eye view. You'd need to change y by 1 or something for platformers because you touch land in platformers).


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#10 2010-07-31 15:27:41

Jasmidge
Scratcher
Registered: 2010-07-30
Posts: 23

Re: Solid objects

Wow. Lots of replies XD. Thanks everyone. Ill try them all now  big_smile .


http://i33.tinypic.com/1z2lz48.gif This is Blob. She wants to give you luck on getting you to the front page.

Offline

 

#11 2010-07-31 21:42:16

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Solid objects

Once you get a project started, upload it. Then come back here and make a link to it and describe what you want it to do and the various AAS forum squad will be on it like ants on candy.

ps.. do this for ANY troubling scripting problem you have in the future. And of course you are welcome to jump in and help others if you see a post you feel like you can help with. But you have to be quick to be first, lol!


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#12 2010-07-31 22:44:49

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Solid objects

Locomule wrote:

And of course you are welcome to jump in and help others if you see a post you feel like you can help with. But you have to be quick to be first, lol!

Yup. Coolstuff always gets me with his ninja posts...  tongue

On-topic: You might notice that you can get "stuck" on a wall. If that happens, try using color sensing on each side of your sprite. (Make sure each color is specific to one side) Then use "If color _ is touching color _" instead of "If touching _" Make sure you have a different color sensing block for each side. For example, if you had red on the right side, do this:

Code:

If <<Key right arrow pressed> and <not(color red is touching color [color of walls])>
    Change x by 10

I'm not sure if I explained that well; if I didn't, then tell me and I'll try to explain better. (Or someone else can help of course.)

If you didn't notice the problem I was talking about, disregard this post.

Last edited by Harakou (2010-07-31 22:51:56)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#13 2010-08-01 02:12:55

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Solid objects

coolstuff=modbot... he never rests
but Harakou, you ain't so shabby either my friend! Kudos to your dedication as well  smile
Me, I've just had wayyyy to much spare time that will run out soon enough anyway when I get a new job. Too bad you can't get paid to work for Scratch from home. They would get more than their money's worth from myself and a lot of people around here!!


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#14 2010-08-04 06:42:46

Jasmidge
Scratcher
Registered: 2010-07-30
Posts: 23

Re: Solid objects

None of these are working for my new game  sad


http://i33.tinypic.com/1z2lz48.gif This is Blob. She wants to give you luck on getting you to the front page.

Offline

 

#15 2010-08-04 06:55:08

Jasmidge
Scratcher
Registered: 2010-07-30
Posts: 23

Re: Solid objects

Please help.. Its saved onto Scratch and if someone plays it, they'll think its rubbish and never play again!


http://i33.tinypic.com/1z2lz48.gif This is Blob. She wants to give you luck on getting you to the front page.

Offline

 

#16 2010-08-04 18:22:48

maxdacoolio97
New Scratcher
Registered: 2010-08-04
Posts: 1

Re: Solid objects

sorry to inturrupt but i want my characters to die and restart, HOW?

Offline

 

Board footer