help a newbie

Started by
2 comments, last by Chris F 24 years, 4 months ago
please be more specific.

Get off my lawn!

Advertisement
ok, ive worked out how to blt all the tiles, and scroll the map the only problem is if a tiles position overlaps the edge of the screen, the tile wont show up on the screen, i really dont know why this is and i cant seem to find a solution, please help me, im using directx and c++, thanks in advance for any help.
"I have realised that maths can explain everything. How it can is unimportant, I want to know why." -Me
Hi, im making an isometric game and im not sure what the best blitting algorithm is for displaying all the tiles, any help would be much appreciated.
"I have realised that maths can explain everything. How it can is unimportant, I want to know why." -Me
Hellou. when you blit a surface to another, the destination rect (I'm assuming you're using blt, not bltfast, thou the idea is simmilar), as I was saying, the destination rect can't have any area outside of the destination image, or in your case, you have to reduce it to fit inside the screen. The problem is, you have to do the same transformation you did to the dest rect to make it fit into the screen to the origin rect (for instance, if you had to cut the last five pixels of the dest rect, you'll have to cut the last five pixels of the origin rect) otherwise you'll scale the tile.
I think that bltfast is pretty much the same thing, only you just have to worry with the origin rect.

example; say you have a 640X480 screen, and a 32X32 tile you wanted to draw at (x=635,y=10)

consider w,h:
if(x+32>640)
w = 640 - 635;
else
w = 32;

if(y+32>480)
h = 480 - y;
else
h = 32;


your dest rect would be (left, top,right,bottom): (x,y,x + w, y + h),
and your origin rect would then be: (0,0,w,h)

NOTE(S) The above code isn't supposed to be optimized in any way, was just coded from head to give you an idea about the process
Secondly, and most important, I'm not sure if the rect order is the one above, so be carefull if you use any of this in your program. Now if I were an attorney, I'd be saying the code is supplied on an "as is" basis; and the buttler did it! hitch again!
3rd, it may happen that some of the dimensions above exceed by one pixel the surfaces. if you keep on getting nothing, try subtracting one from w and h.
4th, you should use predefined variables or consts to define the width and height of the scren and tile.
5th don't forget to put comments on your code, just like i didn't do above,
6th, if you're still reading this, you have a lot of patience.
Merry christmas

This topic is closed to new replies.

Advertisement