├── .gitignore ├── res └── index.txt ├── src ├── conf.ts └── main.ts ├── .prettierrc.json ├── .eslintrc.json ├── tsconfig.json ├── package.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | game/ 3 | -------------------------------------------------------------------------------- /res/index.txt: -------------------------------------------------------------------------------- 1 | index.txt content 2 | -------------------------------------------------------------------------------- /src/conf.ts: -------------------------------------------------------------------------------- 1 | love.conf = (t) => { 2 | t.window.title = "TypeScript Project"; 3 | }; 4 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "prettier-plugin-organize-imports" 4 | ] 5 | } -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "eslint:recommended", 4 | "plugin:@typescript-eslint/recommended", 5 | "prettier" 6 | ] 7 | } 8 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | love.load = () => { 2 | const [content] = love.filesystem.read("res/index.txt"); 3 | print(content); 4 | }; 5 | 6 | love.draw = () => { 7 | love.graphics.print("Hello World!", 400, 300); 8 | }; 9 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "strict": true, 4 | "forceConsistentCasingInFileNames": true, 5 | "lib": ["esnext"], 6 | "rootDir": "src", 7 | "outDir": "game", 8 | "types": [ 9 | "lua-types/jit", 10 | "love-typescript-definitions", 11 | "@typescript-to-lua/language-extensions" 12 | ] 13 | }, 14 | "tstl": { 15 | "luaLibImport": "require", 16 | "luaTarget": "JIT", 17 | "noImplicitSelf": true, 18 | "sourceMapTraceback": true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "start": "love game --console", 4 | "build": "npm run build:tstl && npm run build:copy", 5 | "lint": "npm run lint:prettier && npm run lint:eslint", 6 | "build:tstl": "tstl -p tsconfig.json", 7 | "build:copy": "copyfiles --all \"res/**/*\" game", 8 | "build:watch": "tstl -w -p tsconfig.json", 9 | "lint:eslint": "eslint -c .eslintrc src/**", 10 | "lint:prettier": "prettier \"**/*.{js,ts,ym,md}\" --check", 11 | "fix:prettier": "prettier \"**/*.{js,ts,ym,md}\" --check --write" 12 | }, 13 | "devDependencies": { 14 | "@typescript-eslint/eslint-plugin": "^8.5.0", 15 | "copyfiles": "^2.4.1", 16 | "eslint": "^9.10.0", 17 | "eslint-config-prettier": "^9.0.0", 18 | "love-typescript-definitions": "^11.5.0", 19 | "lua-types": "^2.13.1", 20 | "prettier": "^3.2.5", 21 | "prettier-plugin-organize-imports": "^4.0.0", 22 | "typescript-to-lua": "^1.25.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LÖVE 2D TypeScript Project Template 2 | 3 | A template LÖVE 2D TypeScript Project made possible with [TypeScriptToLua](https://github.com/TypeScriptToLua/TypeScriptToLua). 4 | 5 | You can click `Use this template` to clone this repo, or download it as a zip. 6 | 7 | ## Scripts 8 | 9 | Requires [NodeJS](https://nodejs.org/en/download/) and [LÖVE 2D](https://love2d.org/) within your CLI. 10 | 11 | | Command | Description | 12 | | ---------------------- | ------------------------------------------------ | 13 | | `npm install` | ⏬ Install dependencies | 14 | | `npm run build` | 🔨 Build everything | 15 | | `npm run watch` | 🔨x♾ Re-build Lua files when a TS file is saved | 16 | | `npm start` | 🎮 Start the game | 17 | | `npm run fix:prettier` | 💄 Fixes linting issues | 18 | | `npm run lint` | 💄 Checks for linting issues in code | 19 | 20 | To distribute the game, see the [game distribution wiki page](https://love2d.org/wiki/Game_Distribution). 21 | 22 | External files can be placed in `res/` and referenced with `res/`. 23 | 24 | e.g. 25 | 26 | ```ts 27 | love.filesystem.read("res/input.txt"); 28 | ``` 29 | 30 | ### Notes 31 | 32 | - If you're using VS Code, the [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extension will automatically format your code for you so you don't need to run `npm run fix:prettier` on every change. 33 | - Index your arrays at 0 in your source code. 34 | - Lua does not iterate over sparse arrays (arrays with no values in the middle of them). 35 | 36 | ### Links 37 | 38 | - [TypeScriptToLua Wiki](https://github.com/TypeScriptToLua/TypeScriptToLua/wiki) 39 | - [Writing Declarations](https://github.com/TypeScriptToLua/TypeScriptToLua/wiki/Writing-Declarations) 40 | - [Compiler Directives](https://github.com/TypeScriptToLua/TypeScriptToLua/wiki/Compiler-Directives) 41 | - [LÖVE 2D Wiki](https://love2d.org/wiki/Main_Page) 42 | - [LÖVE 2D - Getting Started](https://love2d.org/wiki/Getting_Started) 43 | --------------------------------------------------------------------------------