Smooth Scrolling in Programming RPG's Book

Started by
6 comments, last by knine 21 years, 9 months ago
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
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?
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
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


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
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).
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
Anyone have more luck with this than I?

Thanks!
knine

This topic is closed to new replies.

Advertisement