char array tile drawing function
Hi,
I'm having trouble figuring out how to get my tile based graphics engine to work. I am able to display as many tiles on screen as I want using the following concept:
1) Source rect identified
2) Initial destination rect set (0,0,32,32)
3) 1st loop starts
4) 2nd loop draws a tile, then increases the x value of the dest rect. This loop ends.
5) 1st loop increases the y value of the dest rect. This loop ends and then goes back to the other loop.
6) Steps 3-6 are repated until all tiles are displayed.
My problem is as follows:
I have a character array which only consists of 1s and 0s. (char map[12][12]) I have the two loops run as many times as there are values in the array. I added an If..Then statement that says if the value is 1, then draw the tile, if not, don't draw anything. If all values are 1 then everything works fine. However, when I change one value to 0, then one tile isn't drawn, but it's at the wrong place. I haven't discovered a pattern of where the not drawn tile is in relationship to the 0 value in the array, but I think that either the x or y value are opposite, or maybe even both.
Please help me! I hope I made myself clear, although I never really succeed in doing so!
Edited by - alex mcandrew on 12/17/00 1:41:08 PM
Edited by - alex mcandrew on 12/18/00 10:04:39 PM
--------------------Help Needed!Turn-based 20th century strategy wargameTitle still to be determined
C''mon! I know someone here can help me... It''s funny that I''m a beginner, yet my questions can never be answered. Please help me, this is important.
--------------------Help Needed!Turn-based 20th century strategy wargameTitle still to be determined
Well, have you TRIED reversing the X & Y loops?
Otherwise try reversing the count, ie x=64;x>=0;x--)
NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ...
Otherwise try reversing the count, ie x=64;x>=0;x--)
NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ...
"NPCs will be inherited from the basic Entity class. They will be fully independent, and carry out their own lives oblivious to the world around them ... that is, until you set them on fire ..." -- Merrick
Im not sure if this will help or even if it is a valid point but if you are only using 0''s and 1''s why not use an array of bool type?
If you are still having problems I can email you the part of my game that deals with drawing tiles but i am using an array of TILES (class TILE) so it isnt quite the same as what you are trying to do
Just my thoughts take them as you will.
"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
If you are still having problems I can email you the part of my game that deals with drawing tiles but i am using an array of TILES (class TILE) so it isnt quite the same as what you are trying to do
Just my thoughts take them as you will.
"People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
Just my thoughts take them as you will. "People spend too much time thinking about the past, whatever else it is, its gone"-Mel Gibson, Man Without A Face
quote: Original post by alex mcandrew
My problem is as follows:
I have a character array which only consists of 1s and 0s. (char map[12][12]) I have the two loops run as many times as there are values in the array. I added an If..Then statement that says if the value is 1, then draw the tile, if not, don''t draw anything. If all values are 1 then everything works fine. However, when I change one value to 0, then one tile isn''t drawn, but it''s at the wrong place. I haven''t discovered a pattern of where the not drawn tile is in relationship to the 0 value in the array, but I think that either the x or y value are opposite, or maybe even both.
Ok, as you were saying, this is just a matter of inverting the 2 values. It''s a bit hard to explain without a graphic but anyhow, just invert the x and y in your 2 for loops. That should solve the problem. I''ve had the same thing happen to me.
Cyberdrek
Headhunter Soft
DLC Multimedia
[Cyberdrek | ]
When you say It does nothing when it encounters a 0, does that mean it doesn''t increment the x & y values either?
BTW, a bool is a typedef int and hence twice as big as a char. However, you could use an int per line if you have a 16x16 array and using some bitwise arithmetic =)
hope I helped
Marcel B.
The Rubber Chicken Must Die.
BTW, a bool is a typedef int and hence twice as big as a char. However, you could use an int per line if you have a 16x16 array and using some bitwise arithmetic =)
hope I helped
Marcel B.
The Rubber Chicken Must Die.
The Rubber Chicken Must Die.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement