btrzcinski / apaquarium

A graphical Aquarium of Creatures meant to help high school students learn Java.
https://btrzcinski.github.io/apaquarium/
GNU General Public License v2.0
1 stars 3 forks source link

ChangingSwimmer.setSpeedX(0) always results in speed 1 #3

Closed btrzcinski closed 8 years ago

btrzcinski commented 8 years ago

2 has a bug in ChangingSwimmer:

public void setSpeedX(int x) 
    {
        if (x != 0) 
        {
            this.deltaX = x;            
        }
        // Instead of setting the X speed to 0, set it to the slowest it can go: 1 (or -1)
        else {
            this.deltaX = this.deltaX / this.deltaX;
        }

    }

The adjustment for 1/-1 always sets 1 instead of -1 (if the previous speed is negative).

kmcginn commented 8 years ago

That's what I get for trying to be clever without actually thinking about it!