Skip to content

codi-hacks/space-race

Repository files navigation

Luacheck Unit Tests Coverage Status License: GPL v3

Spaceship Game!

Use w/a/s/d to move laterally via velocity. Press shift and arrow keys to "teleport" laterally.

Use a/d to spin the ship left/right and w/s to boost forward/backward. Press space to brake.

Press b for debug information.

Press p to pause.

Running

Install love2D and run love . in the main directory. That's it!

Of course, this game is still in development, so please expect bugs.

Development

Architecture

This project is loosely based on the Entity-Component-System (ECS) architecture. Here is some of the jargon we use in the context of this project:

  • Entity - These are described as tables (object) in the entities/ folder, though strictly speaking the entities are the instances of these objects that exist during gameplay and are bound to the Box2D World singleton via its body, shape, and perhaps a fixture.
    • Factory functions - These are the functions returned by each "file" in the entity directory. The reason these return functions that return tables instead of just returning tables directly is because when we spawn any type of entity multiple times we want each table to be a unique copy and that's what functions do well. A "planet factory function" says it all... a function that's like a giant factory pumping out planets!
    • Props - In addition to returning table copies during entity spawning, factory functions can be passed in a "props" table to override some of the default aspects of an entity.
  • Components - Components are functions that you attach to an entity table within the entity files. These can be either inline functions or defined in a separate "components" folder. In a game with lots of similar entities, the same component may be utilized between many types of entities.
  • Systems - These are functions invoked at the top level of the game loop, having every entity passed through them. A system's job is to define what entities it is allowed to operate with and then proceed whenever it receives a match. Note that "System" is also the name of the knife.system library used on this project to define Systems. However the library can and may be utilized to define things that aren't strictly Systems in the ECS sense so there is potential for confusion there.
    • Aspects - These are essentially the key names attached to the entity table, but the term is useful in the context of the System API

Linting

You can check your changes against the linter in realtime by installing a luacheck plugin for your editor or running luacheck . command (assuming you have luacheck installed).

Docker

Alternatively, you can run the linter as well as the (busted) unit tests if you have Docker installed. Once docker is installed and running, simply invoke one of the make commands:

make test  # Run linter and unit tests
make test-lint  # Just luacheck
make test-unit  # Just busted

Releases

No releases published

Packages

No packages published

Languages