@Socks looking real slick - there's a guy making a nice looking isometric game called Quonie - I think the illustrator has captured a new take on the Head over Heals vibe here - http://wiki.xxiivv.com/Oquonie - it's in dev but looking really nice. He does some really weird but smart stuff - I would even say obtuse really as it is quite mysterious in it's own ambiguity. http://wiki.xxiivv.com/Hiversaires is stunning looking - a puzzler that has no real direction but for exploration. I really like the clean look and Japanese influence in the work. I think once I get my current 3 projects done, I will look in to either an isomteric game or point and click adventure. We shall, see, anyway, back to game dev Cheers, M@

tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,947

@Socks, you need to finish Cubert. Can't wait to see what you do with this...

@GS_Master -- Thanks for sharing with the GS community! These two demos will come in very handy.

tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,947

edited February 2014

Detect attribute value change

This will log a debugging statement when the value of an integer changes within a rule condition that was already true. For example, if the condition is When attribute game.count > 5, it will trigger when game.count is 6, and 7, and 8, etc.

Ever wanted to detect if the mouse is inside an odd shaped polygon? It uses a math trick to find if a point is to the right of a line segment. (If the point is to the right of all the line segments of a polygon, then the point must be inside the polygon.) In this example, the point is the tip of the cursor. (But it could be any point.)

The expressions just look difficult because the table functions take up so much room. Whats going on is pretty straight forward. I should have documented it better. For starters, the expression is just testing if a point is left or right of a given line segment. (Its a logical truth that if a group of lines are all connected to form a simple polygon -- when a point is to the right of each line, then the point must be inside the polygon formed by the lines.)

Any formula that tells you if a point is left or right of a line will work for this trick. (There are probably other expressions that do the same thing.)

Lets say mx,my stands for the mouse's x and y coordinates, and x1,y1 stands for the point where a line begins, and x2,y2 stands for a point where the line ends. The expression would look like this: (my-y1)*(x2-x1)-(mx-x1)*(y2-y1)

If the answer is less than 0 then the point is to the left of the line. If the answer is greater than 0 then the point is on the right of the line.

So here are the six expressions for finding if the mouse is within a six sided figure: Line1: (my-y1)*(x2-x1)-(mx-x1)*(y2-y1) Line2: (my-y2)*(x3-x2)-(mx-x2)*(y3-y2) Line3: (my-y3)*(x4-x3)-(mx-x3)*(y4-y3) Line4: (my-y4)*(x5-x4)-(mx-x4)*(y5-y4) Line5: (my-y5)*(x6-x5)-(mx-x5)*(y6-y5) Line6: (my-y6)*(x1-x6)-(mx-x6)*(y1-y6)

See the pattern? It makes it real simple to create a test for anything from a three sided to a 359 sided polygon. You just need to make the last line hook back up to the first line (as in Line6).

Never thought I would need duel monitors to see a line of code, very interesting I'm gonna play with that once my head stops hurting from looking at it.

tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,947

@RThurman I think I get it but I'm stuck on this idea of a point being "right of a line." To me, some points outside of a polygon are to the left of a line segment and some are to the right of a line segment. I'm not following how a point would be to the right of all line segment if it's inside the polygon.

@RThurman I think I get it but I'm stuck on this idea of a point being "right of a line." To me, some points outside of a polygon are to the left of a line segment and some are to the right of a line segment. I'm not following how a point would be to the right of all line segment if it's inside the polygon.

Hmm... Imagine you are standing at the beginning of a line and looking straight down the line towards its end. Your right eye would be on the right side of the line, and the left eye would be on the left side of the line.

tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,947

edited February 2014

@RThurman But here's the thing... I took the polygon from your demo and extended two of the lines that define the polygon. Ignore the thick black square as it was the scene background. If I plot a point in green inside of the polygon, it looks to be left ("southwest") of line #1 and right ("northeast") of line #2 if I were to draw perpendicular lines (not shown on my sketch) from those two lines to the interior point .

Hmm.... I didn't realize just how bad my explanations are. Does the following figure help? It shows the line numbers and the coordinates at the beginning of each line segment.

tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,947

Well, and I had numbered the lines in my sketch without thinking about the fact that you had assigned the lines numbers in your demo. I just arbitrarily picked #1 and #2 because I drew two lines.

Okay, in your drawing above, let's say #2 was actually parallel to #5. If I pick a point in the interior of the polygon (say 0,40), it would appear to me that the point is to the right of #5 and to the left of #2.

when a point is to the right of each line, then the point must be inside the polygon formed by the lines

I think I must be using different definitions for "right" and "left." Or is it because I'm thinking in terms of line segments and that logical truth depends on lines? I appreciate you trying to explain it..... I'm sure we'll get there!

tatiangMember, Sous Chef, PRO, Senior Sous-ChefPosts: 11,947

Oh wait! @RThurman, is it as if I'm walking along the perimeter of the polygon in a clockwise manner and checking to see if the point is to the right of me? If it's that, then it makes sense. But then of course if I walk counter-clockwise the point would always be to the left of me. Hmm...

