lundi 1 février 2016

If statement running when false

I'm attempting to write some code for a game in Java, however one of the if statements isn't working as expected.

if(player.gety() < y+row*tileSize){
    player.draw(g);
    System.out.println("Row:    " + y+row*tileSize);
    System.out.println("Player: " + player.gety());
}

When this code is run the output that I receive is:

Player: 200
Row:    -79.99999999968651320
Player: 200
Row:    -79.99999999968651320
Player: 200
Row:    -79.99999999968651320

This doesn't make much sense as player.gety() is clearly larger than y+row*tileSize. Is there any reason why this would be happening?

Aucun commentaire:

Enregistrer un commentaire