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

#1 2012-06-06 05:05:48

GameGuy64
Scratcher
Registered: 2011-09-22
Posts: 500+

0.0

On a project I am working on, the velocities for the character make the character stop and run. The problem is that it decreases by 0.1/-0.1 to get to 0, and stop. The problem is that when it reaches 0 the game freezes (not Scratch but the game itself), and online it just doesn't go to 0 it stays at 0.1. I really don't know why this happens.

This project:http://scratch.mit.edu/projects/GameGuy65/2591628

Last edited by GameGuy64 (2012-06-06 05:18:13)


http://i45.tinypic.com/25apxc7.png

Offline

 

#2 2012-06-06 05:24:24

muppetds
Scratcher
Registered: 2011-02-11
Posts: 1000+

Re: 0.0

its most likely a scripting error


SCRATCH'S PARTLY INSANE RESIDENT 
http://internetometer.com/imagesmall/31691.pnghttp://bluetetrarpg.x10.mx/usercard/?name=muppetds

Offline

 

#3 2012-06-06 05:46:59

GameGuy64
Scratcher
Registered: 2011-09-22
Posts: 500+

Re: 0.0

muppetds wrote:

its most likely a scripting error

But why does it stop the game? Do you mean with my scripting or the scripts running Scratch?


http://i45.tinypic.com/25apxc7.png

Offline

 

#4 2012-06-06 07:13:49

Tecklop
Scratcher
Registered: 2009-08-20
Posts: 63

Re: 0.0

GameGuy64 wrote:

muppetds wrote:

its most likely a scripting error

But why does it stop the game? Do you mean with my scripting or the scripts running Scratch?

Yes it's a scripting error, It freezes on Scratch 1.4 too.
It stops the game because the scripts doesn't work properly.
It's probably the [else] below which says:

[If X Velocity <0] change X Velocity by 0.1 and
[If X Velocity >0] change X Velocity by -0.1.

So if the X Velocity is ZERO it doesn't know what to do because it is not more than 0 or less than 0.

Possible Solution:
Make another one that says [If X Velocity =0] and do something.

Last edited by Tecklop (2012-06-06 07:21:20)


http://neuropod.net/imagehost/uploads/ccd036346f6834ab872b4f233c158c82.png

Offline

 

#5 2012-06-06 08:59:09

muppetds
Scratcher
Registered: 2011-02-11
Posts: 1000+

Re: 0.0

Tecklop wrote:

GameGuy64 wrote:

muppetds wrote:

its most likely a scripting error

But why does it stop the game? Do you mean with my scripting or the scripts running Scratch?

Yes it's a scripting error, It freezes on Scratch 1.4 too.
It stops the game because the scripts doesn't work properly.
It's probably the [else] below which says:

[If X Velocity <0] change X Velocity by 0.1 and
[If X Velocity >0] change X Velocity by -0.1.

So if the X Velocity is ZERO it doesn't know what to do because it is not more than 0 or less than 0.

Possible Solution:
Make another one that says [If X Velocity =0] and do something.

this i think is what causes it


SCRATCH'S PARTLY INSANE RESIDENT 
http://internetometer.com/imagesmall/31691.pnghttp://bluetetrarpg.x10.mx/usercard/?name=muppetds

Offline

 

#6 2012-06-07 07:00:47

legoscratch
Scratcher
Registered: 2010-06-18
Posts: 100+

Re: 0.0

The problems online and off are actually the same, it just matters whether you go left or right.
The glitch caused when you go left is that the variables value is really -0.0999999999999999759 (it rounds off for the viewer). It is less than 0, so it adds 0.1, but then it's a fraction more than zero, so it subtracts 0.1 and you're right back where you started.
The same sort of thing happens when you go right. It gets down to -2.414735078559715e-15, which is really really tiny but not equal to zero, so it never gets out of that loop.
The true glitch here is how Scratch can come up with these strange, incorrect numbers with just addition and subtraction of simple numbers.
To fix this, I would just round the variable off to the nearest tenth.


If you are having trouble with simple counting, use the following mnemonic device: 1 comes before 2 comes before 5,280 comes before 523,860,759 comes after the square root of -153 comes before π. This will make your previous counting problems seem like no big deal.

Offline

 

#7 2012-06-07 17:03:59

3sal2
Scratcher
Registered: 2012-03-22
Posts: 100+

Re: 0.0

legoscratch wrote:

The problems online and off are actually the same, it just matters whether you go left or right.
The glitch caused when you go left is that the variables value is really -0.0999999999999999759 (it rounds off for the viewer). It is less than 0, so it adds 0.1, but then it's a fraction more than zero, so it subtracts 0.1 and you're right back where you started.
The same sort of thing happens when you go right. It gets down to -2.414735078559715e-15, which is really really tiny but not equal to zero, so it never gets out of that loop.
The true glitch here is how Scratch can come up with these strange, incorrect numbers with just addition and subtraction of simple numbers.
To fix this, I would just round the variable off to the nearest tenth.

That's because of rounding errors in Squeak. mo- <- A mouse.

However, that may require this script:

((round ((number)*([10^ v] of (1))))/([10^ v] of (1)))


http://scratch.mit.edu/static/projects/3sal2/3120946_sm.png In 2012, scientists at the LHC discovered the Higgs boson, which explains the source of the masses of the W+, W-, and Z bosons, as well as fermions.

Offline

 

#8 2012-06-11 04:09:27

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: 0.0

You are probably trying to divide by 0.

Make sure nothing is being divided by the velocity.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

Board footer