Thanks @RThurman for the "Odd Shape Collision" example. I'm mucking around with an isometric board and this is perfect for selecting individual isometric tiles without selecting the other tiles that the images overlap.

@RThurman - Sorry, you lost me at "just look difficult". Nevertheless, cool stuff! - Thomas

Sorry about that! I bet someday you will sit straight up in chair and yell "Eurika -- I have found it"

Oh wait! @RThurman, is it as if I'm walking along the perimeter of the polygon in a clockwise manner and checking to see if the point is to the right of me? If it's that, then it makes sense. But then of course if I walk counter-clockwise the point would always be to the left of me. Hmm...

Yes!!! and Yes!!!

My head hurts. b-(

Sorry! The nice thing about this is -- all you have to do is put in the coordinates in the table and the rest just works!

Thanks @RThurman for the "Odd Shape Collision" example. I'm mucking around with an isometric board and this is perfect for selecting individual isometric tiles without selecting the other tiles that the images overlap.

@Socks -- Thanks! It is genius. But I can't take credit for it. It is a relatively common way to determine if a point is within a simple polygon. There are other methods, but this one seemed fairly doable in GameSalad.

## Comments

12,822Patterned fades as an alternative to a normal fade to black.

https://www.mediafire.com/?4d98gc1q2lb9rap

12,822I've got an abandoned isometric GS game project I need to get back to at some stage:

Not seen those before, I'll definitely check them out.

85411,947New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User

12,822: )

5,690http://www.deepblueapps.com/gs-q-bert-template/

Its an old file but might be of use to some.

Darren.

15915911,947play it.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User

2,313✮ FREE templates at GSinvention ✮✮ Available for hire! support@gsinvention.com ✮2,86711,947Detect attribute value changeThis will log a debugging statement when the value of an integer changes within a rule condition that was already true. For example, if the condition is When attribute game.count > 5, it will trigger when game.count is 6, and 7, and 8, etc.

Click the square to increase the count.

New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User

2,867Collision Detection For Odd ShapesEver wanted to detect if the mouse is inside an odd shaped polygon? It uses a math trick to find if a point is to the right of a line segment. (If the point is to the right of all the line segments of a polygon, then the point must be inside the polygon.) In this example, the point is the tip of the cursor. (But it could be any point.)

It uses a table to list the endpoints of the line segments.

http://www.mediafire.com/download/n68v4ql9qeo0sxj/pointInPolyTableMoveableV2.zip

11,947Those expressions are not for the faint of heart. :P

By the way, thanks for the conditional logic examples a while back. I've made good use of them in my custom keyboard project.

2,867The expressions just look difficult because the table functions take up so much room. Whats going on is pretty straight forward. I should have documented it better. For starters, the expression is just testing if a point is left or right of a given line segment. (Its a logical truth that if a group of lines are all connected to form a simple polygon -- when a point is to the right of each line, then the point must be inside the polygon formed by the lines.)

Any formula that tells you if a point is left or right of a line will work for this trick. (There are probably other expressions that do the same thing.)

Lets say mx,my stands for the mouse's x and y coordinates, and x1,y1 stands for the point where a line begins, and x2,y2 stands for a point where the line ends. The expression would look like this: (my-y1)*(x2-x1)-(mx-x1)*(y2-y1)

If the answer is less than 0 then the point is to the left of the line. If the answer is greater than 0 then the point is on the right of the line.

So here are the six expressions for finding if the mouse is within a six sided figure:

Line1: (my-y1)*(x2-x1)-(mx-x1)*(y2-y1)

Line2: (my-y2)*(x3-x2)-(mx-x2)*(y3-y2)

Line3: (my-y3)*(x4-x3)-(mx-x3)*(y4-y3)

Line4: (my-y4)*(x5-x4)-(mx-x4)*(y5-y4)

Line5: (my-y5)*(x6-x5)-(mx-x5)*(y6-y5)

Line6: (my-y6)*(x1-x6)-(mx-x6)*(y1-y6)

See the pattern? It makes it real simple to create a test for anything from a three sided to a 359 sided polygon. You just need to make the last line hook back up to the first line (as in Line6).

TMI???

1,603Nevertheless, cool stuff!

- Thomas

1,764Never thought I would need duel monitors to see a line of code, very interesting I'm gonna play with that once my head stops hurting from looking at it.

11,9472,86711,9472,86711,947~X( ~:> X_X

2,86711,947Okay, in your drawing above, let's say #2 was actually parallel to #5. If I pick a point in the interior of the polygon (say 0,40), it would appear to me that the point is to the right of #5 and to the left of #2. I think I must be using different definitions for "right" and "left." Or is it because I'm thinking in terms of line segments and that logical truth depends on lines? I appreciate you trying to explain it..... I'm sure we'll get there!

11,9472,343Complete Guide to iOS Publishing{}Complete Guide to Mac Publishing1,893KevinCross.co.uk | Basic Game Mechanic Templates inc. Candy Crush / Bejewelled

Games On Arcade: MineScroller | Reflexio | Doodle Kicks

2,86712,822Genius !

2,867