Jump to content
  • Advertisement

Archived

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

fireking

opacity (2d tile engine)

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


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

thanks alot!

--Fireking

Owner/Leader
Genetics 3rd Dimension Development

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!