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)
Offline
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)

Offline
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
Offline
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.
Offline
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)))
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