Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Checking for polygon wall (https://forums.graalonline.com/forums/showthread.php?t=134263936)

iBeatz 07-16-2011 02:26 PM

Checking for polygon wall
 
I've been having an issue trying to do this for a while now, and I thought I'd ask here for a hand.
Okay, so I have these 7 variables:

PHP Code:

 this.game_height_b = (GraalControl.height/2)+150
 
this.char_top_x = (GraalControl.width/2);
 
this.char_top_y this.game_height_b 12;
 
this.char_left_x = (GraalControl.width/2)-12;
 
this.char_left_y this.game_height_b 2;
 
this.char_right_x = (GraalControl.width/2)+12;
 
this.char_right_y this.game_height_b 2

These control a moveable character, all except this.game_height_b.
Now, I also have a wall of small polygons all down the left side of my screen, each polygon with 4 coordinates, so it's basically a small wall of rectangles of different lengths.
What I would like to do is take each this.char x variable and try to see if it is less than the innermost polygon's x coordinate on each char's y coordinate.

(NOTE: These polygons are continually moving down the left side of my screen, so I have little way of knowing the index of each polygon as it is always changing.)
Any suggestions?

fowlplay4 07-17-2011 01:32 AM

You could do something like...

PHP Code:

if (this.char_x in |this.wall_xthis.wall_x this.wall_width| &&
    
this.char_y in |this.wall_ythis.wall_y this.wall_height|) {

    
// In Wall



You'd benefit more from searching 'polygon collision' and seeing how it's implemented in other programming/scripting languages and then port/adapt it to GS2.

WhiteDragon 07-17-2011 02:14 AM

I have some geometry stuff written which I could release, like
  • checking if a point is in a triangle;
  • checking if a point is in a polygon;
  • forming a convex polygon around a set of points (using the gift wrap algorithm); and
  • forming a bounding rectangle around a polygon.

However, I don't have a polygon-polygon intersection checker, though I could probably write one if multiple people think it'd be useful.

fowlplay4 07-17-2011 02:28 AM

Quote:

Originally Posted by WhiteDragon (Post 1659151)
I have some geometry stuff written which I could release, like
  • checking if a point is in a triangle;
  • checking if a point is in a polygon;
  • forming a convex polygon around a set of points (using the gift wrap algorithm); and
  • forming a bounding rectangle around a polygon.

You should!


All times are GMT +2. The time now is 06:34 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.