Question for TANSTAAFL
Hi! I bought your book today, and first off I can say - it is a very good book.
I just had a question from one of the examples: IsoHex14_2
I may be overlooking something, but it seems from the DrawMap() function that this example program draws the ENTIRE map whether it is on the screen or not. The main problem I have been having in my first Iso engine is not being able to figure out the right methods to scroll a map and still only draw the necessary tiles. In my previous post "Map drawing problems" I posted the source of my DrawMap() function (this was before I bought your book, today).
I am wondering if you can point me in the right direction as to how to scroll a map and calculate only the necessary tiles to be drawn.
If you are curious, what my function does right now is it finds which tiles are to be drawn, but as you try to scroll it jumps around every tile you move across (hard to explain).
Thanks for any advice you can provide.
Since I'm up...
You're readjusting your offset before moving the focus to the next cell. That's why it's jumping.
Base the cells you draw on the position of the player in the map. There's very little math involved.
That's the general idea. Where .X and .Y are locations in the map array, not actual pixel values.
Just keep plugging at it. Also, have you worked up to chapter 14 or did you just skip to there?
Ben
http://therabbithole.redback.inficad.com
Edited by - KalvinB on July 4, 2001 5:01:26 AM
You're readjusting your offset before moving the focus to the next cell. That's why it's jumping.
Base the cells you draw on the position of the player in the map. There's very little math involved.
|
That's the general idea. Where .X and .Y are locations in the map array, not actual pixel values.
Just keep plugging at it. Also, have you worked up to chapter 14 or did you just skip to there?
Ben
http://therabbithole.redback.inficad.com
Edited by - KalvinB on July 4, 2001 5:01:26 AM
Ok...
I could be wrong, but if you're saying what I think you're saying:
In this function I first set the offset for the very first tile. After that, there are the 2 for loops that just increment the Dest RECT. The drawing actualy works ok, its the scrolling that is completely off =(
If you meant something else let me know...
Oh and when I first got the book I went straight to diamond maps because that was my immediate problem. I had before read the slide map chapter on IsoHex.net, though I am still reading the book from the begining.
Thanks
Edited by - bose on July 4, 2001 11:34:46 AM
I could be wrong, but if you're saying what I think you're saying:
In this function I first set the offset for the very first tile. After that, there are the 2 for loops that just increment the Dest RECT. The drawing actualy works ok, its the scrolling that is completely off =(
If you meant something else let me know...
Oh and when I first got the book I went straight to diamond maps because that was my immediate problem. I had before read the slide map chapter on IsoHex.net, though I am still reading the book from the begining.
Thanks
Edited by - bose on July 4, 2001 11:34:46 AM
In chapters 12, 13, and 14, the entire map is drawn every frame.
later chapters show how to better optimize tile rendering.
later chapters show how to better optimize tile rendering.
Get off my lawn!
Now, I am not sure if I am approaching an isometric tile engine the right way but...
I GOT IT TO WORK!
It was simply the equation for the start RECT that I was getting wrong.
I still want to know about TANSTAAFL''s example though, and if it indeed does calculate tiles for the entire map whether it is in the viewport or not? I know my function is far from optimized - hell it doesn''t even have error checking...
But here is what worked for me:
As you can see there is little difference from my first function... the thing that fixed my problem was:
rcDest.left = (xStart-yStart)*22 + mapData.yScreen/2 - mapData.xScreen/2;
rcDest.top = (xStart+yStart)*22 - mapData.yScreen/2 - mapData.xScreen/2;
Anyway, i''d appreciate if you could answer my question, TANSTAAFL.
Thanks again
I GOT IT TO WORK!
It was simply the equation for the start RECT that I was getting wrong.
I still want to know about TANSTAAFL''s example though, and if it indeed does calculate tiles for the entire map whether it is in the viewport or not? I know my function is far from optimized - hell it doesn''t even have error checking...
But here is what worked for me:
|
As you can see there is little difference from my first function... the thing that fixed my problem was:
rcDest.left = (xStart-yStart)*22 + mapData.yScreen/2 - mapData.xScreen/2;
rcDest.top = (xStart+yStart)*22 - mapData.yScreen/2 - mapData.xScreen/2;
Anyway, i''d appreciate if you could answer my question, TANSTAAFL.
Thanks again
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement