Information about object: Ball Sprite: Solid: false Visible: true Depth: 0 Persistent: false Parent: Mask: Create Event: execute code: force = 0; mass = 0; direction = 0; selected = false; Mouse Event for Glob Left Pressed: execute code: if( point_distance( x, y, mouse_x, mouse_y ) < 10 ) { selected = true; } Mouse Event for Glob Left Released: execute code: if( selected ) { direction = point_direction( mouse_x, mouse_y, x, y ); force = point_distance( x, y, mouse_x, mouse_y ) / 10; } selected = false; Draw Event: execute code: draw_circle( x, y, 10, true ); Information about object: Overmind Sprite: Solid: false Visible: true Depth: 0 Persistent: false Parent: Mask: Create Event: execute code: balls[0] = instance_create( x, y, Ball ); balls[1] = instance_create( x + 50, y + 50, Ball ); balls[2] = instance_create( x + 70, y + 70, Ball ); balls[3] = instance_create( x + 90, y + 90, Ball ); count = 4; Step Event: execute code: // Ruch for( i = 0; i < count; i += 1 ) { a = balls[i]; a.x += lengthdir_x( a.force, a.direction ); a.y += lengthdir_y( a.force, a.direction ); } // Kolizje for( i = 0; i < count; i += 1 ) { a = balls[i]; for( j = 0; j < count; j += 1 ) { if( i != j ) { b = balls[j]; distance = point_distance( a.x, a.y, b.x, b.y ); if( distance < 20 ) { a_back_force = min( a.force, distance / 2 ); b_back_force = min( b.force, distance / 2 ); a.x -= lengthdir_x( a_back_force, a.direction ); a.y -= lengthdir_y( a_back_force, a.direction ); b.x -= lengthdir_x( b_back_force, b.direction ); b.y -= lengthdir_y( b_back_force, b.direction ); direction = point_direction( a.x, a.y, b.x, b.y ); force = point_distance( 0, 0, lengthdir_x( a.force, a.direction ) + lengthdir_x( b.force, b.direction ), lengthdir_y( b.force, b.direction ) + lengthdir_y( a.force, a.direction ) ); a.direction = direction + 180; a.force = force * 0.98; b.direction = direction; b.force = force * 0.98; a.x += lengthdir_x( a_back_force, a.direction ); a.y += lengthdir_y( a_back_force, a.direction ); b.x += lengthdir_x( b_back_force, b.direction ); b.y += lengthdir_y( b_back_force, b.direction ); } } } } // Tarcie for( i = 0; i < count; i += 1 ) { a = balls[i]; if( a.force != 0 ) { if( abs( a.force ) <= 0.03 ) a.force = 0; else a.force -= sign( a.force ) * 0.03; } }