• Print

Author Topic: Tile-base line-of-sight concepts, need some help  (Read 187 times)

caligari87

  • Newbie
  • *
  • Posts: 8
Tile-base line-of-sight concepts, need some help
« on: February 26, 2013, 12:18:38 PM »
I'm currently using beam/raycasting for my roguelike project, and I really like the intuitive simplicity of it. It's probably 15-20 lines of code in QB64, and easy to understand. For some reason though, I keep getting hung up on the artifacts and imprecision (see this PDF for some more examples)

I'd really like to improve it, and to that end I've been looking at restrictive precise angle shadowcasting. My problem is that I'm not really "getting" how to code it, and the source code is in languages I don't understand. Shadowcasting in general seems a lot more complex than raycasting, and I want to keep things as simple as possible.

Ideally, would it be possible to somehow "port" the concepts from RPAS to beam/raycasting? I'm still a bit of a programming novice and not sure how to start designing my own version. If someone here can give me a few tips, it would be greatly appreciated.

8)

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Tile-base line-of-sight concepts, need some help
« Reply #1 on: February 26, 2013, 12:40:06 PM »
I wish I knew what you are talking about ::)
No acronyms and jargon, please.
I'd like to try to help you.

Is the attached prog the kind of thing you mean?

(Warning, it may not be QB64 so recent dictates may prevent us discussing it)

caligari87

  • Newbie
  • *
  • Posts: 8
Re: Tile-base line-of-sight concepts, need some help
« Reply #2 on: February 26, 2013, 01:10:05 PM »
Sorry, let me clarify. I'm working on a "roguelike", or top-down tile-based game. I want to create accurate line-of-sight calculations between the player's square and the rest of the squares on the map, making visible squares lit and non-visible squares dark.

Currently, I'm tracing along "beams" from the player's position in a 360-degree circle until the beam hits something solid (raytracing). It's relatively simple and I've made it fast, but the problem is that while raycasting is fine for pixel-level operations, it's fairly inaccurate for a tile-based environment. Wrong squares are being calculated as "visible" when they intuitively would not be.

The article I linked provides a more accurate, but more complex method (called restrictive precise-angle shadowcasting), and I was hoping someone could help interpret it and give me some tips on how to actually code it, since I can't understand any of the provided source code and I'm still a relative newbie at algorithms

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Tile-base line-of-sight concepts, need some help
« Reply #3 on: February 26, 2013, 01:22:50 PM »
Thanks for explaining so well.
I don't know enough to help you.  I am better at maths and physics than programming.
But your time is not wasted explaining for the chance of getting help here is now much increased

Billbo

  • Sr. Member
  • ****
  • Posts: 286
    • Email
Re: Tile-base line-of-sight concepts, need some help
« Reply #4 on: February 26, 2013, 03:16:51 PM »
Mrwhy,

AVG indicates 'May be infected by unknown virus Win32/DH.C954E4D4{bQ}' for tiledfloor.exe on download. Could you check it out?

Bill
« Last Edit: February 26, 2013, 03:21:58 PM by Billbo »

SkyCharger001

  • Hero Member
  • *****
  • Posts: 1594
Re: Tile-base line-of-sight concepts, need some help
« Reply #5 on: February 26, 2013, 05:37:33 PM »
just an idea:
you could set up an array indicating which tiles depend on which.
this will require a distance sorted array to truly allow both speedy and accurate rendering.
EG:
Code: [Select]
IF tile(center+atile(A).parentA) = floor OR tile(center+atile(A).parentB) = floor OR tile(center+atile(A).parentC) = floor THEN checktile(tile(center+atile(A).position))
CONCEPT: DO NOT USE AS IS.

Klangaroo

  • Full Member
  • ***
  • Posts: 202
  • Video Game Dad
    • ManFightDragon Indie Dev Blog
Re: Tile-base line-of-sight concepts, need some help
« Reply #6 on: March 04, 2013, 10:01:02 PM »
My game has lots of cool line-of-sight stuff and it's all tile based. You can see lots of it happening here.
http://www.youtube.com/watch?v=Ks1vEX8PYQo
if you want help with logic, maybe add me on skype. My name is manfightdragon.
I make video games over at Man Fight Dragon and I have Twitter so do whatever really.

Billbo

  • Sr. Member
  • ****
  • Posts: 286
    • Email
Re: Tile-base line-of-sight concepts, need some help
« Reply #7 on: March 05, 2013, 07:42:32 AM »
Mrwhy,

Why have you not answered my reply to a possible virus?

Bill

Mrwhy

  • Hero Member
  • *****
  • Posts: 2890
  • My Dad called me Mr Why when I was 5.
    • Email
Re: Tile-base line-of-sight concepts, need some help
« Reply #8 on: March 05, 2013, 12:30:25 PM »
Because it is "off topic" and turned out to be no help to the questioner.
Because there is nothing I can do about AVG (software not writ by me) on YOUR machine (unknown to me) "Thinking that it MIIGHT be infected by an UNKNOWN virus" (this covers EVERY bit of software!)

So please don't be upset - I have the highest opinion of you and your concern that others might get hurt by unknown viruses.

  • Print