Skip to main content

A library for implementing something similar to Pygame in the command line.

Project description

TUI_game

A simple Text-Based User Interface (TUI) game framework for creating terminal-based games. This module allows you to create a text-based game with mouse control, character placement, and screen updates.

Features

  • Initialize screen dimensions based on user input.
  • Control a mouse cursor using 'w', 's', 'a', 'd' keys.
  • Place characters at specific coordinates on the screen.
  • Refresh the screen to reflect changes.
  • Exit the game loop gracefully.

Installation

To install TUI_pygame, you can use pip:

pip install TUI_pygame

Usage

Basic Example

Here's a basic example of how to use the TUI-game module:

import TUI_game
import time

# Initialize the game screen
TUI_pygame.initialize()

# Main game loop
while True:
    if not TUI_game.run():
        break
    TUI_game.update_screen()
    time.sleep(0.001)  # Add a brief delay to prevent the program from running too fast

Customizing the Game Loop

You can also customize the game loop by adding your own logic:

import TUI_pygame
import time

# Initialize the game screen
TUI_pygame.initialize()

# Custom game loop
while True:
    # Place a character at a specific position
    TUI_pygame.place_character('X', (5, 5))
    
    # Move the mouse cursor
    TUI_pygame.move_mouse('w')
    
    # Process user input
    if not TUI_pygame.run():
        break
    
    # Update the screen
    TUI_game.update_screen()
    
    # Add a brief delay
    time.sleep(0.001)

Functions

initialize() Initializes the screen dimensions and content. This function must be called before entering the game loop.

run() Processes user input and returns True to continue the game loop or False to exit.

update_screen() Refreshes the screen to reflect changes.

place_character(character, position) Places a character at the specified coordinates on the screen.

move_mouse(direction) Moves the mouse cursor in the specified direction ('w', 's', 'a', 'd').

Contributing

Contributions are welcome! If you have any suggestions or improvements, please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

tui_pygame-0.1.3.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

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

tui_pygame-0.1.3-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file tui_pygame-0.1.3.tar.gz.

File metadata

  • Download URL: tui_pygame-0.1.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for tui_pygame-0.1.3.tar.gz
Algorithm Hash digest
SHA256 0985dd6a551b67c7d7a00aea84efce6a28eb1ad22b28f5b058462966164b88a9
MD5 42c1bbfa318795a121a611347240f16a
BLAKE2b-256 0a146d0014b5ebc8e69e8b1bbfc9fe10e92375281ad2a8ac7682b0041d1257b0

See more details on using hashes here.

File details

Details for the file tui_pygame-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: tui_pygame-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for tui_pygame-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f3d441c0ae67641975b425d74eea49e89540b7a1b2747a6af60e6a0b00735eed
MD5 6364e6c7a1148e3422994ca07b966b5a
BLAKE2b-256 c080a754b4fd30cdc259a100eee1735cead09639412032354c258f72fc04d528

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