FIle organisation

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
mongrol
Prole
Posts: 33
Joined: Fri Nov 30, 2012 1:01 am

FIle organisation

Post by mongrol » Sat Jan 05, 2013 10:01 am

Hi,
I'm moving from C++/SFML to Lua/Love in order to speed my development along (Dad of two kids, hardly any time to code). With C++ I generally followed the standard of making .h and .cpp files for every class and starting the whole shebang off from a main.cpp. I'm assuming at this stage that since we're all making games then a class system is going to be used in any moderately sized project. What's the general standard for Lua game development? How do you organise your files?

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: FIle organisation

Post by bartbes » Sat Jan 05, 2013 6:19 pm

I usually end up doing something like

Code: Select all

+ Root
+-- main.lua
+-- conf.lua
+-+ lib
  +-- slither.lua (my class lib of choice)
  +-- misc libs
+-+ class
  +-- all of my classes
+-+ state
  +-- any game states
+-+ gfx
  +-- graphics
+-+ sfx
  +-- sound
and anything else I might have forgotten.

User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: FIle organisation

Post by kikito » Sat Jan 05, 2013 6:54 pm

mongrol wrote:I'm assuming at this stage that since we're all making games then a class system is going to be used in any moderately sized project. What's the general standard for Lua game development? How do you organise your files?
There is no standard whatsoever. Also there's no default class system. There are several class implementations . Whichever you choose will depend on your personal preferences regarding syntax and functionality. (Disclaimer I am the developer of one of them, MiddleClass)

LÖVE provides some minimal requirements - you must at least have a main.lua file to start things out (a conf.lua will be handy, too).

From what I've seen other people do, it's generally a good principle to separate the code of the game from the "external libraries" that it uses. Usually this is done via a "lib" folder, with the library files/folders inside of it. It's also usual to have the media (images, sounds, etc) separated from the sourcecode in separate folders.

Appart from that, I think every project is a beautiful flower. The file structure of the game source code should reflect what the game looks like. For example, in some games it might make sense to have a "levels" folder, but in others it will not.
When I write def I mean function.

User avatar
monsieur_h
Citizen
Posts: 65
Joined: Tue Oct 30, 2012 4:43 pm

Re: FIle organisation

Post by monsieur_h » Sat Jan 12, 2013 1:09 am

I ended up with a pretty similar to bartbes' :

Code: Select all

main.lua
conf.lua
+lib //external libs folder
+class
+data //all data that is textual for the game
--+levels
--+pnj
--+shader
--+i18n
+gamestate//all my gamestates
+res //all resources loaded in the game that aren't data
--+images
--+fonts
--+sounds
--+music
Also I'm curious of what you're putting in gfx and sfx bartbes?

User avatar
xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am
Location: Canada

Re: FIle organisation

Post by xXxMoNkEyMaNxXx » Sat Jan 12, 2013 1:12 am

@monsieur_h
'gfx' and 'sfx' stand for graphics and sound effects.

I'd be curious as to what you're putting in i18n and pnj :P

User avatar
monsieur_h
Citizen
Posts: 65
Joined: Tue Oct 30, 2012 4:43 pm

Re: FIle organisation

Post by monsieur_h » Mon Jan 14, 2013 2:18 pm

i18n contains localisation for my texts. And about PNJ I forgot to translate it: it stands for NPC in english :rofl:
My bad!

Code: Select all

+i18n
--fr.lua
--en.lua
--es.lua
...
+pnj(NPC)
--a_character.lua
--a_boss.lua

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests