vendredi 29 mars 2019

How to increment a variable within a loop to move an object a certain amount of points the rotate to a new direction

rotate in a clockwise square: first go North 3 times, then East 3 times, then South 3 times, then West 3 times then repeats.

Currently my code rotates the bird north to east to west, then north to east to south, and moves up 2 North, but doesn't increment any other direction

creating for loops with an array and a temp variable storing a string direction simply to check which direction is needed

public Direction getMove(){
        if(count > 12){
            count = 0;
        }else if(count <= 12){
            if(count >= 0 && count <= 3){
                count++;
                return Direction.NORTH;
            }else if(count > 3 && count <= 6){
                count++;
                return Direction.EAST;
            }else if(count > 6 && count <= 9){
                count++;
                return Direction.SOUTH;
            }else if(count > 9 && count <= 12){
                count++;
                return Direction.WEST;
            }
        }

Aucun commentaire:

Enregistrer un commentaire