## 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.
mongrol
Prole
Posts: 33
Joined: Fri Nov 30, 2012 1:01 am

### FIle organisation

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?

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

### Re: FIle organisation

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.

kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

### Re: FIle organisation

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.

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

### Re: FIle organisation

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
--+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?

xXxMoNkEyMaNxXx
Party member
Posts: 206
Joined: Thu Jan 10, 2013 6:16 am

### Re: FIle organisation

@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

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

### Re: FIle organisation

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

Code: Select all

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

### Who is online

Users browsing this forum: No registered users and 39 guests