Skip to main content

A game engine... for the console

Project description

A very simple console game engine

A functional game engine. How does it work? Well, there are two core parts of this engine. The game state dictionary, and the entity system.

Game state dictionary

The game state dictionary is a dictionary containing the game state as well as entities. Good Console++ code uses the dictionary to store data instead of global variables.

The game state dictionary must contain two keys: "running" and "entities". "running" is a bool. At the end of every iteration of the main loop, if running is false, the loop ends."entities" is a dictionary of Entity. More on that later

The game state is important because of how you update it. Every frame input is taken, and passed to a function that you define along with the game state. The call looks like this: game(state, key). This call returns a new dictionary which replaces the old one.

Entity system

The entity system is simple. There is a class called Entity. Its constructor takes 4 parameters: x, y, char, style.

Each iteration of the main loop, each entity calls update() (so, entity.update(). Then, they are drawn at the x and y with the char and style. Update is a stub, but you can extend entity to add your own behaviour.

Main loop

Finally, to initialize the main loop, run

run_loop(game, {"running": True, "entities": {
  "player": Entity(10, 10, "@", style.RED)
  }})

Replace game with your own update function, and add and remove entities.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

consoleplusplus-0.1.0.1.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

consoleplusplus-0.1.0.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file consoleplusplus-0.1.0.1.tar.gz.

File metadata

  • Download URL: consoleplusplus-0.1.0.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for consoleplusplus-0.1.0.1.tar.gz
Algorithm Hash digest
SHA256 e2b53025e0c497f98144a41960a0a4d9b4133a7cddb404f08a413ef2a38938aa
MD5 c0caebb41636847f8c8989c5b89e00dd
BLAKE2b-256 c42ff6a2544b8378c44479f04a483fb7f6eb255135527af64bc6e590a70fa798

See more details on using hashes here.

File details

Details for the file consoleplusplus-0.1.0.1-py3-none-any.whl.

File metadata

  • Download URL: consoleplusplus-0.1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for consoleplusplus-0.1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b67adafd43ad0fa12436f5c6b93372afa31fc476b680efee41d1789474243506
MD5 29e119c07be58adfd8b216f9ef543e38
BLAKE2b-256 fb66a507b47ea983203f9e0357c558c043b707c3ad5cc7d23b2d9be25c0fea98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page