x = random(view_xview) y = random(view_yview)
How can I get that instance to move with the view port with the same x and y values?
Thanks in advance!
Posted 07 August 2012 - 06:16 AM
x = random(view_xview) y = random(view_yview)
Posted 07 August 2012 - 06:36 AM
x = view_xview[0] + irandom(view_wview[0]); y = view_yview[0] + irandom(view_hview[0]);To get the instance to stick to that relative point from then on, you will need to store the randomised section above in a variable and add that to the current view co-ordinates like this:
// This should only be run once, most likely in the create event. x_amount = irandom(view_wview[0]); y_amount = irandom(view_hview[0]); // STEP EVENT x = view_xview[0] + x_amount; y = view_yview[0] + y_amount;
Edited by Blake, 07 August 2012 - 06:38 AM.
Posted 07 August 2012 - 08:27 AM
x_amount = xbecause that will record the x position in the room and not the view.
x_amount = view_wviewbecause that will record the view width (in my case 1280)
x = view_xview[0] + x_amount y = view_yview[0] + y_amount
Posted 07 August 2012 - 09:34 AM
x_amount = mouse_x - view_xview[0]; y_amount = mouse_y - view_yview[0];
Posted 07 August 2012 - 10:12 AM
Posted 07 August 2012 - 10:35 AM
Then you would use the x and y position of the instance in place of mouse_x and mouse_y.I'm sorry to drag this out any further... but what if the instance is placed at the mouse co-ordinates and move_snap(64,64) changes the position making mouse_x/y "useless?"
This is correct.Is irandom in whole integers and random in decimals?
Posted 07 August 2012 - 04:12 PM
Posted 07 August 2012 - 10:53 PM
// step event
if x < view_xview + 128 && y < view_yview +128
{
move_snap(64,64);
var_inv = true
}
// create event
var_drag = false
var_inv = false
// step event
if var_drag = true
{
x = mouse_x
y = mouse_y
}
if x < view_xview + 128 && var_drag = false
{
move_snap(64,64);
var_inv = true;
}
// left mouse pressed
if var_drag = false
{
var_drag = true
}
else
var_drag = false
if x = view_xview + 32
else
if x = view_xview + 64
else
if x = view_xview + 128
else
if x = view_xview + 196
else
then {x = bla bla bla}
Edited by tatman87, 07 August 2012 - 10:58 PM.
Posted 08 August 2012 - 12:01 AM
0 members, 0 guests, 0 anonymous users