I don't want to discourage your idea of doing OO with inheritance and so forth but maybe read a little about composition over inheritance and prototype based programming.
Lua is in my opinion a natural fit for these paradigms. I would also advise against using an OO library and instead starting just with plain tables as objects and just adding the OO mechanisms you really need.
Lua access parent scope var with same name as in local scope ?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- RagingDave
- Prole
- Posts: 23
- Joined: Mon Jul 27, 2015 3:12 pm
Re: Lua access parent scope var with same name as in local scope ?
The plan was to groupe gameobject by type, for example :
- gameobject
-- character
--- player
--- monster
player will inherit fields and methods from character and so on for gameobject.
- gameobject will contain basic stuff like x y position in world maybe an ID
- character will contain a component with hp, an other one for a collider
- player will have a sprite and business logic
But maybe I shouldn't bother with 'inheritance' (it's rather some way to organize stuff) and create every object from scratch.
There are indeed interestings concepts behing protype programming :
http://gameprogrammingpatterns.com/prototype.html
https://en.wikipedia.org/wiki/Prototype ... rogramming
But does it work to create object on the fly ? Can you really have organized code like that ?
The part on "Prototypes for Data Modeling" from gameprogrammingpatterns.com look nice for data but I don't know for building real world object.
- gameobject
-- character
--- player
--- monster
player will inherit fields and methods from character and so on for gameobject.
- gameobject will contain basic stuff like x y position in world maybe an ID
- character will contain a component with hp, an other one for a collider
- player will have a sprite and business logic
But maybe I shouldn't bother with 'inheritance' (it's rather some way to organize stuff) and create every object from scratch.
There are indeed interestings concepts behing protype programming :
http://gameprogrammingpatterns.com/prototype.html
https://en.wikipedia.org/wiki/Prototype ... rogramming
But does it work to create object on the fly ? Can you really have organized code like that ?
The part on "Prototypes for Data Modeling" from gameprogrammingpatterns.com look nice for data but I don't know for building real world object.
Who is online
Users browsing this forum: No registered users and 12 guests