GM:S 1.4 Stick objects together.

Discussion in 'Programming' started by NoFontNL, Jun 2, 2019.

  1. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    I was thinking...

    How would I make extendable objects?
    [​IMG]
    This is what I kinda wanna create.
    I thought of when dragging it up, that it creates new objects, while moving the top part up.

    But how do I move this whole thing then? How do I group all those objects together? How do I move every part that is part of the full blaster?

    Any ideas / help would be appreciated
    Thanks in advance.
     
  2. chamaeleon

    chamaeleon Member

    Joined:
    Jun 21, 2016
    Posts:
    888
    I imagine there's no one right answer. Anything that looks good when playing the game is ok. So with that said, you could have helper instances that represent the extrusion, set an anchor instance id variable on each helper that identifies your base, and in the end step event update x and y on the helper with the appropriate offset for each based on the x and y of your anchor instance. Another option could be the have just one instance, and simply draw more sprites in the draw event to make it look bigger (which does not have any impact on the bounding box for collisions, etc., so you'd have to manage that manually). And if the extrusion is a plain color (or there would be distortions) you could in theory just do a scale of the sprite (but I don't know if only horizontal or veritical scaling growth is required for you, so it may or may not be appropriate).
     
  3. JasonTomLee

    JasonTomLee Member

    Joined:
    Jul 20, 2016
    Posts:
    115
    You could simply increase the object's size or it's sprite ( and use a separate variable to mimic the object's boundaries ).

    I assume you'd want to click the object to move and drag it. So you'd need to do a collision check when pressing the mouse ( "mouse_check_button( mb_left )" ) and check if your cursor is colliding with the object.
    A basic collision fuction you'd use is "place_meeting( x,y, object )". So you'd use that function to check if the cursor is above the specified object to follow up on whatever you'd like to do! (Drag or move object )

    If you need some example code, let us know what you have so far. If you're just starting out, I'd be happy to help u out
     
  4. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    I am currently starting from scratch and I'm beginning making the editor UI. I do have some exoerience making in game editors, but didn't know how to solve this problem. I'll get back to you when I have the base system down.
     
  5. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    I'm back. Now with semi-working sizable objects! I still need some help though.
    [​IMG]
    What I've done here, is I have a normal object (64x64) (1 block)
    Center point is (32,64) (bottom middle)
    And I have a variable called size. The image_yscale gets set to the size(so size 3 will make the image_yscale also 3)
    But it collides weirdly. The bboxes are drawn with red lines.
    But for some reason if the blaster is above another blaster, then the bottom blaster randomly collides with it and gets destroyed.
    When placing the grabbed blaster and put it's top on the bottom part of the not grabbed blaster, then they don't collide, which they should do, right?

    Any help would be appreciated
     
  6. NoFontNL

    NoFontNL Member

    Joined:
    Feb 10, 2018
    Posts:
    258
    Nevermind. I used collision_point_list instead of collision_point_rectangle_list
    Because of the center is at (32,64) it behaved weirdly, now I use it's full collision_box instead of it's x and y coordinates
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice