Constructor - The king of data [GameMaker | Advanced]

Поделиться
HTML-код
  • Опубликовано: 18 дек 2024

Комментарии • 39

  • @damianrogers4585
    @damianrogers4585 10 месяцев назад +6

    Before this I was at arrays. My simple mind has been blown. It all makes sense, thank you.

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      You have unlocked the another piece of the nine heavenly gates of programming. You will be unstoppable in the future. (thanks for the trust by subbing!)

    • @potatocat94
      @potatocat94 10 месяцев назад

      question: what are the other eight? @@1upIndie

    • @PixelKnight93
      @PixelKnight93 10 месяцев назад +1

      same here dude I've been studying gml and c++ for months but just yesterday understudy arrays

    • @1upIndie
      @1upIndie  10 месяцев назад

      @@PixelKnight93Glad I could be of assistance.

  • @blackstormfire
    @blackstormfire 10 месяцев назад +1

    structs are perfects, you can use them in so many ways, the first thing i did when structs came out, was to make a copy of cookie clicker. it was one of my first "real" projects i was making for many years ago, and i remeber how hard it was to keep control of each objects ( yes i made every upgrade as an object so it was easiere to change values ) it took so much time, with structs, 2 hours and you have it all up and running. structs are poerfull, and you can use them for so many odd things too, it do not have to be anything about items or games, but you could make a calculator with structs, i would recommend to do that if you dont feel sure about structs yet ;) believe me, when you learn structs you will fall in love with GM once more. Thanks for an awesome video on this topic that many people are a afraid of

    • @1upIndie
      @1upIndie  10 месяцев назад

      Couldn't agree more. That made my life infinite easier developing.

  • @Dronemain
    @Dronemain 10 месяцев назад +3

    Thank you for this video. And for all the other videos you made. It's always fun to learn something new and try it out in my project. You explain everything so easily and nice

    • @eunit08
      @eunit08 10 месяцев назад +2

      That's the best part of his tutorials. Being able to implement it into our projects without changing much of the rest of the project

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      Glad to hear I can help a fellow developer out, keep it up!

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      Agreed, hey there mate!

    • @eunit08
      @eunit08 10 месяцев назад

      @@1upIndie 🙏🙏

  • @ShaolinMonkster
    @ShaolinMonkster 10 месяцев назад +2

    Now you gotta know which index belongs to which item :D
    Thank you for the info, good video

    • @1upIndie
      @1upIndie  10 месяцев назад

      Yeah, that is a just a tiny bit of important. But you can write a repeat loop and check for the name and get as a return value the index back.

  • @mrnobody7600
    @mrnobody7600 10 месяцев назад +3

    You have been using the same background song for years bro I love it haha.

    • @1upIndie
      @1upIndie  10 месяцев назад

      Yeah, a golden one. Thanks RUclips audio library.

  • @Madworld130
    @Madworld130 10 месяцев назад +1

    This is great! I add one more step to mine, but it's just a preference thing. I do the constructor like you did, then make a struct specific to the items i.e.,
    itemStruct = {
    drinkingHorn : new create_item("Drinking horn",spr_Item_0)
    }
    items = [itemStruct.drinkingHorn];
    I will say that saving an array that has a sprite in it can become a nightmare later because it'll generally save the sprite as it's reference number, but then if you add anything new into the project, that sprite's reference number changes so it won't draw the correct one anymore. But that's a whole different topic to do with saving and there might be a better way to save an array than how I do it.

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      Legit :D. Yeah references can be a fickle, I agree.

  • @georgehennen
    @georgehennen 10 месяцев назад +1

    I am a genius if this this is the advanced way to do this. Still a great video, love all your dedication to the videos dawg.

    • @1upIndie
      @1upIndie  10 месяцев назад

      Well, maybe you are :D. In that case teach me senpai.

    • @georgehennen
      @georgehennen 10 месяцев назад +1

      @@1upIndieCurrently making something now, can probably show you the way I am doing once I am done, and you can tell me if it's dumb or not, plus I might need some help.

    • @1upIndie
      @1upIndie  10 месяцев назад

      @@georgehennen Sure, I will be honest with you but in a constructive way. Everybody starts small and that is the way that is. Looking forward to it.

    • @georgehennen
      @georgehennen 6 месяцев назад

      @@gleefuluv No I have not. I actually forgot about this. I can?

  • @vosovoso5220
    @vosovoso5220 10 месяцев назад +1

    amazing as always - is there a way to create the items in a for loop - anything like `string text ${expression} string text` Template literals?

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      Technically yes,.You should be able to create a for loop to "insert" values/create new entries via template literals. I did that with codifcation in one of my games (in a simpler way for randomisation), so that should work here aswell. I need check though if the ${expression} would be causing issues. GameMaker is a bit wonky here. I will give you an update I guess tomorrow or Wednesday on that one.

    • @vosovoso5220
      @vosovoso5220 10 месяцев назад

      legend thank you!@@1upIndie

  • @digitalswordplay
    @digitalswordplay 10 месяцев назад +1

    Any chance you’d be able to build on this and add removing + stacking?

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      Sure, I guess I can do a tutorial later on that topic. I assume you want the castlevania/metroidvania item popups that you collect on the way that show briefly? Or do you want to see a simple add to inventory one?

    • @digitalswordplay
      @digitalswordplay 10 месяцев назад

      @@1upIndie I would say whatever makes it the most simple. I was thinking kinda along the lines of super Mario bros 3 where you can open up the inventory, choose an item and then the item is removed. Now in smb3 the items don’t really stack, but it’d be nice to see a stack as it’s a highly popular component. I know it would just mean adding a “count” variable to the constructor, but just not sure how to implement it in code :)

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      @@digitalswordplayHm, I have to think about it. I have bridge here a gap between helping you out and make a general purpose inventory for everybody to use. Your idea has 2 things going for it. 1st stacking internally and 2nd using a menue/popup for use. I guess that could be an interesting video tut in the future (but not this week, got too many things I have to do).

    • @Madworld130
      @Madworld130 10 месяцев назад +1

      What I do for this is use some of the array functions as well as a count variable in the constructor. For example:
      if keyboard_check_pressed(vk_space)
      {
      //Simply add to the count
      item[0].count += 1;
      }
      else if keyboard_check_pressed(vk_tab)
      {
      //Remove from the count if there is 1 or more already there
      if item[0].count >= 1 item[0].count -= 1;
      }
      //Remove the item from the array completely if it's now 0 or less
      if item[0].count

    • @digitalswordplay
      @digitalswordplay 10 месяцев назад

      @@Madworld130 in order to remove a specific item wouldn’t you have to implement a selector of sorts or implement a mouse hover over the item to find it and remove it ?

  • @tiffloo5457
    @tiffloo5457 10 месяцев назад +1

    thankyou, its very good video

  • @jrwhrwiutrwuitwiut
    @jrwhrwiutrwuitwiut 10 месяцев назад +1

    Constructors are great! However, depending on the use case I'm not a huge fan of using them for items.
    For instance, in my current project, Items require over a dozen parameters, with some of them being functions. Calling a constructor and trying to pass that many parameters looks horrible.

    • @1upIndie
      @1upIndie  10 месяцев назад +1

      Well, I just show you a way. At the start of my programming journey I never liked it (because it reminded me of Java) but now I over use constructors because they make my life much easier. So if you have a better or other ways to get to your goal, more power to you. I am not the church of programming and no dogma is being forced here, I am just a developer like you.