Skip to content

Pome-ro/Love2D-Template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LÖVE Template

This is a simple template for making games with LÖVE. It tries to do as little as possible while still being useful for most types of games (or tools).

Should you use this template?

This template is primarily for my own personal use and the way that things are setup matches how I tend to write projects.

If you are an absolute novice to LÖVE, it would be in your best interest to become familiar with the basics first before using any templates.

If you are a beginner/intermediate user of LÖVE and you are not sure what libraries to use or how to layout a project, then this may be what you need.

If you are experienced with LÖVE, you probably know enough to make your own template, and you don't need this anyway. On the other hand, it should also be trivial to modify the code to suit your own needs. It is your choice.

General project guidelines

There are a few guidelines that I follow to keep projects consistent and maintainable.

  1. Modules should be local by default.

    This makes it easy to alias the module name. It also keeps the global namespace clean. For further reading: https://kiki.to/blog/2014/03/31/rule-2-return-a-local-table/

    -- theModule.lua
    local theModule = {}
    ...
    return theModule
    -- Other lua file
    local theModule = require 'theModule'
  2. Common libraries should be global.

    If a library is used everywhere, then it might be a good idea to require it globally.

    Class = require 'libs.class'
  3. Global variables should be put into a file called globals.lua.

    Ideally, you do not want many global variables in the global namespace, because it makes it hard to keep track of state. To make things even easier, putting global variables in a single file makes it easier to find where they are defined.

  4. Directories should be plural, where applicable.

  5. Directories should not be abbreviated.

    There is no technical justification for these two guidelines, but it makes names easier to remember.

Included libraries

  • inspect.lua (Used as Inspect) - A useful debug utility for printing out the contents of tables.
  • HUSL 1.0 (now called HSLuv) - Provides an easier and more aesthetically pleasing alternative to RGB for specifying colors.
  • HUMP
    • Camera - Handles translations, rotation, and scaling.
    • Class - Allows lightweight classes, not a full OOP implementation.
    • Gamestate (Used as State) - Creates different states in your game that you can switch between, e.g. menu, game, pause screen, etc.
    • Signal - Used for broadcasting events, "player killed an enemy," "an item was dropped," "the game has started," which is useful for triggering sounds and effects without tying it to your gameplay code.
    • Timer - Allows you to create code that will run after N seconds, every N seconds, and during N seconds, and other useful timing utilities.
    • Vector - Represents a 2D vector with a full set of the needed functions (normalization, dot product, cross product, etc.).
  • Lume - A set of utility functions that are incredibly useful for gamedev.

About

A game development template for LÖVE.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 99.6%
  • Batchfile 0.4%