Pages: 1 2 »
  Print  
Author Topic: collision_line and collision_rectangle are not working  (Read 4341 times)
Offline (Unknown gender) egofree
Posted on: June 19, 2013, 03:16:45 AM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
I would like to know if functions collision_line and collision_rectangle are implemented as they seem to return always true. I tested my code with GM8.1 and it works fine.
« Last Edit: June 19, 2013, 07:48:26 AM by egofree » Logged
Offline (Male) polygone
Reply #1 Posted on: June 19, 2013, 06:46:33 AM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
You need to check if the return is != noone
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) egofree
Reply #2 Posted on: June 19, 2013, 07:07:49 AM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
Thanks polygone, it's ok now !  (Y)
Logged
Offline (Unknown gender) egofree
Reply #3 Posted on: June 19, 2013, 07:11:44 AM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
I think the wiki page should be changed : http://enigma-dev.org/docs/Wiki/Collision_line, because it says the function returns a boolean. This is not the case.
« Last Edit: June 19, 2013, 07:16:43 AM by egofree » Logged
Offline (Male) Goombert
Reply #4 Posted on: June 19, 2013, 02:51:52 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
egofree it says that because ENIGMA returns differently for that than GM, ENIGMA returns what had collided, GM just returns true or false.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Male) polygone
Reply #5 Posted on: June 19, 2013, 03:43:52 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
egofree it says that because ENIGMA returns differently for that than GM, ENIGMA returns what had collided, GM just returns true or false.
No, GM returns the instance id also.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) TheExDeus
Reply #6 Posted on: June 19, 2013, 04:13:00 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Yes, GM returns the instance id, but it considers anything >0 as true, so it returns true on collision and false otherwise. ENIGMA considers ==0 as false, so <0 is also true. Which makes noone (which is -4 or something) to be true. That is why you have to check explicitly. I think there was a discussion about this, whether to keep it like this or create some overloads or something.
Logged
Offline (Unknown gender) egofree
Reply #7 Posted on: June 19, 2013, 04:56:01 PM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
I was looking for information about how testing collisions in a given region and i found the collision_rectangle function, which was perfect for me. But the info i found was for GM not ENIGMA. In my mind the GM functions are identical in ENIGMA. I feel the ENIGMA function collision_rectangle is fine, but it's dangerous right now for two reasons : 1) unfortunately, as GM is more famous right now than ENIGMA, people will very often find information on GM programming websites. This means they will probably try what they found on these websites with ENIGMA, and if the functions are not identical, they will be puzzled. This will be not be a good impression for new users. At first, i was sure it was a bug in ENIGMA. I was thinking : what a disappointment, the function doesn't work at all ! 2) If the functions are not identical, this means it will be break compatibility and it will be harder to import GM projects.
My feeling is that we should give collision_rectangle another name and keep the GML functions compatible with ENIGMA. If it is not the case, we should do it for very good reasons, and most of all document this. Somebody has corrected the wiki page for collision_rectangle today, but the page was wrong before. If some GM functions are not identical it should be displayed in the wiki and be visible to everybody.
« Last Edit: June 19, 2013, 05:10:04 PM by egofree » Logged
Offline (Male) polygone
Reply #8 Posted on: June 19, 2013, 05:12:53 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
The functions are the same, as me and ExDeus said.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Offline (Unknown gender) egofree
Reply #9 Posted on: June 19, 2013, 05:23:08 PM
Contributor
Joined: Jun 2013
Posts: 603

View Profile Email
The functions are the same, as me and ExDeus said.

Well, this morning i tried my code on GM 8.1 and ENIGMA and the result was different. I don't pretend to be an expert, but at least in some cases the result is not the same.
Logged
Offline (Male) Josh @ Dreamland
Reply #10 Posted on: June 19, 2013, 05:26:48 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2957

View Profile Email
In GM, a value of -4 is false, as are all other values less than 0.5. In ENIGMA, only a value of 0 is false.

I'm working on a new type which will hint to the compiler that negatives are to be considered false.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #11 Posted on: June 20, 2013, 01:10:02 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
Well, this morning i tried my code on GM 8.1 and ENIGMA and the result was different. I don't pretend to be an expert, but at least in some cases the result is not the same.
What poly is saying that the different result wasn't because of the function. The function is correct and works exactly like GM. The interpretation of the returned value is different. That means GM documentation also works in case for ENIGMA (dunno why it had wrong return type in ENIGMA wiki though).
« Last Edit: June 20, 2013, 01:11:40 AM by TheExDeus » Logged
Offline (Male) Josh @ Dreamland
Reply #12 Posted on: June 20, 2013, 06:28:23 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2957

View Profile Email
The wrong return type is because I told Robert to set up a bot to generate the pages in his new format, and he insisted that doing it by hand was better.
So every post-2010 modification to the function documentation on the Wiki was done by hand and is probably teeming with errors.

inb4 Robert saying "Everyone makes mistakes."
Bots don't make mistakes.
« Last Edit: June 20, 2013, 06:30:03 AM by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) DarkAceZ
Reply #13 Posted on: June 22, 2013, 06:11:16 PM

Member
Location: United States
Joined: Dec 2011
Posts: 75

View Profile
So when this new compiler happens I won't have to be spamming !=noone anymore?
And why is -4 so special?
Logged
My Goodness! Is it 4:30? I'm supposed to be having a back, sack and crack!

[edit]
Offline (Male) polygone
Reply #14 Posted on: June 22, 2013, 06:17:31 PM

Contributor
Location: England
Joined: Mar 2009
Posts: 803

View Profile
In this instance I think GM would have been better starting indexes at 1 and using 0 for noone.
Logged
I honestly don't know wtf I'm talking about but hopefully I can muddle my way through.
Pages: 1 2 »
  Print