Obj_thing.x = 10 // Finds the first instance of obj_thing, and sets its x to 10 However, you can use an object index to refer to an instance: GM objects are like classes, and GM instances are like objects. This is a pain point for a bunch of people, so it's not just you. Basically, arrays are copy-on-write, unless you use an accessor when writing to the array. You can edit the same array actually! Check out array accessors.
What I tend to do is pass the instance I want to operate on as the first parameter, then use a with statement inside the script. how it is, it's annoying for sure, but you end up working with it. Also, 1D arrays are a lie, every 1D array in GM is actually a 2D array cries This is a weird one for me, personally I find it weird we even have 2D arrays (rather than just an array of arrays). Have a nice day!*ĪFAIK, there's just an internal limit that was put there by YYG, wouldn't quote me on it though :D You all are much more open-minded than I am used to. I'll admit I was a bit worried that my post might be considered as an attack. It's the first time I'm exposed to the GM community and so far it's been a pleasure. So an object is like a reference to all instances but if there is no instance, there is no object ? Can someone explain this to me with a classical Class / Object / Instance example ?Įdit*: Thank you all for these answers, I've learned much more with this pos than in 3 days of researches. The only object you can create is a GM object ? With all these attributes populated ?Ħ - What in the hell is an object ? if I don't have any oWall instanciated, I can't get the properties of oWall. Am I in the obligation to use the above method (n☃) ?ĥ - If I create an object that doesn't show anything, why does it gets an x, an y, a size, a ratio, etc.
#Game maker studio 2 language code#
Also this limits a lot code reusability.Ĥ - If I pass an array to a script as a parameter, it's entirely copied. I've added a numerotation so if you know the answer for one or two questions you can answer to them directly :)ġ - Why do arrays have a maximum size ? How do you manage >32 000 elements ? Does it never happens ?Ģ - Why can't we manipulate >2 dimentions arrays without any tweaks ? Does 2D games only need 2D data structures /s ? Are there any alternatives ?ģ - Why does scripts are able to create, edit and delete any variables from the calling scope ? That seems like a huge hard to diagnose bugs generator. I'm not angry or in a conflicting mood, I'm genuenly curious and I'm open to discussion. It's so much fun and I thind I'll stick with it despite the language, but I'm very confused.
Don't get me wrong, I love Game maker studio. So far, my experience with GML is a big turn off. What I mean by good coding practices is DRY, unit testing, separation of concerns, encapsulation. I usually work in team and I'm very attached to good programming practices. I've been coding for approx 7 years now and I've used a lot of different languages and programming paradigms (I'm not flexing here, just giving you some context (: ).
Plase if this is you, dont feel attacked x) I have a friend who learned to code with GM for almost 10 years now and his opinion very biased, so I've stopped to ask him to avoid conflict. I've been toying with Game Maker Language for 3 days now and I wanted your advice on some good coding practices.