1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Destroy every instances expect one

Discussion in 'Programming' started by 66Gramms, Feb 2, 2017.

  1. 66Gramms

    66Gramms Member

    Joined:
    Feb 2, 2017
    Posts:
    23
    Hello All!
    I'm making a shootemup and i'm quite a begginer in programming. So i've made a powerup system and now i'm making the last one the bomb. I think i'm going quite fine with it but i don't know how to kill every enemies without destroying them one by one. So i'm using collosion circle and there is the object arguement. Is there some way i could destroy everything expect the player and a few things? Thanks for your answers in advance and sorry for bad grammar
     
  2. veko

    veko Guest

    sorry, but im pretty sure its simpler to destroy every other object mannually than to write a code for it, just use
    with obj_iwanttodestroy
    {
    instance_destroy();
    }

    and copy paste it and change the object name
     
  3. 66Gramms

    66Gramms Member

    Joined:
    Feb 2, 2017
    Posts:
    23
  4. 66Gramms

    66Gramms Member

    Joined:
    Feb 2, 2017
    Posts:
    23
    if collision_circle(obj_character.x, obj_character.y, r, obj_enemyShip, false, false){
    instance_destroy();

    So i tried this but it destroy the object which makes the circle... How could i destroy the instance it's meeting with?
     
  5. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,851
    Have you read the Manual entry on collision_circle()?
    Code:
    var colliding_ship = collision_circle(obj_character.x, obj_character.y, r, obj_enemyShip, false, false);
    if (colliding_ship != noone) {
      with (colliding_ship) {
        instance_destroy();
      }
    }
     
  6. 66Gramms

    66Gramms Member

    Joined:
    Feb 2, 2017
    Posts:
    23
    Well like i'm said i'm begginer i didn't know about "WITH" and i can't really use the id-s it's quite unknown for me atm. Thank you for helping me it's working now and sorry for my silly questions :)
     
  7. Blazing

    Blazing Guest

    Also, for all destructables, give them one parent object and put that in the
    Code:
    with (obj_destructables) instance_destroy();
    code instead like this. Make sure you use that circle collision check or you will wipe out every enemy and such in the entire room.

    That way you can have goody boxes, cars, and all sorts of enemies that can be blown up, but the player and inventory items will not get blown up because their parent object isn't obj_destructables.
     

Share This Page