Why's it not working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why's it not working?

Why is this code not working? What did i do wrong in the javascript https://code.sololearn.com/W6ra2t7VK11n/?ref=app

26th May 2018, 6:59 PM
Roel
Roel - avatar
10 Answers
+ 1
Roel Jy moet die kode wat besluit hoe om te beweeg skei van die kode wat besluit wanneer om te beweeg. Yes, the if conditions shoul be seperate for when something should happen and how something should happen. x y changes based on behaviour and behaviour changes when x y is a certain value. It can be simplified to a state machine. Initial state is move right but when x >= 200 transition into move down state. Your logic is flawed thou and I'll let you fix that you will notice it when you see it.
27th May 2018, 10:35 AM
Nommer101
Nommer101 - avatar
0
What's wrong?
26th May 2018, 7:03 PM
Paul Grasser
Paul Grasser - avatar
0
look at the code: its ment to do this let the box go to right if a<1 and d>0 then set a to 1 and b to 0 and that with all of them so it will be an infinite loop
26th May 2018, 7:05 PM
Roel
Roel - avatar
0
Roel a <1 and d>0 does not get executed because it is an else if. right >= 200 gets executed everytime because it is true.
26th May 2018, 10:03 PM
Nommer101
Nommer101 - avatar
0
Nommer101 what do you suggest me to use? (pls only tips, because its more fun and i learn more from it☺)
26th May 2018, 10:16 PM
Roel
Roel - avatar
0
Roel Separate your movements from the behaviour. They are not related but they just depend on each other.
26th May 2018, 10:22 PM
Nommer101
Nommer101 - avatar
0
like with only if statements? im not that good at english, sorry for that
26th May 2018, 10:23 PM
Roel
Roel - avatar
0
Nommer101 why'd you put that first part in dutch/belgium?? and why does it mean exactly the same as the second part? and why is your dutch/belgium grammer that bad ok ill try to do that
27th May 2018, 10:44 AM
Roel
Roel - avatar
0
Roel Its afrikaans that's why its so bad. Wanted to know if you could understand it. XD
27th May 2018, 10:46 AM
Nommer101
Nommer101 - avatar
0
Nommer101 i can, but its hard, because its not fully dutch waarschiinlijk is het voor jou dan ook lastiger om deze text te begrijpen, omdat het nederlands is en niet afrikaans
27th May 2018, 10:47 AM
Roel
Roel - avatar