loops - Java Monopoly Game -
i made board , set board's layout null. position token's moving them pixel pixel. when turning corners having trouble. after first 10 position token can make turn , continue next 10 position. impossible token make 2. turn.
can advice me better code problem. think make things more complicated is.
if(g.getposx() <= 650 && g.getposx() >= 50 && g.getposy()==650) { if(g.getposx()-unitchange*d.getdice() <= 50) { temp = unitchange*d.getdice() - (g.getposx() - 50); g.setposx(50); g.setposy(g.getposy()-temp); } else { g.setposx(g.getposx()-unitchange*d.getdice()); temp = 0; } } else if(g.getposy() <= 650 && g.getposy() >= 50 && g.getposx()==650) { if(g.getposy()-unitchange*d.getdice() <= 50) { temp = unitchange*d.getdice() - (g.getposy() - 50); g.setposy(50); g.setposx(g.getposx()-temp); } else { g.setposy(g.getposy()-unitchange*d.getdice()); temp = 0; } } else if(g.getposx() <= 650 && g.getposx() >= 50 && g.getposy()==50) { if(g.getposx()-unitchange*d.getdice() <= 50) { temp = unitchange*d.getdice() - (g.getposx() - 50); g.setposx(50); g.setposy(g.getposy()-temp); } else { g.setposx(g.getposx()-unitchange*d.getdice()); temp = 0; } } else if(g.getposy() <= 650 && g.getposy() >= 50 && g.getposx()==50) { if(g.getposy()-unitchange*d.getdice() <= 50) { temp = unitchange*d.getdice() - (g.getposy() - 50); g.setposy(50); g.setposx(g.getposx()-temp); } else { g.setposy(g.getposy()-unitchange*d.getdice()); temp = 0; } }
instead of using current x , y positions track location piece stopped on, try tracking property piece has landed on instead. property 1 first stop on board after go way boardwalk @ position 39. can have function
moveplayertolocation(player player, int location){ // calculate x , y based on property locatoin if(locatoin < 11){ // on first edge } else if (location < 21) { // on second edge } else if (location < 31) // on third edge } else { // on fourth edge of board } // g.setpos-ing }