Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // collision list will be a ds_list holding instance ids, or noone
- var radius = sprite_get_width(sprite_index) / 2; // assumes object is circular
- var collision_list = scr_collision_circle_list(x, y, radius, obj_collidables, true, true);
- // check list isn't empty
- if (collision_list != noone) {
- // iterate through the list
- for (var n = 0; n < ds_list_size(collision_list); n++) { // all objects that can collide should have a common parent object
- var inst = ds_list_find_value(collision_list, n);
- // get direction to instance
- var dir = point_direction(x, y, inst.x, inst.y);
- // only bounce the object if it hasn't already been bounced
- if (inst.direction != dir( {
- inst.speed *= speed_multiplier;
- inst.direction = dir;
- }
- }
- // clean up ds objects when you're done with them, else they sit in memory even when their pointer is a local var
- ds_list_destroy(collision_list);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement