Skip to main content

A practical 2D game framework for Python with scenes, camera, particles, multiplayer networking, CLI host/join tools, and chunked tilemaps

Project description

Easy2D

Easy2D is a general-purpose 2D game framework for Python built on pygame. It is designed to support many kinds of 2D games: arcade, platformer, top-down, RPG-style, puzzle, shooter, story-driven, menu-heavy, multiplayer prototypes, and experimental projects.

Install

pip install easy2d

Quick Start

import easy2d as e

game = e.Game("My Game", 960, 540, fps=120)

class MainScene(e.Scene):
    def __init__(self):
        super().__init__()
        self.player = self.add(e.Rect(100, 100, 32, 32, gravity=0.0, floor_y=None))
        self.title = self.add(e.Text("Hello Easy2D", 20, 20))
        self.button = self.add(e.Button("Play", 100, 100, 180, 50, on_click=self.play))

    def play(self):
        print("Play clicked")

game.set_scene(MainScene())
game.run()

Display and Fullscreen

game = e.Game(
    "Display Demo",
    960,
    540,
    fullscreen=False,
    resizable=True,
    vsync=True,
    scale_mode="fit",  # native | fit | stretch | pixel-perfect
)

game.toggle_fullscreen()
game.set_resolution(1280, 720)

UI

scene.add(e.Text("Settings", 30, 20, size=30))
scene.add(e.Panel(20, 50, 420, 260))
scene.add(e.Button("Apply", 40, 80, 170, 44, on_click=apply_settings))
scene.add(e.TextInput(40, 140, 240, 40, placeholder="Player name"))
scene.add(e.Checkbox(40, 200, text="Fullscreen"))
scene.add(e.Slider(40, 250, 220, min_value=0, max_value=100, value=75))

Sprites and Animation

player = e.Sprite("assets/player.png", 100, 100)
player.scale = 2
player.flip_x = True
player.rotation = 8

anim = e.AnimatedSprite(200, 100)
anim.add_animation("idle", ["idle1.png", "idle2.png"], fps=6)
anim.add_animation("run", ["run1.png", "run2.png"], fps=12)
anim.play("run")

Audio and Assets

game.assets.load_image("player", "assets/player.png")
game.assets.load_json("level", "assets/level1.json")
game.assets.load_font("main", size=24)

game.audio.load_sound("coin", "assets/coin.wav")
game.audio.play_sound("coin")
game.audio.play_music("assets/theme.mp3", loop=True)

Particles

fx = e.ParticleSystem.explosion()
fx.emit_burst(200, 200, count=40)

Networking Helpers

server = e.MultiplayerServer(port=5000)
server.start()
server.broadcast({"type": "chat", "text": "hello"})
messages = server.get_messages()

client = e.MultiplayerClient()
client.connect("127.0.0.1", 5000)
client.send({"type": "hello"})
inbox = client.get_messages()
client.disconnect()

CLI

easy2d --help
easy2d --show-scope
easy2d --multiplayer
easy2d --multiplayer --port 7777
easy2d --host --port 5000
easy2d --join 127.0.0.1 --port 5000 --message "hello"
easy2d --net-test --port 5000
easy2d --list-examples
easy2d --write-example basic
easy2d --write-example ui
easy2d --write-example particles
easy2d --write-example multiplayer
easy2d --write-all-examples
easy2d new arcade MyGame
easy2d new topdown MyTopDown
easy2d new shooter MyShooter

Current Scope

  • Scene-based game loop
  • Camera follow/zoom/shake
  • Tilemaps with chunk caching
  • UI widgets
  • Sprite and basic animation classes
  • Particle systems
  • Audio and asset managers
  • Timer and tween helpers
  • Beginner-friendly multiplayer relay helpers

Roadmap

  • Expanded physics and collision response
  • Sprite atlas/animation tools
  • Save/load helper utilities
  • Optional higher-level networking patterns
  • Additional UI widgets and layout helpers

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

easy2d-0.5.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

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

easy2d-0.5.0-py3-none-any.whl (28.3 kB view details)

Uploaded Python 3

File details

Details for the file easy2d-0.5.0.tar.gz.

File metadata

  • Download URL: easy2d-0.5.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for easy2d-0.5.0.tar.gz
Algorithm Hash digest
SHA256 4986dc0cb7e053eab0f2fe17d7e962c368b02f5a252fed29a64804146239b918
MD5 d1030012558c395629a0e91b49aef094
BLAKE2b-256 63501aa9c6adfb943b741ef429fe459f0376a49502f87e8d8a7b57bb92cb1166

See more details on using hashes here.

File details

Details for the file easy2d-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: easy2d-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 28.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for easy2d-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5152939bb325e320acc5856d3cdb929778cfd1d432c2a62faf2f8ec5830004a2
MD5 9169c68e7d505005147a3418310a9604
BLAKE2b-256 757b00e834ec2079dd164fc8af4e189a0f433f98922c00b2de25605098a83248

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