Proper Entity Inheritance Structure (Help Request)
Posted: Wed Sep 10, 2014 9:40 pm
Hello friends!
First post, but I've been reading/searching quite a bit in the past few weeks and learning a ton. I have both "Beginning Lua Programming" and "Programming in Lua (3rd Edition)". They have helped tremendously, but I've found I learn and retain even more by figuring out a goal and then trying to make it happen.
Anyway, most recently I've gone through goature's awesome tutorials on youtube with great success, but when I tried to apply (and change) some of it to my own project, I've come across a bit of an issue that perhaps you all could help me with.
Basically, I started with the entity structure in goature's tutorials and I've tried to expand it a bit. Instead of just having a "base", I created a base_entity and base_character. The reason for this is because I want all of my char_(name) files to inherit a few more things that are unnecessary in base_entity (like keypressed movements and such).
In my files, you can see that char_sol.lua has keyboard options in function ent:update(dt), however, I want those to be in base_character. I tried creating a function player:update(dt) but nothing was being passed through it, and when adding it to main.lua (under function love.update(dt)) I received an error.
I'm clearly missing something as I still have quite a bit to learn about inheritance and functions. It would be greatly appreciated if someone could point me in the right direction in regards to getting my basic character movement stuff into base_character and out of char_(name). This would also go a long way in regards to moving almost everything into character_base and simply using the char_(name) file for settings (health, speed, images used for animations, etc).
Perhaps I need to rename a few things as well to make sure things are more clear? Perhaps an entire set of player functions? Or can I keep sharing the ent functions from goature's structure?
Thanks so much for any help.
Here are my files: Note: Currently using sprites off the internet (from Guilty Gear XX) to get my proof of concept working. Hopefully that's OK.
First post, but I've been reading/searching quite a bit in the past few weeks and learning a ton. I have both "Beginning Lua Programming" and "Programming in Lua (3rd Edition)". They have helped tremendously, but I've found I learn and retain even more by figuring out a goal and then trying to make it happen.
Anyway, most recently I've gone through goature's awesome tutorials on youtube with great success, but when I tried to apply (and change) some of it to my own project, I've come across a bit of an issue that perhaps you all could help me with.
Basically, I started with the entity structure in goature's tutorials and I've tried to expand it a bit. Instead of just having a "base", I created a base_entity and base_character. The reason for this is because I want all of my char_(name) files to inherit a few more things that are unnecessary in base_entity (like keypressed movements and such).
In my files, you can see that char_sol.lua has keyboard options in function ent:update(dt), however, I want those to be in base_character. I tried creating a function player:update(dt) but nothing was being passed through it, and when adding it to main.lua (under function love.update(dt)) I received an error.
I'm clearly missing something as I still have quite a bit to learn about inheritance and functions. It would be greatly appreciated if someone could point me in the right direction in regards to getting my basic character movement stuff into base_character and out of char_(name). This would also go a long way in regards to moving almost everything into character_base and simply using the char_(name) file for settings (health, speed, images used for animations, etc).
Perhaps I need to rename a few things as well to make sure things are more clear? Perhaps an entire set of player functions? Or can I keep sharing the ent functions from goature's structure?
Thanks so much for any help.
Here are my files: Note: Currently using sprites off the internet (from Guilty Gear XX) to get my proof of concept working. Hopefully that's OK.