#### Archived

This topic is now archived and is closed to further replies.

# opacity (2d tile engine)

This topic is 5936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am now at the point where I need to add Opacity to my 2d tile engine. What I mean by opacity is this. Each tile has a set of properties, such as blocked, which determines if you can walk on that tile. Opacity is a property that will tell you if you can see past that tile. If a tile has the property opacity, you will be able to see that tile, but you wont be able to see whats behind that tile. I think this is commonly refered to as Line of Sight Algorithm. I need to know how to do this in the most simplistic way as possible, and the most effecient way as possible. Example:
###########
###########
###########
###########
###OOOOO###
###O###O###
###O###O###
###OO#OO###
###########
######P####
###########

P=Player
#=Ground
O=Wall

First of all, which tiles would you see? And secondly, how would you figure that out? Thanks, --Fireking Owner/Leader Genetics 3rd Dimension Development

##### Share on other sites
My first reaction was to tell you to look up Ray Tracing in Google, but when I did so myself it came up with a bunch of advanced radiosity articles (not good for beginners!).

Basically, you have the player's FOV (Field of View). It is a certain angle wide, say 60°. What you do is trace a line at each intermediary angle (so at 0°, 1°, 2°, etc.) in the FOV until you hit a wall. In that process, you will pass through many ground tiles in your quest to reach a wall. Every ground tile you pass over is visible. And in addition, every wall tile you hit is visible. Everything else is not visible.

I will leave finding how to trace this line up to you Since your map uses square tiles, tracing a line at a certain angle (and thus a defined slope) and finding which tiles it intersects should be a nice challenge - not too difficult, but just enough to get you thinking, which is what we want!

[edited by - Zipster on September 16, 2002 3:42:45 AM]

##### Share on other sites
By the way, if you want to get some good answers to 2D-style questions, I'd recommend posting your questions at the 2D-Now forums [http://2dnow.zenzer.net]. There are some pretty experienced 2D game developers there, most of whom don't read this forum reguarly.

- Air

[edited by - Air on September 16, 2002 5:26:05 AM]

##### Share on other sites
Also, Amit''s Game Programming has a bunch of interesting reading on LOS:

http://www-cs-students.stanford.edu/~amitp/gameprog.html

2DNow - for the 2D game developer in you

##### Share on other sites
thanks guys, ive been looking for a forum specifically for 2d tile engines and stuff

thanks alot!

--Fireking

Genetics 3rd Dimension Development

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
14
5. 5

• 9
• 13
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633744
• Total Posts
3013662
×