Skip to main content

Create and interact with your very own Tamagotchi character using Python! \(^ 3 ^)/

Project description

workflow workflow

Tamagotchi

Description

Tamagotchi is a Python package where you care for your pixelated pet in pure text form while you code! This package allows users to care for an ASCII-rendered pet by feeding, patting, and customizing its environment. This project includes modules for user interaction, ASCII art conversion, and an engaging game interface.

Find us on PyPI here.

Usage

Importing the Tamagotchi Class

To use the Tamagotchi class

from tamagotchi import Tamagotchi

Class Initialization

tamagotchi = Tamagotchi()

Creates a new Tamagotchi instance with default attributes, including a blank name, a white background, and a default food item (apple).

Methods

#### run_game()

The primary method to initialize and run the Tamagotchi game. This method launches the tkinter interface to input the pet's name and start interactions.

tamagotchi.run_game()


get_pet(number)

Retrieves an ASCII representation of a specific pet based on the input number. This function reads from a text file, which should be named tama-<number>.txt.

  • Parameters:
    • number (int ): Identifier for the pet image file.
  • Returns : ASCII string of the pet image orNone if not found.

tamagotchi.getpet(1)


get_ascii_art(image_path, scale=0.1, character_map=G_SCALE_1)

Converts an image into ASCII art based on grayscale values.

  • Parameters:
    • image_path (str ): Path to the image file.
    • scale (float ): Scale factor for resizing the image.
    • character_map (str ): Characters to map grayscale values for ASCII art.
  • Returns : ASCII art string orNone if image not found.

ascii_art = tamagotchi.get_ascii_art("path/to/image.jpg")


start_game()

Internal function that initializes the game window once the pet name is entered. Should not be called directly but is used in run_game().


game_window()

Internal function to create the main game window where the pet is displayed. Not typically called directly.


change_background_color(color)

Changes the background color of the pet display.

  • Parameters:
    • color (str): Background color (e.g., "blue").

tamagotchi.change_background_color("lightblue")


feed(food)

Simulates feeding the Tamagotchi with a specified food item.

  • Parameters:
    • food (str): Name of the food.

tamagotchi.feed("banana")


pat(times)

Simulates patting the pet a specified number of times.

  • Parameters:
    • times (int): Number of pats.

tamagotchi.pat(3)


Example

Find an example project that shows how to use each function here.

Contributing

Installation

pip install pipenv
git clone https://github.com/software-students-fall2024/3-python-package-macaron-for-three.git
cd 3-python-package-macaron-for-three
pipenv install --dev
pipenv shell
pipenv install -e .
python -m pip install --upgrade pip setuptools wheel

// to build:
pip install build
python -m build

// install built package for testing
pip install dist/*.whl 

// to test
pytest

To Use and Run

pip install tamagotchi
tamagotchi

Note: to upload an image, make sure your file is in the same directory you install this package in.

Teammates

Hang Yin

Sahar Bueno-Abdala

Jessica Xu

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

tamagotchi-0.1.1.tar.gz (4.0 MB view details)

Uploaded Source

Built Distribution

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

tamagotchi-0.1.1-py3-none-any.whl (4.6 MB view details)

Uploaded Python 3

File details

Details for the file tamagotchi-0.1.1.tar.gz.

File metadata

  • Download URL: tamagotchi-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for tamagotchi-0.1.1.tar.gz
Algorithm Hash digest
SHA256 74911b329ef199aa42a7f6f54ca6a1212c8dfa3f55a1e2987a903c72bb4289bf
MD5 319edfda11585c793f9f0728c8ed8d5b
BLAKE2b-256 56fa6c87599e773efe9ad8d3837eab3712e757c1991b19f2c3524d649d4be038

See more details on using hashes here.

File details

Details for the file tamagotchi-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tamagotchi-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for tamagotchi-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd78977f2b9022b699b28f29bfa93caebe2301141eda28ad535263d55fae6cc1
MD5 4ebe41858b208c78a02985fbb850071b
BLAKE2b-256 096dd802ef26cf3a3f41a81012e356c1f977d8de7d6131ec1ca09a98da10dc60

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