polygone
 Joined: Mar 2009
Posts: 794
|
 |
Posted on: February 28, 2011, 10:47:52 AM |
|
|
|
void move_wrap(bool hor, bool vert, double margin) { enigma::object_planar* const inst = ((enigma::object_planar*)enigma::instance_event_iterator->inst); if (hor) { const double wdis = room_width + margin*2; if (inst->x < -margin) { inst->x += wdis*ceil(((-margin) - inst->x)/wdis); } if (inst->x > room_width + margin) { inst->x -= wdis*ceil((inst->x - (room_width + margin))/wdis); } } if (vert) { const double hdis = room_height + margin*2; if (inst->y < -margin) { inst->y += hdis*ceil(((-margin) - inst->y)/hdis); } if (inst->y > room_height + margin) { inst->y -= hdis*ceil((inst->y - (room_height + margin))/hdis); } } }
|
|
|
|
Post made March 01, 2011, 02:47:03 PM was deleted at the author's request.
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #2 Posted on: March 01, 2011, 06:32:01 PM |
|
|
Quote from: Fede-lasse on March 01, 2011, 02:47:03 PM I. Did. This. One. FFS.
And more efficiently.
//int move_wrap(double hor,double vert,double margin) int move_wrap(double hor,double vert,double margin) { //not sure whether two IFs are faster than one big calculation in a single IF if (hor) { if (X < -margin || X > room_width+margin) { X = -(X-room_width); } } if (vert) { if (Y < -margin || Y > room_height+margin) { Y = -(Y-room_height); } } return (int)0; }
Since Josh fails to remember or care (<_<), I post this code.
a) That's not more efficient, it's different. And by being different it does not behave how the function behaves in GM. I don't just stick shit into code randomly  b) It's not written properly. Wtf are X and Y going to do?
|
|
|
RetroX
Master of all things Linux
 Joined: Apr 2008
Posts: 1,055
|
 |
Reply #3 Posted on: March 02, 2011, 03:44:47 AM |
|
|
|
Dear Fede-lasse,
Please do not complain that you have already done functions when you posted them months ago and we don't know where they are.
If you wish to have them actually looked at, please post them or point out where you posted them.
Sincerely, RetroX and everyone else.
P.S.: (int)0 is redundant because 0 is an int, and it would have been auto-casted either way.
|
|
|
|
Post made March 06, 2011, 08:05:42 PM was deleted at the author's request.
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #5 Posted on: March 06, 2011, 08:10:19 PM |
|
|
|
I never said it was less efficient, I said it was different. My code is 'less efficient' for a reason: because it works better.
|
|
|
|
Post made March 08, 2011, 08:54:57 AM was deleted at the author's request.
|
polygone
 Joined: Mar 2009
Posts: 794
|
 |
Reply #7 Posted on: March 08, 2011, 10:34:48 AM |
|
|
Quote from: Fede-lasse on March 08, 2011, 08:54:57 AM My version mimics the behaviour in GM, so I don't see the problem.
It doesn't mimic the behaviour in GM. Try moving an instance's x position 3*room_width and see if it wraps correctly using your code. If you actually read what code I use you will see I am specifically catering for this. Though actually my code doesn't completely mimic GM's, it in fact works better. I believe GM's code goes more like this: if (hor) { const double wdis = room_width + margin*2; if (inst->x > room_width + margin) { inst->x -= wdis*ceil((inst->x - (room_width + margin))/wdis); } else if (inst->x < -margin) { inst->x += wdis*ceil(((-margin) - inst->x)/wdis); } } if (vert) { const double hdis = room_height + margin*2; if (inst->y > room_height + margin) { inst->y -= hdis*ceil((inst->y - (room_height + margin))/hdis); } else if (inst->y < -margin) { inst->y += hdis*ceil(((-margin) - inst->y)/hdis); }This means that when the margin is set to a high negative value, ie more than half the room_width or something and both if statements are true it doesn't actually wrap and just moves the instance continuously left/up. By leaving the else out it wraps correctly mirrored which is a better way to handle things.
|
|
|
|
|
|
Post made March 09, 2011, 02:14:31 PM was deleted at the author's request.
|
RetroX
Master of all things Linux
 Joined: Apr 2008
Posts: 1,055
|
 |
Reply #10 Posted on: March 09, 2011, 11:51:19 PM |
|
|
Quote from: Fede-lasse on March 09, 2011, 02:14:31 PM
Quote from: RetroX on March 08, 2011, 09:09:56 PM
Quote from: Fede-lasse on March 08, 2011, 08:54:57 AM Also @Retro, I once sent Josh all the functions I had done. He probably forgot about them.
Josh != everyone else
Quote from: RetroX on March 02, 2011, 03:44:47 AMSincerely, RetroX and everyone else. Yes, thank you for enforcing my point. Please post them if you want them to be reviewed by everyone else.
|
|
|
|
Post made March 10, 2011, 04:40:42 PM was deleted at the author's request.
|
RetroX
Master of all things Linux
 Joined: Apr 2008
Posts: 1,055
|
 |
Reply #12 Posted on: March 11, 2011, 01:50:11 AM |
|
|
Quote from: Fede-lasse on March 10, 2011, 04:40:42 PM
Quote from: RetroX on March 09, 2011, 11:51:19 PM
Quote from: Fede-lasse on March 09, 2011, 02:14:31 PM
Quote from: RetroX on March 08, 2011, 09:09:56 PM
Quote from: Fede-lasse on March 08, 2011, 08:54:57 AM Also @Retro, I once sent Josh all the functions I had done. He probably forgot about them.
Josh != everyone else
Quote from: RetroX on March 02, 2011, 03:44:47 AMSincerely, RetroX and everyone else. Yes, thank you for enforcing my point. Please post them if you want them to be reviewed by everyone else.
I didn't reinforce your point, silly. Your own post was against the point that you made. By saying "sincerely RetroX and everyone else," you say that no one but me knows of them. That is not true.
Either way, polygone seems more interested than I am in coding these functions.
Yes, and only you and Josh know. Quote from: RetroX on March 08, 2011, 09:09:56 PM Josh != everyone else
|
|
|
|
Post made March 11, 2011, 10:18:24 AM was deleted at the author's request.
|
Josh @ Dreamland
Prince of all Goldfish
 Joined: Feb 2008
Posts: 2,950
|
 |
Reply #14 Posted on: March 11, 2011, 02:01:49 PM |
|
|
|
... His point is, if you have functions, post them here. I'm not going to do anything with them, and no one else gives a shit about your functions unless they're posted here. So post them, or drop them.
|
|
|
|