samedi 7 novembre 2020

If condition false but still does it

I'm running this code in JavaFX and I have no idea what's happening, I'm working with time where an event happens only at a certain period, picked randomly.

animationTimer = new AnimationTimer() {
            private long lastEvent = 0;
            private double period = Main.forest.getPeriodNextEvent();

            @Override
            public void handle(long now) {
                    if ((now - lastEvenement)/ 1_000_000_000.0 >= Main.forest.getPeriodNextEvent() && Main.forest.getList().size() != 0){
                           System.out.println((now - lastEvent)/ 1_000_000_000.0 >= Main.forest.getPeriodNextEvent() && Main.forest.getList().size() != 0);
                    }
            }
}

The output is litteraly false or true whenever it feels like it. Sometimes it'll wait 7sec instead of 2 then print false, sometimes 2sec instead of 7 print true and other times false. I've never seen anything like it. help

Aucun commentaire:

Enregistrer un commentaire