Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-16-2011, 02:26 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
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?
__________________

Intelligence without ambition is like a bird without wings.

Reply With Quote
  #2  
Old 07-17-2011, 01:32 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote
  #3  
Old 07-17-2011, 02:14 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
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.
Reply With Quote
  #4  
Old 07-17-2011, 02:28 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by WhiteDragon View Post
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!
__________________
Quote:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:22 PM.


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