6
66Gramms
Guest
Hello!
I'm trying to reproduce something i saw on a cool website (check it out anotalk.hu to understand(it's the background)) So I made a few dots (like 200) and gave them random direction and speed. Now to connect them i used a collision circle but collision circle is dumb and picks 1 instance in the circle and then keep checking only that. To fix that I made a ds list then I add an instance to the list, deactivate it (so it won't be checked again) and keep doing it until collision circle returns noone. If this happens I activate all the instances again from the list, it looks like this:
Now this works pretty cool expect for the dots flashing up and diasapiring. I think it happens because as they are doing the code above, they deactivate each other. Also I want them to bounce back when they leave the room, what is the best way to do that? I think using GM-s built in bounce stuff is not a good idea with 200+ instances. Also I leave a dropbox link to the project so you can see it on the work. Thanks for any help in advance! https://www.dropbox.com/s/edy3r6l6hmnaz46/dots.gmz?dl=0
I'm trying to reproduce something i saw on a cool website (check it out anotalk.hu to understand(it's the background)) So I made a few dots (like 200) and gave them random direction and speed. Now to connect them i used a collision circle but collision circle is dumb and picks 1 instance in the circle and then keep checking only that. To fix that I made a ds list then I add an instance to the list, deactivate it (so it won't be checked again) and keep doing it until collision circle returns noone. If this happens I activate all the instances again from the list, it looks like this:
Code:
draw_circle(x, y, 3, false); //I don't use a sprite just draw a "dot" like this
var dots = collision_circle(x, y, length, obj_dots, false, true); //Checking for the instance in the radious
if (dots != noone)
{
ds_list_add(list, dots); //Save it for later in a ds list
if (distance_to_point(mouse_x, mouse_y) <= distance) //Check if mouse is close to the dots
{
draw_line(x, y, dots.x, dots.y); //If it is then the dot draw a line to the closer dots
}
instance_deactivate_object(dots); //Then deactivate it
} else { //if dots returns noone
for (var i = 0; i < ds_list_size(list); i++) //Add them back
{
instance_activate_object(ds_list_find_value(list, i)); //By reactivating them
ds_list_delete(list, i); //And deleting them from the list
}
}