I have a world with this code:
The goal is to add a Ball to the world with the rotation already set (tot 10) and when the game starts, the ball should start moving at an angle of, in this case, 10 degrees. (in the future, that 10 should be a random number)
I have an image of a square(*), black 'ball' with size 10x10 pixels.
(*) = so I can see visually if the ball is rotated.
The only code in the void act of the ball is:
What I expect is when the game starts the ball starts moving to the right at an angle of 10 degrees ( 0 degrees = east of course) in case of the code above.
But it doesn't......
Here is what happens when I fill in different numbers instead of 10
- Number >=0 AND <= 30 --> Ball goes at angel of 0 degrees, so straight east
- Number >=30 AND <= 60 --> Ball goes at an estimated angle of 45 degrees
- Number >= 61 AND <=90 --> Ball goes straight down (angle of 90 degrees)
In all these cases:
1. I see visually that the ball is rotated
2. When I inspect the Ball (right click, Inspect) I see that the rotation is correct according to the code above.
So the ball rotates ok, but it only moves in 3 directions: horizontally, vertically and appr 45 degrees.
I've tried different images (size, shape) but with no effect. Can anybody tell me what I'm doing wrong? Thanks!
super(800, 600, 1);
Ball ball = new Ball(){};
ball.setRotation(10);
addObject(ball, 5, 5);move(1);
