Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Visibility test.  (Read 1359 times)
0 Members and 1 Guest are viewing this topic.
Offline trollwarrior1
« Posted 2014-04-07 05:50:11 »

I need to do some visibility test to implement node based path finding. I don't know the exact name of it, but the idea I have in mind is this.

* Developer places movement nodes around the map by hand, in a certain manner so that every node can see at least one another node;
* When doing movement, check if destination point is visible. If it is, just walk to it in a straight line;
* If it isn't do some kind of node based pathfinding algorithm and work out shortest node path to destination point, or something like that..

One big problem I can see incoming is checking if the node is visible. I have node idea how to do it properly. Here is a simple illustration showing what I want to accomplish if you don't understand..

On one of my previous games I implement vision by doing something like this:
* Pick a starting point and destination point. Compute x,y increments so each increment is of specific length, lets say increment length = 1;
* Add those increment values to starting position, until starting position is equal to destination position;
* After each increment check if current position on the level is a visible point. If not, the path is not visible.

I guess this is called ray casting or something like that. The problem I see coming with this already is that it would be reallllyyyyyyyy slow if I computed visibility check many times. Are there better ways to compute visibility, or should I also calculate which nodes are visible by a certain node before the game begins so that each nodes know which nodes it can see, since those nodes wouldn't change positions.
Offline ctomni231

JGO Wizard

Medals: 99
Projects: 1
Exp: 7 years

Not a glitch. Just have a lil' pixelexia...

« Reply #1 - Posted 2014-04-07 05:52:23 »

There is using A*. You can set each node to the corner of each object and use A* to check for the path around those nodes. It is a very flexible algorithm not just used for tile based systems.

Offline trollwarrior1
« Reply #2 - Posted 2014-04-07 06:02:44 »

Hmm I found this page somewhere. I think I will try to implement path smoothing from this page first, since it is far less work, because I already have A* implemented in my game.

Lets just come back to the original question which is what is the best way to do visibility test (is it called ray casting?).
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven

« JGO Overlord »

Medals: 1340
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #3 - Posted 2014-04-07 06:33:25 »

Write a line-line intersection function first. Then intersect your line-of-sight with the 4 lines comprising the edges of your rectangle.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline trollwarrior1
« Reply #4 - Posted 2014-04-07 07:24:51 »

Thanks I'm trying to write line intersection method.

I'm reading this wiki page, and I don't seem to understand one thing.

I'm kinda stuck at calculating proper intersection point. I'm kinda confused. The page says that we can find the intersection point by using determinants. The thing I don't get is why is intersection point's P coordinates x,y found by the same 'method'. Is it me or is intersection point P.y always the same as X? The formula to calculate P.y is the same as the formula to calculate P.x

Is this wiki page's fault, or am I missing something here?

Ignore the post I just made Cheesy I can't read, it so seems.
Pages: [1]
  ignore  |  Print  

EgonOlsen (44 views)
2018-06-10 19:43:48

EgonOlsen (24 views)
2018-06-10 19:43:44

EgonOlsen (46 views)
2018-06-10 19:43:20

DesertCoockie (200 views)
2018-05-13 18:23:11

nelsongames (126 views)
2018-04-24 18:15:36

nelsongames (125 views)
2018-04-24 18:14:32

ivj94 (866 views)
2018-03-24 14:47:39

ivj94 (127 views)
2018-03-24 14:46:31

ivj94 (770 views)
2018-03-24 14:43:53

Solater (142 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!