freezway
|
|
Posted on: September 13, 2010, 01:44:43 am |
|
|
Joined: Dec 2009
Posts: 220
|
What I mean by "extra returns" is there should be a vector or struct in memory that functions can write to as extra returns, so, for example collision functions could return not only the id but the x and y of the collision as well. This way it would remain completely backwards compatible with gm, but add a lot of functionality. This of course could be enabled our disabled at compile time so its only used when needed. Thoughts? Oh, and josh, if you like the idea, finish collisions first.
|
|
« Last Edit: September 13, 2010, 08:57:53 am by IsmAvatar »
|
Logged
|
if you drop a cat with buttered toast strapped to its back, which side lands down? joshdreamland: our languages are based on the idea that it's going to end up FUBAR /kick retep998
|
|
|
|
freezway
|
|
Reply #2 Posted on: September 13, 2010, 09:10:50 am |
|
|
Joined: Dec 2009
Posts: 220
|
So basically add pointers to the vars you want to change. I like it
|
|
|
Logged
|
if you drop a cat with buttered toast strapped to its back, which side lands down? joshdreamland: our languages are based on the idea that it's going to end up FUBAR /kick retep998
|
|
|
Josh @ Dreamland
|
|
Reply #3 Posted on: September 13, 2010, 09:25:54 am |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
struct collision_result { double x, y; }; collision_result collision_line_ext(x,y,x2,y2,obj);
...
collision_result xy = collision_line_ext(x,y,o.x,o.y,wall); x = xy.x; y = xy.y;
What luis was suggesting is passing x and y to be modified by reference. The problem with luis's idea is that now, the arguments MUST be double or var, they can't be int or anything or it'll throw a compile error.
|
|
|
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
|
|
|
|
Josh @ Dreamland
|
|
Reply #5 Posted on: September 13, 2010, 12:00:18 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Then the exe size would skyrocket if it was actually used with multiple types. If a function absolutely needs to take double&, then it should. But these solutions seem a little overcomplicated for a simple multivalue return.
|
|
|
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
|
|
|
|
Josh @ Dreamland
|
|
Reply #7 Posted on: September 13, 2010, 09:15:38 pm |
|
|
Prince of all Goldfish
Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Var has a overload for cast to double&, so that would be the more accommodating choice.
|
|
|
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
|
|
|
|
freezway
|
|
Reply #9 Posted on: September 14, 2010, 09:11:48 am |
|
|
Joined: Dec 2009
Posts: 220
|
This isn't the easier choice, but what about adding python like operators. Eg
id_of_collision, x_col, y_col = collision_line(arguments here)
|
|
|
Logged
|
if you drop a cat with buttered toast strapped to its back, which side lands down? joshdreamland: our languages are based on the idea that it's going to end up FUBAR /kick retep998
|
|
|
|
|
|
|
|
|