Rotation matricies seem to be what I was looking for, but when I try to implement them (at the moment the sword is just a line), I just see the sword rotating from what looks like 90 degrees to 180 degress as fast as it can, and the sword itself is much longer than it should be, this is what pertains to the sword in the game loop:
1 2 3 4 5 6 7 8 9 10 11 12
| double subx = test.getXloc(); double suby = test.getYloc(); playerCenterX = test.getXloc() + (test.getWidth()/2); playerCenterY = test.getYloc() + (test.getHeight()/2); if(cooldown > 0) cooldown--; playerRot = Math.atan2(mouseY - playerCenterY, mouseX - playerCenterX); swordRot1 = playerRot; subx = sword.getX1(); suby = sword.getY1(); sword.setLine(subx*Math.cos(swordRot)-suby*Math.sin(swordRot),subx*Math.sin(swordRot)+suby*Math.cos(swordRot),sword.getX2(),sword.getY2()); |