This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 »
181
Proposals / Re: Object member functons
« on: January 07, 2011, 05:21:05 pm »
That's why I'm saying that it should be made as an option. :V
Use member functions like regular variables. Then, add a configuration option to make both variables and functions operate on all objects.
Use member functions like regular variables. Then, add a configuration option to make both variables and functions operate on all objects.
182
Proposals / Re: Object member functons
« on: January 07, 2011, 05:03:13 pm »
Yeah, that would make sense. Still think that it would be a good idea to have an option for all objects, though.
183
Function Peer Review / Re: move_towards_point
« on: January 07, 2011, 04:10:44 pm »
In addition, motion_add:
Untested, but it's mathematically sound.
Code: (C++) [Select]
void motion_add(double newdir, double newspd) {
enigma::object_planar* const inst = ((enigma::object_planar*)enigma::instance_event_iterator->inst);
inst->hspeed.rval.d += newspd * cos(newdir);
inst->vspeed.rval.d += newspd * sin(newdir);
inst->direction.rval.d = point_direction(0, 0, inst->hspeed.rval.d, inst->vspeed.rval.d);
inst->speed.rval.d = abs(hypot(inst->hspeed.rval.d, inst->vspeed.rval.d));
}
Untested, but it's mathematically sound.
184
Proposals / Re: Object member functons
« on: January 07, 2011, 04:05:33 pm »Given this suggestion, how would this be interpreted?Code: (EDL) [Select]a = obj.f1();
Code: [Select]
global var ______ENIGMATEMP;
with (obj)
{
______ENIGMATEMP = f1();
}
a = ______ENIGMATEMP;
By "parse," I didn't mean textually. I meant to replicate its usage.
All that with() does is change enigma::instance_event_iter to the current object. a = obj.f1() simply would mean change the event iter, however, operate on a local variable.
185
Proposals / Object member functons
« on: January 06, 2011, 07:50:50 pm »
It would be really cool if, somehow, ENIGMA would be able to do something like:
Basically, calling a function as a member function would merely mean applying it as a with() statement with only one line. And there might be optimisations for it, too, for example:
Granted, you could abuse this and do things like obj.draw_set_color(), but it's still a nicer syntax (and you can do that in with(), too). Obviously, with() would have to be used for ifs and loops, but for simple functions, writing it out this way just looks nicer.
I dunno how doable that this would be, but I think that it would be a really nice thing to have.
Code: [Select]
obj.instance_destroy();
instead of:Code: [Select]
with(obj)
{
instance_destroy();
}
Basically, calling a function as a member function would merely mean applying it as a with() statement with only one line. And there might be optimisations for it, too, for example:
Code: [Select]
obj.f1();
obj.f2();
would be parsed to:Code: [Select]
with (obj)
{
f1();
f2();
}
Granted, you could abuse this and do things like obj.draw_set_color(), but it's still a nicer syntax (and you can do that in with(), too). Obviously, with() would have to be used for ifs and loops, but for simple functions, writing it out this way just looks nicer.
I dunno how doable that this would be, but I think that it would be a really nice thing to have.
186
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 04, 2011, 10:04:46 pm »
It actually probably does what you described in GM. But it makes sense that it should be this way. Someone should test it
If it works the other way in GM, I'd say have the crappy GM method, but also have the correct method.
If it works the other way in GM, I'd say have the crappy GM method, but also have the correct method.
187
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 04, 2011, 04:34:25 pm »
One random thing to mention, but:
In this case, the box should move-collide with the corner exactly. If it's not a good method, it won't.
In this case, the box should move-collide with the corner exactly. If it's not a good method, it won't.
188
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 02, 2011, 09:56:05 pm »I know the point is to make it more efficient, but without doing an inefficient loop it's not exact going to be doing it's job.It can be done. It's just that I'm doing it incorrectly.
189
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 02, 2011, 08:57:14 pm »I would suggest writing a more precise method using place_meeting.The point of this was to avoid using a massive, inefficient for loop. (that)
I've basically given up at this point, so, anyone else can either fix mine or toss it and make a new one.
190
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 02, 2011, 07:41:55 pm »
lol:
Code: [Select]
#define EPSILON 1e-14
int move_contact(double direction, double max_distance, int object, bool solid_only)
{
enigma::object_collisions* inst1 = ((enigma::object_collisions*)enigma::instance_event_iterator->inst);
const double left1 = inst1->x + inst1->bbox_left, top1 = inst1->y + inst1->bbox_top,
right1 = inst1->x + inst1->bbox_right, bottom1 = inst1->y + inst1->bbox_bottom;
double max_x = lengthdir_x(max_distance, direction);
double max_y = lengthdir_y(max_distance, direction);
double moving_left1 = left1 + max_x, moving_top1 = top1 + max_y,
moving_right1 = right1 + max_x, moving_bottom1 = bottom1 + max_y;
for (enigma::inst_iter *it = enigma::fetch_inst_iter_by_int(all); it != NULL; it = it->next)
{
const enigma::object_collisions* inst2 = (enigma::object_collisions*)it->inst;
if (inst2->id == inst1->id || solid_only && !inst2->solid) continue;
const double left2 = inst2->x + inst2->bbox_left, top2 = inst2->y + inst2->bbox_top,
right2 = inst2->x + inst2->bbox_right, bottom2 = inst2->y + inst2->bbox_bottom;
if (top1 < bottom2 && bottom1 > top2)
{
if (max_x > EPSILON)
{
if (left2 < moving_right1)
{
max_x = left2 - moving_right1;
moving_left1 = left1 + max_x;
moving_right1 = right1 + max_x;
}
}
else if (max_x < -EPSILON)
{
if (right2 > moving_left1)
{
max_x = right2 - moving_left1;
moving_left1 = left1 + max_x;
moving_right1 = right1 + max_x;
}
}
}
if (left1 < right2 && right1 > left2)
{
if (max_y > EPSILON)
{
if (top2 < moving_top1)
{
max_y = top2 - moving_bottom1;
moving_top1 = top1 + max_y;
moving_bottom1 = bottom1 + max_y;
}
}
else if (max_y < -EPSILON)
{
if (bottom2 > moving_bottom1)
{
max_y = bottom2 - moving_top1;
moving_top1 = top1 + max_y;
moving_bottom1 = bottom1 + max_y;
}
}
}
}
inst1->x += max_x;
inst1->y += max_y;
return 0;
}
inline int move_contact_solid(double direction, double speed) { return move_contact(direction, speed, all, true); }
inline int move_contact_all(double direction, double speed) { return move_contact(direction, speed, all, false); }
inline int move_contact_object(double direction, double speed, int object) { return move_contact(direction, speed, object, false); }
still doesn't work.
191
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 02, 2011, 06:50:32 pm »Code: [Select]
#define EPSILON 1e-14
int move_contact(double direction, double max_distance, int object, bool solid_only)
{
enigma::object_collisions* inst1 = ((enigma::object_collisions*)enigma::instance_event_iterator->inst);
const double left1 = inst1->x + inst1->bbox_left, top1 = inst1->x + inst1->bbox_top,
right1 = inst1->x + inst1->bbox_right, bottom1 = inst1->x + inst1->bbox_bottom;
double max_x = lengthdir_x(max_distance, direction);
double max_y = lengthdir_y(max_distance, direction);
double moving_left1 = left1 + max_x, moving_top1 = top1 + max_y,
moving_right1 = right1 + max_x, moving_bottom1 = bottom1 + max_y;
for (enigma::inst_iter *it = enigma::fetch_inst_iter_by_int(all); it != NULL; it = it->next)
{
const enigma::object_collisions* inst2 = (enigma::object_collisions*)it->inst;
if (inst2->id == inst1->id || solid_only && !inst2->solid) continue;
const double left2 = inst2->x + inst2->bbox_left, top2 = inst2->x + inst2->bbox_top,
right2 = inst2->x + inst2->bbox_right, bottom2 = inst2->x + inst2->bbox_bottom;
if (top1 < bottom2 && bottom1 > top2)
{
if (max_x > EPSILON)
{
if (left2 < moving_right1)
{
max_x = left2 - moving_right1;
moving_left1 = left1 + max_x;
moving_right1 = right1 + max_x;
}
}
else if (max_x < -EPSILON)
{
if (right2 > moving_left1)
{
max_x = right2 - moving_left1;
moving_left1 = left1 + max_x;
moving_right1 = right1 + max_x;
}
}
}
if (left1 < right2 && right1 > left2)
{
if (max_y > EPSILON)
{
if (top2 < moving_top1)
{
max_y = top2 - moving_bottom1;
moving_top1 = top1 + max_y;
moving_bottom1 = bottom1 + max_y;
}
}
else if (max_y < -EPSILON)
{
if (bottom2 > moving_bottom1)
{
max_y = bottom2 - moving_top1;
moving_top1 = top1 + max_y;
moving_bottom1 = bottom1 + max_y;
}
}
}
}
inst1->x += max_x;
inst1->y += max_y;
return 0;
}
inline int move_contact_solid(double direction, double speed) { return move_contact(direction, speed, all, true); }
inline int move_contact_all(double direction, double speed) { return move_contact(direction, speed, all, false); }
inline int move_contact_object(double direction, double speed, int object) { return move_contact(direction, speed, object, false); }
Now, I don't know why this is spazzing all over the place. Will figure out later, or someone else can do it.
192
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 01, 2011, 09:33:15 pm »Code: [Select]
#define EPSILON 1e-14
int move_contact(double direction, double max_distance, bool solid_only)
{
enigma::object_collisions* inst1 = ((enigma::object_collisions*)enigma::instance_event_iterator->inst);
const double left1 = inst1->x + inst1->bbox_left, top1 = inst1->y + inst1->bbox_top,
right1 = inst1->x + inst1->bbox_right, bottom1 = inst1->y + inst1->bbox_bottom;
double max_x = lengthdir_x(max_distance, direction);
double max_y = lengthdir_y(max_distance, direction);
double moving_x = inst1->x + max_x;
double moving_y = inst1->y + max_y;
for (enigma::inst_iter *it = enigma::fetch_inst_iter_by_int(all); it != NULL; it = it->next)
{
const enigma::object_collisions* inst2 = (enigma::object_collisions*)it->inst;
if (inst2->id == inst1->id || solid_only && !inst2->solid) continue;
const double left2 = inst2->x + inst2->bbox_left, top2 = inst2->y + inst2->bbox_top,
right2 = inst2->x + inst2->bbox_right, bottom2 = inst2->y + inst2->bbox_bottom;
const double x_moving = inst1->x + max_x;
if (inst1->y < bottom2 && inst1->y > top2)
{
if (max_x > EPSILON)
{
if (left2 < moving_x)
{
max_x = left2 - inst1->x;
moving_x = inst1->x + max_x;
}
}
else if (max_x < -EPSILON)
{
if (right2 > moving_x)
{
max_x = right2 - inst1->x;
moving_x = inst1->x + max_x;
}
}
}
if (inst1->x < right2 && inst1->x > left2)
{
if (max_y > EPSILON)
{
if (top2 < moving_y)
{
max_y = top2 - inst1->y;
moving_y = inst1->y + max_y;
}
}
else if (max_y < -EPSILON)
{
if (bottom2 > moving_y)
{
max_y = bottom2 - inst1->y;
moving_y = inst1->y + max_y;
}
}
}
}
inst1->x = moving_x;
inst1->y = moving_y;
return 0;
}
inline int move_contact_solid(double direction, double speed) { return move_contact(direction, speed, true); }
inline int move_contact_all(double direction, double speed) { return move_contact(direction, speed, false); }
I know why this doesn't work, but I'm working on something else atm. Will fix later; bug me on the IRC if I don't.
193
Function Peer Review / Re: move_contact functions optimised for bbox
« on: January 01, 2011, 07:27:59 pm »
Wow, I can't get this to work.
Here's my code, and if anyone wants to see if they can fix it, go ahead:
Here's my code, and if anyone wants to see if they can fix it, go ahead:
Code: [Select]
#define EPSILON 1e-14
int move_contact(double direction, double max_distance, bool solid_only)
{
enigma::object_collisions* inst1 = ((enigma::object_collisions*)enigma::instance_event_iterator->inst);
const double left1 = inst1->x + inst1->bbox_left, top1 = inst1->y + inst1->bbox_top,
right1 = inst1->x + inst1->bbox_right, bottom1 = inst1->y + inst1->bbox_bottom;
double max_x = lengthdir_x(max_distance, direction);
double max_y = lengthdir_y(max_distance, direction);
double moving_x = inst1->x + max_x;
double moving_y = inst1->y + max_y;
for (enigma::inst_iter *it = enigma::fetch_inst_iter_by_int(all); it != NULL; it = it->next)
{
const enigma::object_collisions* inst2 = (enigma::object_collisions*)it->inst;
if (inst2->id == inst1->id || solid_only && !inst2->solid) continue;
const double left2 = inst2->x + inst2->bbox_left, top2 = inst2->y + inst2->bbox_top,
right2 = inst2->x + inst2->bbox_right, bottom2 = inst2->y + inst2->bbox_bottom;
const double x_moving = inst1->x + max_x;
if (inst1->y < bottom2 && inst1->y > top2)
{
if (max_x > EPSILON)
{
if (left2 < moving_x)
{
max_x = left2 - inst1->x;
moving_x = inst1->x + max_x;
}
}
else if (max_x < -EPSILON)
{
if (right2 > moving_x)
{
max_x = right2 - inst1->x;
moving_x = inst1->x + max_x;
}
}
}
if (inst1->x < right2 && inst1->x > left2)
{
if (max_y > EPSILON)
{
if (top2 < moving_y)
{
max_y = left2 - inst1->y;
moving_y = inst1->y + max_y;
}
}
else if (max_y < -EPSILON)
{
if (bottom2 > moving_y)
{
max_y = bottom2 - inst1->y;
moving_y = inst1->y + max_y;
}
}
}
}
inst1->x = moving_x;
inst1->y = moving_y;
return 0;
}
inline int move_contact_solid(double direction, double speed) { return move_contact(direction, speed, true); }
inline int move_contact_all(double direction, double speed) { return move_contact(direction, speed, false); }
194
General ENIGMA / Re: Some common GML issues, and dealing with them in Enigma?
« on: December 31, 2010, 11:49:19 am »
The only way that it would work in C++ is by creating a map of variables to strings.
map<var*, string> var_map;
var_map.find(variable_name);
Of course, I think that ENIGMA should have a separate resource and variable map, and have each disablable. This also probably is how execute_string would pull variable/resource names.
map<var*, string> var_map;
var_map.find(variable_name);
Of course, I think that ENIGMA should have a separate resource and variable map, and have each disablable. This also probably is how execute_string would pull variable/resource names.
195
Function Peer Review / Re: move_contact functions optimised for bbox
« on: December 31, 2010, 12:42:19 am »
Confirmed not working. I know why, though.