Splitting source into multiple files

26 views
Skip to first unread message

Sean Normoyle

unread,
Oct 2, 2012, 8:02:54 PM10/2/12
to gam...@googlegroups.com
Hey everybody,
I just found GameJs and I really like it. I'm also very new to JavaScript in general. For the sake of organization and source control, I'd like to be able to separate various components of my game into various files. Is there an easy way to do this?

Thanks,
--Sena

si...@nekapuzer.at

unread,
Oct 3, 2012, 11:30:01 AM10/3/12
to gam...@googlegroups.com
hello sena,
GameJs supports the CommonJs module system, which makes this very easy. Basically you have two new keywords:
require() and exports.

Take a look at this game: https://github.com/oberhamsi/telemachus-gamejs

for a formal definition of how modules work: http://gamejs.org/commonjs_modules

We should probably add an example to gamejs, which shows how the module system works.

simon

Sean Normoyle

unread,
Oct 3, 2012, 11:53:15 AM10/3/12
to gam...@googlegroups.com
Hi Simon,
Awesome, thanks! I'll take a look at those links. If I can come up with a decent example, I'll post it. As I've been learning GameJs I've been creating examples for myself and continuously updating them with what I learn. I'd be happy to help out with any if I can.
 
-- *Sean (mispelled my name in my first post, I was very tired)
Reply all
Reply to author
Forward
0 new messages