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

#1 2010-05-25 15:54:05

lu9
Scratcher
Registered: 2009-05-19
Posts: 56

How to make solid walls without combining with "Ground"

I Just used the Thingy when touching sprite or colour move back -Number Steps, But when u Jump ON it brings me back.
How can i put this in one sprite? Because to work properly, i would need to make 2 sprites: a wall and a ground. But i don't want that.
Can please anyone tell me?
Thanks


Talk about Scratch,Super Mario Bros X, Super Mario War and Lego Stunt Rally in my forum

Offline

 

#2 2010-05-25 16:46:15

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to make solid walls without combining with "Ground"

lu9 wrote:

I Just used the Thingy when touching sprite or colour move back -Number Steps, But when u Jump ON it brings me back.
How can i put this in one sprite? Because to work properly, i would need to make 2 sprites: a wall and a ground. But i don't want that.
Can please anyone tell me?
Thanks

You could always use colour sensing - making the ground one colour, and walls another, and then sense that way.

Another commonly used method is to make four sprites, which should be just lines, two of which should be horizontal, and two should be vertical. Make sure the center of the costumes are spot-on, then forever send them to your sprite, plus or minus a few pixels - the idea being that they surround the sprite. For example, say our sprite is 50 pixels wide and the costume center is right in the middle. The left sprite should have a script like this:

Code:

When Green Flag Clicked
Forever
  go to x: ((x position of Sprite) - 25) y: (y position of sprite)
end

You can alter that code for right, down, and up, too.

Then, create a global variable for left, right, up, and down. Make the four sprites have their ghost effect set to 100, so they won't be showing (but don't use the hide block because sensing no longer works properly if that is the case). Then make it forever so that if a sprite is touching the walls/ground, set their corresponding variable to 0, otherwise it is set to 1. Then, on the character sprite, make it so that moving can't be done in a particular direction if the corresponding variable is equal to 0.

This method is a lot more accurate than the first one I described and requires a lot less work once you have the engine done. I know I described it kind of vaguely (more as a concept than anything else), so if you need any help with it, feel free to ask me.

Hope that helped!

Last edited by coolstuff (2010-05-25 16:46:44)

Offline

 

#3 2010-05-27 17:01:01

infinitum3d
Scratcher
Registered: 2009-05-10
Posts: 100+

Re: How to make solid walls without combining with "Ground"

Instead of four extra sprites, could you use two;

1. a "horizontal" pair of lines for above/below, and
2. a "vertical" pair for left/right?

or does it have to be four?

Offline

 

#4 2010-05-27 17:12:16

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to make solid walls without combining with "Ground"

infinitum3d wrote:

Instead of four extra sprites, could you use two;

1. a "horizontal" pair of lines for above/below, and
2. a "vertical" pair for left/right?

or does it have to be four?

I'm pretty certain there should be four - otherwise, how would it tell which side is in contact with the wall? I see what you're saying, but this was is bump-less. If you want a sprite jumping up & down, two will do.

Offline

 

#5 2010-06-09 17:03:44

GlitchSprite
Scratcher
Registered: 2010-06-08
Posts: 1000+

Re: How to make solid walls without combining with "Ground"

How do you make it so that the character sprite can't move if the variable is zero?


http://www.mspaintadventures.com/storyfiles/hs2/02915.gif

Offline

 

#6 2010-06-09 17:07:10

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to make solid walls without combining with "Ground"

GlitchSprite wrote:

How do you make it so that the character sprite can't move if the variable is zero?

Code:

if <(variable) = (1)>
  [Insert moving script here]
end

Offline

 

#7 2010-06-09 17:09:04

GlitchSprite
Scratcher
Registered: 2010-06-08
Posts: 1000+

Re: How to make solid walls without combining with "Ground"

Thankew soooooo much!!


http://www.mspaintadventures.com/storyfiles/hs2/02915.gif

Offline

 

#8 2010-07-17 14:34:55

Pokemonfan226
Scratcher
Registered: 2010-07-10
Posts: 13

Re: How to make solid walls without combining with "Ground"

if <(variable) = (1)>
  [Insert moving script here]
end


http://sdb.drshnaps.com/objects/7/971/Sprite/DoraemonGBA.png

Offline

 

#9 2010-07-17 14:37:24

laser100
Scratcher
Registered: 2009-12-04
Posts: 100+

Re: How to make solid walls without combining with "Ground"

finished post?

Offline

 

#10 2010-07-17 14:38:54

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to make solid walls without combining with "Ground"

Pokemonfan226 wrote:

if <(variable) = (1)>
  [Insert moving script here]
end

Thanks for trying to help out, but this topic has been solved - I'll close it to prevent any more confusion.

Offline

 

Board footer