A simple terminal-based virtual pet game built with Go, featuring real-time pet interactions and ASCII art.
- 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
- Go 1.21 or higher
- A terminal with Unicode support
# 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- Enter your pet's name and press Enter
- Use arrow keys to select between Cat or Bunny, then press Enter
- Use the following commands to care for your pet:
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)qorCtrl+C- Quit the game
- 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)
- Pets automatically fall asleep when energy reaches 0
- After 5 minutes of sleep, pets wake up with full energy
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
- Go: Core programming language
- Bubble Tea: Terminal UI framework
- Lipgloss: Terminal styling library
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
- Concurrent programming with goroutines and channels
- Real-time updates every 5 seconds
- Cross-platform compatibility
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
This project is licensed under the MIT License.
Have fun!