Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » I can't get scratch to return the subtraction of 2 x positions
- sotosbic
- New to Scratch
12 posts
I can't get scratch to return the subtraction of 2 x positions
if <[abs] of (x1)) - ([abs] of (x2)) > <[30]> then
end
Why is that subtraction not working?
Last edited by sotosbic (Dec. 5, 2017 19:58:55)
- Incomputable
- Scratcher
8 posts
I can't get scratch to return the subtraction of 2 x positions
Perhaps you need to add a forever?
Thanks!
Thanks!
“I am not an Athenian or a Greek, but a citizen of the world.“
”As quoted in Plutarch's Of Banishment”
― Socrates
Team xenophilia! (affiliation to foreign things)
- sotosbic
- New to Scratch
12 posts
I can't get scratch to return the subtraction of 2 x positions
It seams like the subtraction it's never happening because i tested with this thing https://imgur.com/a/uAvdN. And the variable it's not changing
- Incomputable
- Scratcher
8 posts
I can't get scratch to return the subtraction of 2 x positions
Perhaps you need to add a forever?
Thanks!
May I ask what purpose this is for?
“I am not an Athenian or a Greek, but a citizen of the world.“
”As quoted in Plutarch's Of Banishment”
― Socrates
Team xenophilia! (affiliation to foreign things)
- sotosbic
- New to Scratch
12 posts
I can't get scratch to return the subtraction of 2 x positions
Perhaps you need to add a forever?
http://imageshack.com/a/img924/6276/6s3NIT.png
Thanks!
May I ask what purpose this is for?
It's for a soccer game where the attacker has to decide whether he can pass between 2 defenders or not. So i need to check if the distance between the two defenders is bigger than the size of the attacker
Last edited by sotosbic (Dec. 5, 2017 20:13:51)
- asivi
- Scratcher
1000+ posts
I can't get scratch to return the subtraction of 2 x positions
Have you made sure x1 is bigger than x2 beforehand?
- sotosbic
- New to Scratch
12 posts
I can't get scratch to return the subtraction of 2 x positions
It doesn't matter because we have put “absolute” for every xHave you made sure x1 is bigger than x2 beforehand?
- Uniquename1
- Scratcher
100+ posts
I can't get scratch to return the subtraction of 2 x positions
There must be something else going on. I made a test project here. and it seems to work. Chances are it is never getting to that loop or something else is conflicting with it. The order of which block is inside which part makes a difference too though the screen shot it looks ok. Best to share projects when looking for help as often the problem is not what you thought and is some other thing.
test project
https://scratch.mit.edu/projects/191171657/#player
test project
https://scratch.mit.edu/projects/191171657/#player
Try my games.
Scratch Sprite Club VI Soccer
Star Fighter Shooting
Space Marines: Boarding Party Strategy
Lion Runner Running/ Platformer
- asivi
- Scratcher
1000+ posts
I can't get scratch to return the subtraction of 2 x positions
It doesn't matter because we have put “absolute” for every xHave you made sure x1 is bigger than x2 beforehand?
Let say -10 and 10 positions its distance is 20
What happens if you use abs in both values?
- deck26
- Scratcher
1000+ posts
I can't get scratch to return the subtraction of 2 x positions
Best if you don't create duplicate topics.
- Discussion Forums
- » Help with Scripts
- » I can't get scratch to return the subtraction of 2 x positions