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

#1 2011-01-24 16:50:05

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

what is wrong with my wall script?

On my right sensor sprite i have

[]if <touching barrier>
[set righttest to 1]
[]else
[set righttest to 0]

Then on my hero i have,

[]forever
[][]if <<key right arrow pressed?> and <righttest = 0>>
[][][point in direction 90
     switch to costume right b
     change x by 8
     wait 0.1 sec
     switch to costume right a
     change x by 8
     wait 0.1 sec]
end if]
endforever]

Barrier is the name of a sprite i have that has different costumes. each costume is  barriers for different levels.

Offline

 

#2 2011-01-24 16:55:42

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

Re: what is wrong with my wall script?

Since it only checks righttest every time it moves 16 pixels to the right, it's probably just passing right over the wall.


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

 

#3 2011-01-24 16:57:23

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

Re: what is wrong with my wall script?

oh, sorry never said the problem -.-. 

The problem is my hero still walks through the barrier.

Offline

 

#4 2011-01-24 17:05:08

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

Re: what is wrong with my wall script?

Oh harakou, thanks for responding! but how can i fix this problem?

and it works if i put "black touching orange" instead of "touching barriers"

Im thinking it has something to do with the custom centers...

(i cant leave it like "black touching orange" because barriers is not always orange)

Offline

 

#5 2011-01-25 18:39:04

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

Re: what is wrong with my wall script?

That's odd.  hmm  I doubt it has anything to do with the centers. Actually, I seem to recall this being a weird bug with Scratch; color sensing works in cases where sprite contact sensing just skips right over. Let me check though.

Edit: It seems that both skip over, so I'm not sure what the problem is in this case. Would you be able to upload your unfinished project so I (or anyone else willing to help) could take a look?

Last edited by Harakou (2011-01-25 18:44:44)


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 2011-01-25 20:00:29

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

Re: what is wrong with my wall script?

Sure, but i think i figured out a way to make it work.

Im making 4 sprites, one for each direction that line up with things i dont want the hero to go through.

For example, when the right sensor sprite touches the right sensor walls, it'll set the variable to 1 and make stuff work. Ill upload it when i have all the sides up, because its still skipping over. I probably have to make the lines thicker...

Offline

 

#7 2011-01-25 20:02:00

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: what is wrong with my wall script?

Make one sprite, up down left right all different colors.
set ghost to 99.999
then don't do "when sprite touching..."
do "when color touching ..."
and make neon colors or something not used in your game.

Offline

 

#8 2011-01-26 15:51:35

Nano511
Scratcher
Registered: 2011-01-20
Posts: 39

Re: what is wrong with my wall script?

I started my project over with brand new programming because i diddnt like the way it was coming out. It is now a scroller, and i think when i finish it will be the first scroller rpg ever made in scratch  smile

Offline

 

Board footer