Skip to main content

Python game framework inspired by LÖVE2D

Project description

pylove2D PyPI version Python Version

PyLove2D is a Python game framework inspired by LÖVE2D. It allows you to quickly build 2D games using Python and Pygame, with a simple API for graphics, input, audio, and more.

Github


Features

  • Graphics: Draw shapes, images, and text easily.
  • Audio: Play sound effects and music.
  • Input: Keyboard, mouse, and joystick support.
  • Timer: Schedule delayed or repeated actions.
  • Math utilities: Vectors and transformations.
  • Filesystem helpers: Load/save data easily.

Installation

PyLove2D requires Python 3.10+ and Pygame. Install via pip:

pip install pygame-ce pylove2d

Getting Started

To install PyLove2D run this command in your terminal:

pip install pylove2d

Basic Game Example :

Create a file main.py:

import pylove2d as love

def load():
    love.window.set_title("Hello PyLove2D!")

def update(dt):
    pass

def draw(g):
    g.clear(0.1, 0.1, 0.2)
    g.set_color(1, 1, 1)
    g.print("Hello, World!", 200, 200)

if __name__ == "__main__":
    love.run(width=800, height=480)

Run your game:

python main.py

You should see a window with “Hello, World!” on a dark background.

API Overview

Graphics

love.graphics.set_color(1, 0, 0)
love.graphics.rectangle("fill", 100, 100, 50, 50)

Input

if love.input.key_down("left"):
    print("Moving left")

Audio

sound = love.audio.Source("sound.wav")
sound.play()

Timer

love.timer.after(2, lambda: print("2s passed"))
love.timer.every(1, lambda: print("Every 1s"))

Examples

Pong :

import pylove2d as love

p1 = {'y': 200}
p2 = {'y': 200}

def load():
    love.window.set_title("Pong")

def update(dt):
    if love.input.key_down("w"): p1['y'] -= 200 * dt
    if love.input.key_down("s"): p1['y'] += 200 * dt

def draw(g):
    g.clear(0, 0, 0)
    g.set_color(1, 1, 1)
    g.rectangle("fill", 50, p1['y'], 20, 100)

Platformer

import pylove2d as love

player = {'x':100,'y':300,'vx':0,'vy':0,'w':40,'h':60,'on_ground':False}

def update(dt):
    if love.input.key_down("left"): player['vx'] = -200
    elif love.input.key_down("right"): player['vx'] = 200
    else: player['vx'] = 0
    player['vy'] += 800 * dt
    player['x'] += player['vx'] * dt
    player['y'] += player['vy'] * dt

def draw(g):
    g.clear(0.1,0.1,0.2)
    g.set_color(0.8,0.3,0.3)
    g.rectangle("fill", player['x'], player['y'], player['w'], player['h'])

Project Structure

pylove2d/ ├── pylove2d/ │ ├── __init__.py │ ├── app.py │ ├── graphics.py │ ├── input.py │ └── ... ├── examples/ ├── tests/ ├── README.md ├── LICENSE ├── pyproject.toml └── setup.py

Contributing :

Contributions are welcome! Please:

Fork the repository

Create a feature branch: git checkout -b feature/myfeature

Commit your changes: git commit -m "Add my feature"

Push to branch: git push origin feature/myfeature

Open a Pull Request

License

MIT License © 2025 nnei

Tips :

Always run in a virtual environment.

Use pip install --upgrade pylove2d to update to the latest version.

Check the examples/ folder for ready-to-run demos.

See examples/pong/main.py for a full example.

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

pylove2d-0.2.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

pylove2d-0.2.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file pylove2d-0.2.1.tar.gz.

File metadata

  • Download URL: pylove2d-0.2.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for pylove2d-0.2.1.tar.gz
Algorithm Hash digest
SHA256 65ff5a4e6432385e2e446ce5d612cce92943ded2bf8d464b393d1fb8530d4842
MD5 fb5d2ccd106d157dc1d639715094a6de
BLAKE2b-256 99b1f69efcf84dafa7f390aaf27a1fc60968badf2dfc5d8202fd8c892cd4ceb1

See more details on using hashes here.

File details

Details for the file pylove2d-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pylove2d-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for pylove2d-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21d275f2b24a0c63ec3fbf90563ff4437701cafc7c72248cf9d1ca04d67be62e
MD5 deb48f925e37536a4deec5c473b83215
BLAKE2b-256 f7eff820e4cbacf077fee5c9e74c0800d9536028f79ea3f9ea69a84b764e10a4

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