Reputation: 541
Ok, so I really can't figure this one out. I defined an array, playerPos, like this:
int[] playerPos = new int[]{32, 32};
and the first number is the x value, second is the y value. But, when I try to use it to define a rectangle, I get a syntax error here:
for (int x = 0 ; x < 64; x++) {
for (int y = 0 ; y < 64; y++) {
switch(map[x][y]) {
case 1:
mapRects[x][y] = new Rect(x - playerPos[0])*64, (y - playerPos[1])*64, ((x - playerPos[0])*64)+64, ((y - playerPos[1])*64)+64);
break;
case 2:
mapRects[x][y] = new Rect(x - playerPos[0])*64, ((y - playerPos[1])*64)-64, ((x - playerPos[0])*64)+64, ((y - playerPos[1])*64)+64);
break;
}
}
}
Wherever I say new Rect(), it gives me a syntax error on all the commas saying
Syntax error on token ",", [ expected
and on the last number, it says
Syntax error, insert "]" to complete Expression
I have no idea what is wrong. Help?
Upvotes: 0
Views: 154
Reputation: 10378
It is a parentheses problem:
new Rect(x - playerPos[0])*64 ...
You probably need to add an opening one like this:
new Rect((x - playerPos[0])*64 ...
Upvotes: 5