D
D
Denis2019-03-13 19:02:35
JavaScript
Denis, 2019-03-13 19:02:35

A bug in the game, can anyone look at the code and advise where I need to look?

Sometimes there is a delay in output. It seems that when the circle of animals ends, he thinks something and starts again.
Sometimes he thinks for a long time. It happens that several appear at once in one zone and abruptly disappear despite the fact that they did not click.
After I get 100 points the game goes crazy. Animals are hatched so quickly that sometimes you can’t really see them
Here is the work
https://codepen.io/fristyr/pen/xBpdXB

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2019-03-13
@Robur

I didn’t go into details, but I skimmed through the code and description - you most likely have problems with timeouts. Somewhere you do not clear the interval, or set extra timers, check it all carefully.

E
Exploding, 2019-03-13
@Exploding

Well, everything is correct.
Your initial speed (interval) is 2200. And the increase in speed takes away 1000, as a result, after two minuses of 1000, 200ms remains.

constructor(){
   //...
   this.speed = 2200;
}
setMoreSpeed(num) {
    this.speed = this.speed - num;
    //...
  }

 if (this.score % 50 === 0) {
        this.setMoreSpeed(1000); //тут наверно должно было быть 100, а не 1000?))
   //...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question