I decided to create a map editor for my Breakout clone, but I'm currently stuck. I have it set to place the center of the current object where the cursor is when the left mouse button is pressed. However, this is not working properly. I've translated the object placement to world coordinates fine, but no matter what world coordinates the screen is centered on,the screen coordinates registered by the program are wrong. They are fine in the upper left hand of the screen, but as you move the cursor right, there is a space between the objects that grows as the x value increases. Same with the Y axis. The further from the upper left the further from the cursor the block is placed. I have no idea what could be causing this and I was wondering if someone could tell me or help me find what I am missing.
Here is the code from my message loop where I set the X and Y positions
case WM_MOUSEMOVE: bluepaddle.color = BLUE;
bluepaddle.height = PADDLEHEIGHT;
bluepaddle.width = PADDLEWIDTH;
bluepaddle.color = BLUE;
bluepaddle.height = PADDLEHEIGHT;
bluepaddle.width = PADDLEWIDTH;
bluepaddle.x = xpos-(resWidth/2)+(int)LOWORD(lParam);
bluepaddle.y = ypos-(resHeight/2)+(int)HIWORD(lParam);
return 0;
I'm doing my drawing with opengl. Here are the relevant edited drawing routines.
void render(){
.....
gluOrtho2D(xpos-(.5*resWidth), xpos+(.5*resWidth) , ypos+(.5*resHeight) , ypos-(.5*resHeight));
.......
glColor3f(0,0,1);
glBegin(GL_QUADS);
glVertex2i(bluepaddle.x-bluepaddle.width,bluepaddle.y-bluepaddle.height);
glVertex2i(bluepaddle.x+bluepaddle.width,bluepaddle.y-bluepaddle.height);
glVertex2i(bluepaddle.x+bluepaddle.width,bluepaddle.y+bluepaddle.height);
glVertex2i(bluepaddle.x-bluepaddle.width,bluepaddle.y+bluepaddle.height);
glEnd();
..........
}
I will post the program later tonight so you can see what I'm talking about.
Any help here would be appreciated.
[Edited by - Al Gorithm on June 24, 2006 11:16:34 PM]