lf I make an animation of div elements that cancel each other when they touch how can I do that without using many if statements | Sololearn: Learn to code for FREE!

+1

lf I make an animation of div elements that cancel each other when they touch how can I do that without using many if statements

12/31/2019 11:28:26 AM

boolean

11 Answers

New Answer

+4

Well that code is too long, so I'll just give you an idea: Make a function that detects collision You can easily program it, or check for some online tutorials. Make a function that keeps track of you elements position. Make a function that detects the edges of an element. Finally, find a creative way to connect all of the three functions mentioned above :) Not sure if this is the best solution, but that's how I would do it..

+2

Can you post your code here ?

+2

I don't code on SoloLearn, is it okay if I make a web version of it ? You can then copy-paste the files on your computer. Also, I need to see an attempt from you first.

+2

boolean I want to see a small code from you..

+2

+1

https://code.sololearn.com/WeIRVRzfTHKl/?ref=app

+1

It's ok you can make a web version of it

+1

Oryt I've got an idea that wont waste time I will just take my code clear the if statement and some other elements from the code

+1

https://code.sololearn.com/W4rv2iTMetFI/?ref=app

+1

Happy New year

0

May you do me just a small code example so that I would understand better