• Advertisement

Archived

This topic is now archived and is closed to further replies.

Parallax scrolling

This topic is 5952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK, this isn''t really about parallax scrolling. I''ve got parallax scrolling working, and I know how that part of it works. I''m scrolling some stars. Each star has an X, Y, and Z coord. The X and Y are just int''s, and are relative to the world. The Z is a float and is used for several calculations like size of the star, color, junk like that. Here''s this code for rendering the stars: RECT FillRect; DDBLTFX fx; for (int index = 0; index < 1000; index++) { int color = 255 * stars[index].z; float z = stars[index].z; int x = stars[index].x; int y = stars[index].y; fx.dwFillColor = RGB(color, color, color); FillRect.left = (x - (tmpcamera->WorldX + 400)) * z; FillRect.top = (y - tmpcamera->WorldY); FillRect.right = FillRect.left + 3 * z; FillRect.bottom = FillRect.top + 3 * z; if (3 * z >= 1) GetBackBuffer->Blt(&FillRect,NULL,NULL,DDBLT_COLORFILL | DDBLT_WAIT, &fx); } It works great, but the problem is I want the camera''s X and Y to represent the center of the camera, not the upper left corner. How do I change the coordinate system?

Share this post


Link to post
Share on other sites
Advertisement
Oh, so simple, ain''t it? I was puttin that +400 in the wrong spot. I figured it was something like that.

Thanks!

Share this post


Link to post
Share on other sites

  • Advertisement