Legacy GM Mouse Grid System and Connect two objects Together

H

hot2fire

Guest
I try to create a mouse grid system and connect them to the endpoint like that video. First, I try to do a 64 by 64 snap grid and connect other objects. This video is the perfect explain how I wanted everything to look like. However, the download link doesn't work. Which is some BS!

Also, if the yellow circle manages to connect another object, is there a way to code?


For the create event
can = 1; // can i move when i press the button
canalarmset = 8;
canalarm=canalarmset;
snap = 64;

selected = false;
global.canSelect = true;

For the step event
if (selected) {
global.canselect = false;
y=mouse_y;
x=mouse_x;
}

Left mouse button
/// Move object
if (global.canSelect) {
instance_create(x, y, obj_electrical_wire);
selected = true;
}

Global left Released
/// Release mouse
if (global.canSelect) {
selected = false;
instance_destroy();
}
 
Last edited by a moderator:
T

tserek

Guest
That's how can you achieve 64x64 grid mouse (object) movement, the minus values are half to move_snap values.
Code:
x=mouse_x-32;
y=mouse_y-32;
move_snap(64,64);
 
Last edited by a moderator:
H

hot2fire

Guest
That's what it looks like when I press mouse left button and drag over green circle
 
Last edited by a moderator:

Morendral

Member
Your left mouse is wrong. It should be the left pressed event instead as right now it will continuously create instances while pressed. The left pressed event only registers once per click. Your code needs to be changed as well. First it should check if there is something at the mouse location already. Then it should place it snapped to your grid. You have it set to just x and y which means wherever and not necessarily in the grid
 
H

hot2fire

Guest
Is there a way to make two objects connected together?

Is there a way to change the code? Right now, you have to click and drag an object around the 64 by 64 grid.

But, I wanted to change it to mouse left pressed to put the object on any grid. Also, I notice in the video above there is a box that changes an object in the top right corner. Is there a way to apply that to the mouse button.

Finally, is there a way to make the lines connect the yellow bulb changes yellow.

I created this for the step event obj_manager and it doesn't have a sprite. I notice when I coded the walls, still goes through.
Here is the code:

/// Stop obj_colorRED from moving
x=xprevious
y=yprevious​

Then I did change it

image_speed = 0;​

Which didn't work as well

/// Create the mouse for obj_colorRED
For the step event
if (mouse_check_button(mb_left) && place_free(mouse_x,mouse_y))
instance_create(mouse_x,mouse_y,obj_colorRED);​

/// Create object for obj_colorRED
create event
if (!place_snapped(32,32))
x=mouse_x-32;
y=mouse_y-32;
move_snap(64,64);​

Does what it looks like when the object goes through objects and the object red square is not snapped in the 64 by 64 grid. However, at least I try to use image_indexs to know they are connected. Is there a code to tell if objects are connected together

I use image_index = 0
then if they are connected image_index = 1

Hopefully, I figure it out soon.... real soon

MOD EDIT: Posts merged. Please do not multi-post if noone else has answered. Just add the extra information to the last post using the edit button.
 

Attachments

Last edited by a moderator:
Top