Bug | Sololearn: Learn to code for FREE!

+1

Bug

My Game: fight the zombie, won't work... If two elements touch each other, it must console.log a number (I am going to make an fight game, but for now a number is enough), but it console.log the number way tot quick https://code.sololearn.com/WEX1x7cT7o4q/?ref=app

3/17/2019 8:11:50 AM

jelger.js

5 Answers

New Answer

+2

Your animate functions are changing the sizes of your margins, rather than moving the picture. Also, your logic to compare whether the two are touching is incomplete. This is what I’ve achieved; https://code.sololearn.com/WaKOAlocKnxg/?ref=app The problem here is that your x1,y1, etc. variables are calculated before the picture moves. You may need to use a delay timer of some sort but I’ve not managed to do this.

+2

Russ Thank you very much! Is it okay if use you code to make my game further?

+1

jelger.js Yes of course, go agead! Glad I could help.

+1

Congrats! Great code, keep going!

0

Russ , I think I fixed the last bug, thanks that I could use it! https://code.sololearn.com/WpMCjHuhKoZC/?ref=app