Jump to content
  • Advertisement

Archived

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

knine

Smooth Scrolling in Programming RPG's Book

This topic is 5884 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

I''ve tried to implement smooth scrolling with the tile and map code in Jim Adams RPG book and its not working like I expect it to. I have used the chapter 11 Tile sample slightly modified. I expanded the map to a 9x9 map. Then I add an m_XOff and m_YOff in CApp. The way he describes in his book I expected the first two args in CMap::Render to be the Fine X and Fine Y(or the pixel offset in the map to render. Yet when I increase m_XOff by 1, it jumps 1 complete tile instead of 1 pixel into the map. Did anyone get this to work correctly? Thanks for your help! knine

Share this post


Link to post
Share on other sites
Advertisement
Hey there! I''m on chapter 10! That is I''m trying to make chapter 10 work but I''ve read chapter 11 a few times already and I''m going to try to make it work any day now. From my impression the Map automation class wrapped up smooth scrolling so we wouldn''t even have to worry about it. But you tried to change the smooth scrolling so the mouse cursor jumps by 2 pixels instead of 1 and it doesn''t work?

Share this post


Link to post
Share on other sites
I didn''t change any of the map code at all. i''m just passing my own m_XOff and m_YOff as the first two args of render expecting them to account for the pixel offset and they are not.

thanks

Share this post


Link to post
Share on other sites
I double-checked the code and it should work - are you assigning a tile set before using render? Check out the UseTiles function. If it continues, I''ll through together a quick demo to demonstrate the use of smooth scrolling - sorry I didn''t put one in the book.

Jim Adams


Share this post


Link to post
Share on other sites
Thanks for your reply jim. Great book so far. I have assigned a tile set. that''s not the problem. the problem is that I was trying to get the scrolling to stop at the end of the map. Upon farther inspection, i noticed when i''m trying to scroll the map 1 pixel at a time or 4 or whatever, it just scrolls 1 tile at a time.

Thanks!
knine

Share this post


Link to post
Share on other sites
I''ve got the same problem. When I''m trying to scroll trough the map. everytime I try to change camera position one bit it changes a whole tile I don''t now why.

It would be great to see some code in which that is working correct!!

plz write that demo Jim (and give us the source code).

Share this post


Link to post
Share on other sites
After stepping through the tile code, I can''t tell what''s wrong with it. It looks to me as though it should be working fine. I''m trying to move 4 pixels at a time. So when KEY_D is pressed I simple do a m_XOff += 4. m_XOff is my FineX(as described in thge book). When I call m_Map.Render(m_XOff, m_YOff, ...) I checked the values that were being passed into m_Tile.Draw and it looks fine. the value Source rect passed is

rect.top = 0, rect.left = 0, rect.right = 64, rect. bottom = 64.

The dest rect to draw to starts a -4 left, which is right because i moved the map 4 pixels.

But this is not how its displaying. Its showing the map moved 4 tiles.

Any more help would be appreciated.

Thanks!
knine

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!