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_pet = 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_pet.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_pet.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_pet.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_pet.change_background_color("lightblue")


feed(food)

Simulates feeding the Tamagotchi with a specified food item.

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

tamagotchi_pet.feed("banana")


pat(times)

Simulates patting the pet a specified number of times.

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

tamagotchi_pet.pat(3)


Example

from tamagotchi import tamagotchi 

tamagotchi_game = tamagotchi.Tamagotchi()
tamagotchi_game.name = 'Fluffy'
print(tamagotchi_game.getpet(1))

# make sure you have a file called input_image.png in the same directory, or make sure you give a correct image path for this function to work

print(tamagotchi_game.get_ascii_art("input_image.png", scale=0.1, character_map=tamagotchi.Tamagotchi.G_SCALE_1))
tamagotchi_game.ascii_art_label = tamagotchi_game.getpet(11)
tamagotchi_game.feed("banana")
tamagotchi_game.change_background_color("blue")
tamagotchi_game.run_game()

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==0.1.2
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.2.tar.gz (167.1 kB 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.2-py3-none-any.whl (164.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tamagotchi-0.1.2.tar.gz
  • Upload date:
  • Size: 167.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tamagotchi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a7f7f56adf40cbfbb49a3d29a197aa7ce22b3b924b8624b441654a04ff063c42
MD5 fda70073a3782b5d2630a50acb24cacb
BLAKE2b-256 5654edf9ed99d2ae84dda9924ee6938a1395eb8d2bb5ca0abe0b6370440ce501

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tamagotchi-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 164.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for tamagotchi-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea451f5fcffa490ab3e9d3928d717100342d0e562aff284b2647e781450050b4
MD5 024871abe7b69075740da57ee9d3581e
BLAKE2b-256 a70d1947c81aad930c277bb5ec26f6983d69ed5f0e575236c252678028c3a9d1

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