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

#26 2012-06-17 10:10:13

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Going through walls glitch

laser314 wrote:

amcerbu wrote:

Well, if Scratch had greater computational speed (in other words, no built-in delay), I would use a recursive function, but unfortunately, loops are slow.

I don't think turbo mode has the delay.

That's correct, but making programs for turbo mode is harder; I've been experimenting with it on my test account, but you have to implement a feature that keeps the framerate constant.  This restricts your programming: no "glide" blocks, no "wait _ secs" blocks, and no "play _ until done" blocks.  I don't think Firedrake969 wants to build a project suited only for turbo anyway.

Offline

 

#27 2012-06-17 20:04:15

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Going through walls glitch

lalala3 wrote:

The problem is that you made it move away from the mouse, not the wall.

Randomness_Player wrote:

Did you use color sensing or sprite sensing?
Try using sprite sensing as the wall...

lalala3 is quite right... because the mouse pointer is black... and you might have used color sensing.

The problem is nothing like that.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#28 2012-06-17 20:05:41

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Going through walls glitch

EPICPIKAGUY wrote:

EPICPIKAGUY wrote:

fetzer wrote:

Ya, i might also suggest making the wall a bit thicker?

Yep,that is a great idea,but what if u wanna make a wall thin?first you have to make a maximum velocity(your caracter cannot go faster than a certain speed),then make your sensor as thick as your maximum velocity(e.g. Max vel. Equals 5,u make sensor 5 pixels(if u don't know that measure,just estimate)).

No offense,of corse!

The wall thickness is NOT the problem.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#29 2012-06-17 22:09:35

wahoo77
New Scratcher
Registered: 2012-06-17
Posts: 27

Re: Going through walls glitch

MoreGamesNow wrote:

This script should work "better".  Increasing the number of trials (increase "5" and the if-else statements) will make it "better", but at the cost of speed.  I don't want to guess whether it will fit into a single frame, but, at the very least, the script should show the basic concept.

when gf clicked
forever
set [m_x v] to (mouse x)
set [m_y v] to (mouse y)
set [x v] to (x position)
set [y v] to (y position)
set [d v] to ((distance to [mouse-pointer v])/(5))
point towards [mouse-pointer v]
move (d) steps
if<touching [wall v]?>
go to x:(x) y:(y)
else
set [x v] to (x position)
set [y v] to (y position)
move (d) steps
if<touching [wall v]?>
go to x:(x) y:(y)
else
set [x v] to (x position)
set [y v] to (y position)
move (d) steps
if<touching [wall v]?>
go to x:(x) y:(y)
else
set [x v] to (x position)
set [y v] to (y position)
move (d) steps
if<touching [wall v]?>
go to x:(x) y:(y)
else
set [x v] to (x position)
set [y v] to (y position)
move (d) steps
if<touching [wall v]?>
go to x:(x) y:(y)
end
end
end
end
end

it should work with only one if/else block

Offline

 

#30 2012-06-18 07:55:32

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Going through walls glitch

wahoo77 wrote:

it should work with only one if/else block

That may be possible, but would definitely be difficult.  I've simplified the script though.

when gf clicked
forever
set [d v] to ((distance to [mouse-pointer v])/(length of sprite))
point towards [mouse-pointer v]
set[bool v] to [false]
set [x v] to (x position)
set [y v] to (y position)
repeat until <<(distance to [mouse-pointer v]) < (length of sprite)> or <(bool) = [true] >>
move (d) steps
if<touching [wall v]?>
go to x:(x) y:(y)
set [bool v] to [true]
else
set [x v] to (x position)
set [y v] to (y position)
end
end
if<(bool) = [false]>
go to [mouse-pointer v]
if <touching [wall v]?>
go to x:(x) y:(y)
end
end
Edit: oops, it appears to be glitching when I try it, and I won't have any time to fix it today.  Sorry guys.

Last edited by MoreGamesNow (2012-06-18 08:15:28)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#31 2012-06-18 21:47:02

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Going through walls glitch

Okay, this solution is relatively simple (and works) but essentially just makes the sprite move towards the sprite at a fairly high speed.  You can just replace "length" with a constant number (the minimum distance between two opposite points on a sprite).  For instance, a 16x16 pixel square would have a length of 16.

when gf clicked
forever if <(distance to [mouse-pointer v]) > ((length)/(2))>
point towards [mouse-pointer v]
move (length) steps
if <touching [wall v]?>
move (((-1)*(length))+(2)) steps
if <touching [wall v]?>
move (-2) steps
end
end


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#32 2012-06-19 18:30:24

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Going through walls glitch

Does this require only one sprite?


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#33 2012-06-20 09:31:51

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Going through walls glitch

Yes, but if you move your mouse too fast it will appear to "follow" it rather than "go to" it.

Edit: you should also click the square that prevents the sprite from rotating.

Last edited by MoreGamesNow (2012-06-20 19:18:04)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#34 2012-06-21 13:35:30

skippito
Scratcher
Registered: 2012-03-17
Posts: 100+

Re: Going through walls glitch

Make sure it moves back a greater distance than it moves forward. Also, make sure it checks for walls as often as it checks for movement keys pressed. I hope this helped! (:

Offline

 

#35 2012-06-22 17:10:17

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Going through walls glitch

Sorry, that's not the problem.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#36 2012-06-24 14:15:50

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Going through walls glitch

Did you try my script?


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#37 2012-06-26 22:19:31

Firedrake969
Scratcher
Registered: 2011-11-24
Posts: 1000+

Re: Going through walls glitch

Ok.  I've been offline for a few days.  Let me catch up on everything.


Click the sign.
https://s3.amazonaws.com/eterna/eterna2/logo2.png

Offline

 

#38 2012-06-27 01:32:24

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Going through walls glitch

You would need to go into color sensing and velocity, which is a whole nother topic.

If you come look at my game, Frigate, you'll see what color sensing+velocity is.  smile

Download and look at one of the character sprites. Basically, we have velocity, and we have another costume with colors on each side of the sprite. Then, when the script runs, it detects to see if any of the colors are touching a wall. If it is, then the script tells the velocity variables to reverse direction and bounces the sprite back.

If my script is too confusing, I'll write up  a simplified one.


Hai.

Offline

 

#39 2012-06-27 09:03:44

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Going through walls glitch

fg123 wrote:

You would need to go into color sensing and velocity, which is a whole nother topic.

I'm pretty sure you don't need color sensing.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer