Advertisement Jump to content


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


Parallax scrolling

This topic is 6227 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; = (y - tmpcamera->WorldY); FillRect.right = FillRect.left + 3 * z; FillRect.bottom = + 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

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!