I've been digging through the help and am thus far unable to find information on it. Is there any way to get AGS to measure the distance someone moves as they do?
I'm trying to make a room where the floor is hot, and they can only take so much movement across it before it becomes unbearable and they leave the room. So, basically, counting down an arbitrary figure, which decreases the more they move.
Thanks for the help!
One approach would be to create a Region covering the hot floor, and use the "While standing on region" event to notch up a counter to determine how long they've been on there.
Another would be to store the position of the character when he starts moving, and in repeatedly_execute calculate the distance from there to his current position.
The game context taken into consideration, I think Pumaman's solution (time of exposure) makes more sense than measuring the distance in whatever way. Why shouldn't it also get unbearable for a character standing still on the hot floor?
The region suggestion is good, but in this context Radiant's is more along the lines of what I'm looking for. Can you advise me as to how I'd get it to store the original position and work out how far they've gone? Do excuse my amateurism, I'm fairly new to this coding nonsense.
You store the original position in the on_mouse_click () function,
int orig_x, orig_y;
function on_mouse_click (MouseButton button) {
if (GetCursorMode () == eModeWalkto) {
orig_x = character[EGO].x;
orig_y = character[EGO].y;
}
}
And you calculate the difference in here:
function repeatedly_execute () {
int dx = character[EGO].x - orig_x;
int dy = character[EGO].y - orig_y;
int distance = Maths.Sqrt (dx * dx + dy * dy);
if (distance > 40) {
Display ("ouch!");
}
}
Quote from: Radiant on Wed 20/02/2008 13:31:01
You store the original position in the on_mouse_click () function,
int orig_x, orig_y;
function on_mouse_click (MouseButton button) {
if (GetCursorMode () == eModeWalkto) {
orig_x = character[EGO].x;
orig_y = character[EGO].y;
}
}
And you calculate the difference in here:
function repeatedly_execute () {
int dx = character[EGO].x - orig_x;
int dy = character[EGO].y - orig_y;
int distance = Maths.Sqrt (dx * dx + dy * dy);
if (distance > 40) {
Display ("ouch!");
}
}
Or slightly faster:
function repeatedly_execute () {
int dx = character[EGO].x - orig_x;
int dy = character[EGO].y - orig_y;
int distance = (dx * dx + dy * dy);
if (distance > 1600) {
Display ("ouch!");
}
}
And: "GetCursorMode()" is old code, "mouse.Mode" is the new (current) style. :=
Thanks, that's surprisingly straightforward - it's just the maths that sometimes does my head in. Since I have multiple characters (who may be in this same room/situation), am I correct in thinking that I can substitute character[EGO] for "player"?
Quote from: JimmyD on Thu 21/02/2008 13:55:24
am I correct in thinking that I can substitute character[EGO] for "player"?
Yes.