This site requires JavaScript, please enable it in your browser!
Greenfoot back
ronald
ronald wrote ...

2021/11/14

PAINT GRID COLOR

1
2
danpost danpost

2021/11/15

#
ronald wrote...
I just understood your formula of int x and int y
x and y, in your case would be:
int x = (mi.getX()/wide)*wide + wide/2;
int y = (mi.getY()/high)*high + high/2;
The values in parentheses give the index of the cell. Multiplying by the cell dimension puts you at the beginning of the cell. Then, adding the halved portion puts you at the center of the cell -- where the actor is to be placed.
ronald ronald

2021/11/15

#
I will try with int x and int y for 100, if my calculations are correct, it should give 118 and 112
ronald ronald

2021/11/15

#
it looks good with your code for rows and cols 25, I found 113 and 112 for int x and int y 100
You need to login to post a reply.
1
2