GM pretends to be OO, but in truth, it's far from it. It's far closer to non-OO languages in the way you program in it. A huge pity, I think.
@ale:
Remember that GM is not an object oriented language. As such "structures" are alien to GM. You can only emulate the wanted effects. There are several methods:
"objects" (as in resource) can be though of as more advanced structures. (basically a struct that also executes several things each step). SO one could create a special object for each "custom TYPE" - and fill it's create event with the default values for each variable- you have and then do something like:var myTypeVariable; myTypeVariable = instance_create(0,0, objCustomType); myTypeVariable.posX = 10; myTypeVariable.posY = 20; if (myTypeVariable.theItems[10]=100) { }
Remember though that GM does quite a bit behind the schemese with instances - so it's not the fastest solution.
Wait, what?
GML is an object oriented language. It wouldn't be useful if it weren't. It's just not a particularly good or flexible object oriented language because Game Maker shoehorns its classes as templates of physical game objects.
This solution of OP's problem is an example of creating a class, that stores data. Game Maker's objects are instances of classes.
Please don't go that route again.. If you stretch the definition of object oriented languages so far C, pascal & even fortran can be considered " object oriented". With structs etc you can also emulate classes. Really without things like data hiding, member methods, polymorphism can you call a language object oriented? On top of that GML has 0 support for even structures, and looking at the container types they are definitely not written in an OO style.
C and FORTRAN aren't object oriented because OOP functionality isn't part of their inherent design. They are inline languages. GML is not an inline language because the code is separated out into into classes, which are used to instantiate objects of certain properties. Most common functionality of OOP has been gutted for simplicity and "user friendliness," but it's still an object oriented language.
How to create a custom TYPE variable in GML?
Started by ale870, Jun 01 2012 09:44 AM
21 replies to this topic
#21
Posted 27 June 2012 - 04:56 PM
#22
Posted 29 June 2012 - 08:05 AM
I'm willing to say "pretends to be object oriented" and "is a ****ty object oriented language" are basically the same thing and any further discussion would be an arduous and annoying and worthless debate of petty semantics.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users



This topic is locked







