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

2019/6/3

X,Y coordinates

PurpleFrozone PurpleFrozone

2019/6/3

#
Hey guys, I’m making a program where horizontal lines spawn at the edge of the screen at regular intervals, as if it were a moving road. What are the coordinates for 1/3 and 2/3 of the way down the screen on the right side?
Super_Hippo Super_Hippo

2019/6/3

#
X is the width of the world, Y is the height of the world multiplied by 1/3 or 2/3.
danpost danpost

2019/6/3

#
Super_Hippo wrote...
X is the width of the world, Y is the height of the world multiplied by 1/3 or 2/3.
x and y are coordinates -- not distances. width and height are dimensions of the world.
1
2
int hiY = getHeight()/3;
int loY = getHeight()*2/3;
Super_Hippo Super_Hippo

2019/6/3

#
Well, I meant that the X-coordinate where the object will be added equals the width of the world. Similar for how I described the Y-coordinate. Didn't think one could get confused by my formulation given the fact that it fits the question pretty well.
danpost danpost

2019/6/3

#
Super_Hippo wrote...
Well, I meant that the X-coordinate where the object will be added equals the width of the world. Similar for how I described the Y-coordinate. Didn't think one could get confused by my formulation given the fact that it fits the question pretty well.
I agree that your response fit the question. I just felt clarity was important. Some of those new to greenfoot take a while to get things (if at all). Not saying this is one of them.
You need to login to post a reply.