Hi,
this is an interesting one I need some thoughts on .
I have 2 versions of a game, they are both coded separately, I need to combine them into
the same program.
I have coded up the menus etc. The menu has buttons to launch each version of the game.
I do not use storyboard otherwise I
could just call a different scene and handle it like that.
My issue that the main runtime contains timers outside of functions. I thought I could just wrap the runtime in a function and call that from the menu for each version.
How would anyone here handle this? I don’t want to re code lots of stuff again, simpler the better…thanks
ok, so I have sorted the timers no problem.
Still looking for opinions regarding the amalgamation of the two though
Is it possible to call each game via module?
example:
main.lua ( contains menu which points to gameA or gameB ) > gameA.lua or gameB.lua ( game plays and on gameover calls gameover screen in main.lua).
If so what is best way to go about it?
Well, thought I would update this with the way I solved it just in case anyone is interested.
I first began to load the separate games as modules, and requiring them in to the main.lua, I had success but not totally as there were a lot of scoping issues; I decided this approach would create lots of additional work.
I fixed it all by as I originally thought, I encapsulated each game within a function in main lua. Obviously I had to add to my sprite module and image folders the relevant assets etc,and just a small amount of code tweaks also.
Sound files I decided to handle all globally, this again worked, although the logic was a little complex (easy but thought provoking :) ).
Probably not an elegant solution but I started out having no intention of a dual game, if I had I would of definitely used Storyboard or Lergs trimmed down Director class.
This would have handled my initial problem easily without fuss by just calling a different scene.
thanks for listening
ok, so I have sorted the timers no problem.
Still looking for opinions regarding the amalgamation of the two though
Is it possible to call each game via module?
example:
main.lua ( contains menu which points to gameA or gameB ) > gameA.lua or gameB.lua ( game plays and on gameover calls gameover screen in main.lua).
If so what is best way to go about it?
Well, thought I would update this with the way I solved it just in case anyone is interested.
I first began to load the separate games as modules, and requiring them in to the main.lua, I had success but not totally as there were a lot of scoping issues; I decided this approach would create lots of additional work.
I fixed it all by as I originally thought, I encapsulated each game within a function in main lua. Obviously I had to add to my sprite module and image folders the relevant assets etc,and just a small amount of code tweaks also.
Sound files I decided to handle all globally, this again worked, although the logic was a little complex (easy but thought provoking :) ).
Probably not an elegant solution but I started out having no intention of a dual game, if I had I would of definitely used Storyboard or Lergs trimmed down Director class.
This would have handled my initial problem easily without fuss by just calling a different scene.
thanks for listening