@Dabien
"any ideas??? "
Hmmm. That sounds like it could prove to be a challenge. But I'll give it a go. You could probably simulate it by placing a plain above every matrix tile and your character, and texture or color it black. As your character moves on to the tile delete or hide the plain permenently.
How you would go about this in code requires a bit more thinking but I'll give it my best shot. You would need to follow these steps:
1. Create a matrix.
2. Create a two-dimensional array the width and depth of the matrix(I.E. If you created a matrix that was 20 x 10 tiles big, you would create an array like the following: dim arrayname(20,10).)
3. Fill the array with data on whether it is visible or not. For now will assume that nothing is visible. You would do this with something similar to the following:
Note: We are assuming here that MatrixWidth and MatrixDepth are either constants or variables that have been declared earlier in your code and are equal to the Width and Depth of the matrix in question. If your map sizes vary from level to level use variables instead of constants.
for X = 1 to MatrixWidth
for Z = 1 to MatrixDepth
`We assume that no tile is visible so we set it to ZERO.
arrayname(X,Y) = 0
next Z
next X
4. Create a plain of size equal to or slightly larger than your tile size.
5. Texture or color the plane black.
6. Orient this plane so it is faceing up(you are looking down on the map correct?). You can do this rotating the object around its Z-axis(I think, might be X. Definately not Y though) by 90 degrees(positive or negative depends on whether you texture it and/or have backface culling set on. If you rotate it the wrong way so that it is facing down then you won't see the texture and probably won't see the plane either if back face culling is on. I believe it is on by default for plains though I could be wrong. You can set backface culling off with the SET OBJECT CULL ObjectNumber, 0 command. As to which way is the wrong way I don't remember that off hand. I think pos 90 is the right way but I'm not sure. Try it for yourself and find out.)
7. Clone as many copies of this plane as you have tiles. You would do this in code like this:
variable = MatrixWidth * MatrixHeight
for i = 1 to variable
Clone Object i + YourPlainsNumber, YourPlainsNumber
next i
7. Now comes a trick part. Placing each clone above a tile. I assume you already have a set height you want to view your map from so pick a number between the height of the camera and the max height of your map. For the x and z positon of the clone a bit of math will come into play. To find out where to position each clone you will have to find the center of your plains(because that is where the object position commands start from I think):
I'm assuming that matricies start from 0,0 and move positivly outward(I.E toward 1,1 not -1,-1 or -1,1 or anything else).
ObjHeight = whatever height you choose
`I'm assuming that the clones start at 2. If you use a different number than just change it.
ObjNum = 2
plaincenterX = (tilewidth)/2
plaincenterY = (tileheight)/2
for x = 1 to MatrixWidth
for z = 1 to MatrixDepth
position object ObjNum, x * plaincenterX, ObjHeight, z * plaincenterY
`Advance to next tile.
ObjNum = ObjNum + 1
next z
next x
With that out of the way now comes...
8. Place character on map. I'll assuming he/she is at tile (1,1) for now.
9. Update array to reflect where character has been. So in this case since he has been at tile(1,1) you would do something like this:
arrayname(1,1) = 1
Real simple. Now I'm assuming that only spaces that your character has physically been at are updated. If your character has some sort of line of sight or area of sight then that can get a slight bit more tricky. I won't go into details of how to deal with that here because I"m pressed for time but if you need any advice on how to do it just post and I'll see if I can get the time to help.
10. Scan array for visible tiles. If they are found hide corresponding plane:
`Once again, I'm assuming that the clones start at 2.
ObjNum = 2
for x = 1 to MatrixWidth
for z = 1 to MatrixDepth
if arrayname(x,z) = 1
hide object ObjNum
endif
`Advance to next tile
ObjNum = ObjNum + 1
next z
next x
Some quick pointers that I've neglected to mention:
Keep movement tile based. This will help a lot with figuring out which plane to remove and which to not.
Don't check the array every loop. If no movement or any other effects that modify visiblity have occured, don't check the array. Use a global variable like MovementOccured or something and set it to true if movement has occured or false if it hasn't then test to see if it is true before you check the array. This will improve the speed of your game greatly.
Better yet, don't use the scan array method at all. Just hide the appropriate plain when you move your character. This will save you even more work.
If you have any questions or feel I left something out just post. I'll try to respond when I can but I don't normally frequent this board. I'll check back for the next few days or so, but after that I probably won't be around if you haven't posted anything by then.