Skip to content

Emmyme/virtual-pet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Pet Terminal App

A simple terminal-based virtual pet game built with Go, featuring real-time pet interactions and ASCII art.

Features

Gameplay

  • Two pet types: cat or bunny
  • Real-time stats: hunger, happiness, and energy bars
  • Interactive commands: feed, play, sleep, and pet
  • Automatic sleep system when energy is low
  • Arrow key navigation for pet selection
  • Colourful UI with heart-themed border

Installation

Prerequisites

  • Go 1.21 or higher
  • A terminal with Unicode support

Quick Start

# Clone the repository
git clone https://github.com/emmyme/virtual-pet.git
cd virtual-pet

# Install dependencies
go mod tidy

# Run the application
go run main.go

How to Play

Getting Started

  1. Enter your pet's name and press Enter
  2. Use arrow keys to select between Cat or Bunny, then press Enter
  3. Use the following commands to care for your pet:

Pet Name Choose Pet

Commands

  • f - Feed your pet (restores hunger)
  • p - Play with your pet (increases happiness)
  • s - Put your pet to sleep (restores energy)
  • t - Pet your pet (increases happiness)
  • q or Ctrl+C - Quit the game

Pet Stats

  • Hunger: Decreases over time, feed to restore
  • Happiness: Decreases over time, play or pet to increase
  • Energy: Decreases over time, sleep to restore
  • Mood: Automatically changes based on stats (happy, unhappy, asleep)

Sleep System

  • Pets automatically fall asleep when energy reaches 0
  • After 5 minutes of sleep, pets wake up with full energy

Project Structure

virtual-pet/
├── main.go          # Main application with Bubble Tea UI
├── pet/
│   ├── pet.go       # Pet struct and core logic
│   ├── cat.go       # Cat ASCII art
│   ├── bunny.go     # Bunny ASCII art
│   └── stats.go     # Progress bar rendering
├── go.mod           # Go module definition
└── README.md        # This file

Technical Details

Built With

  • Go: Core programming language
  • Bubble Tea: Terminal UI framework
  • Lipgloss: Terminal styling library

Dependencies

This project uses the following open-source libraries:

  • Bubble Tea by Charm - A framework for building terminal user interfaces
  • Lipgloss by Charm - Style definitions for nice terminal layouts and colors

Key Features

  • Concurrent programming with goroutines and channels
  • Real-time updates every 5 seconds
  • Cross-platform compatibility

Troubleshooting

Colors not displaying correctly:

  • Ensure your terminal supports 256-color mode
  • Try using a modern terminal emulator

Unicode characters showing as boxes:

  • Update your terminal font to support Unicode

Application not responding:

  • Make sure your terminal window is at least 80x24 characters
  • Check that you're using Go 1.21 or higher

License

This project is licensed under the MIT License.


Have fun!

About

A terminal virtual pet game with real-time interactions, ASCII art, and colourful UI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages