Confusion with mixins and missing variables
Posted: Tue Jun 03, 2014 12:59 am
Me again, this time it wont be as easy as choosing the right file loading function :v
Basically, to handle game objects, I have decided that objects had a prototype class (like actor or item), a defined template to copy (such as wall, enemy, player, door, gun, etc) that would define it's behavior and the object's attribute, and then a proper instance created via the template's spawn() function.
The prototype classes uses mixins that contain code for movement and drawing, both dependent on a mixin defining their grid based behavior.
The problem appears when I try to have each cell of my grid draw their contents : there seems to be no errors with objects of instance item, but for objects of instance actor, it just cannot find the reference to the current map passed during it's creation and throws an error when entering the drawing mixin.
Print() debugs have shown that the only actor created in the game.lua main loop, player, knows what his map is. (print(player.map.name) outputs "testmap" as intended)
I think the problem comes from mixins, but I am not sure. Could someone more well versed help me find my error ? (Also, obviously, if I am coding useless/ugly things, that is not the problem :p)
dat love file
Keep in mind that those pitiful stubs of documentation are meaningless since I began rewriting the way I manage everything, so do not rely on them :v
Basically, to handle game objects, I have decided that objects had a prototype class (like actor or item), a defined template to copy (such as wall, enemy, player, door, gun, etc) that would define it's behavior and the object's attribute, and then a proper instance created via the template's spawn() function.
The prototype classes uses mixins that contain code for movement and drawing, both dependent on a mixin defining their grid based behavior.
The problem appears when I try to have each cell of my grid draw their contents : there seems to be no errors with objects of instance item, but for objects of instance actor, it just cannot find the reference to the current map passed during it's creation and throws an error when entering the drawing mixin.
Print() debugs have shown that the only actor created in the game.lua main loop, player, knows what his map is. (print(player.map.name) outputs "testmap" as intended)
I think the problem comes from mixins, but I am not sure. Could someone more well versed help me find my error ? (Also, obviously, if I am coding useless/ugly things, that is not the problem :p)
dat love file
Keep in mind that those pitiful stubs of documentation are meaningless since I began rewriting the way I manage everything, so do not rely on them :v