Skip to main content

laylib package for pygame

.. image:: https://img.shields.io/badge/License-MIT-yellow.svg :target: https://opensource.org/licenses/MIT

.. image:: https://img.shields.io/badge/version-1.1.9-red.svg :target: https://pypi.org/project/laylib

.. image:: https://travis-ci.org/Layto888/laylib.svg?branch=master :target: https://travis-ci.org/Layto888/laylib

This package is made to fast prototype your multimedia applications like games on pygame. Write clean and pragmatic design. It lets you focus on the game engine itself, so you don't have to take care about several details like setting up the window, loading and checking data (images, sound, font, fx, music, resources names...). All you need to do is to put your resources into a specific data folder and use them in your game class 'MyEngine()'.

You don't need to reinvent the wheel, some repetitive parts of code (main loop, getting the delta time, closing the window, drawing text...) are already described and ready to use in the default engine.

Usage example :

  • Template main file

.. code-block:: python

from laylib import Environment
from engine import Engine
import sys

def main():
demo = Environment(800, 600, False, 'My game')
demo.load_complete(Engine(), 'data')
demo.gInstance.main_loop()
demo.destroy()

if __name__ == "__main__":
sys.exit(main())
  • Template engine file

.. code-block:: python

import pygame as pg
from laylib import DefaultEngine

BLACK = (0, 0, 0)
FPS = 30.0


class Engine(DefaultEngine):
	""" Short summary.
	"""

	def __init__(self):
		super().__init__()
		self.setup()

	def update(self):
		""" Code to update all classes : 
		the global behavior should be written here.
		"""
		pass

	def draw(self):
		self.screen.fill(BLACK)
		""" Code to draw all classes
		"""
		pg.display.update()

	# init engine or set up environement

	def setup(self):
		self.playing = True
		# rescale in laylib time unit to 100.0 as example
		self.time_unit = 100.0
		self.fps = FPS
		"""
		rest of init code
		"""

INSTALLATION

First, install the dependencies:

.. code-block:: bash

$ pip install -r requirements.txt

Then install laylib:

.. code-block:: bash

$ pip install laylib

Or alternatively, you can just copy the "laylib" folder into the same directory as the Python program that uses it.

USAGE

For usage see examples provided with laylib. For more details, all other parts of documentation are described in the source file.

Release History

  • 1.1.9

    • removed ressources.bin parameter
  • 1.1.8

    • version 1.1.7 revision
    • add demo4, rain demo
    • add FPS control, now we can set fps with "self.fps" in the main engine to control frame rate.
  • 1.1.7

    • version 1.1.6 revision
    • update demo1
  • 1.1.6

    • class Music in resources.py: add the function play() to control the music playlist and the volume
    • update demo1 to integrate music play() function.
    • all private methods prefixed with underscore
    • one common data folder for test and demo, to reduce size.
  • 1.1.5

    • in Resources manager: the sound format .ogg is moved to Music class and removed from Sound 'fx' class.
    • relative path to test_laylib changed
    • variable self.all_sprites = pg.sprite.Group() set directly in the DefaultEngine class.
    • add demo1 example to show how to manage resources with laylib
    • updating test_laylib for the 1.1.5 version
    • update documentation in the source files.
  • 1.1.4

    • Add Travis CI file
    • bug fix rotate function util.py file
    • changed value 3.14 to math.pi deg2rad function util.py
    • add complete test module
    • changed README.md to README.rst
  • 1.1.3

    • Bug version package fix (init.py file).
  • 1.1.2

    • Removed functions: load_global()/destroy_global() from Resources class.
    • Bug version fix (setup.py file).
  • 1.1.1

    • Now we can set the 'time_unit' to change the delta_time unit.
    • Minor bugs fix on util.py
  • 0.1.0

    • The first proper release
  • 0.0.1

    • Work in progress

Meta

Amardjia Amine – amardjia.amine@gmail.com Distributed under the MIT license.

Release files for laylib 1.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for laylib 1.1.9
File Size Uploaded
laylib-1.1.9.tar.gz 11.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for laylib 1.1.9
File Interpreter ABI Platform
laylib-1.1.9-py3-none-any.whl Python 3 none any Details

Total release size:24.0 kB

Release files / laylib-1.1.9.tar.gz

Download URL laylib-1.1.9.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
05294299fc209b4e64463e21621e8fc37f54d8d86e1b3b0200580a80fa017bf8
BLAKE2b-256 checksum
How to use checksums
68a8cc632043994a404116621336e8cdb061ea26b80970d3745c44f493746476
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.8.1 pkginfo/1.5.0.1 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Release files / laylib-1.1.9-py3-none-any.whl

Download URL laylib-1.1.9-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9586d54081bb6d8bf1ab56a547e3cb173227d1069fa4cbdbed8da322ed61304d
BLAKE2b-256 checksum
How to use checksums
ed4ce91d98a7fc16f4b68d6003cd744ad52daf25639c35c497bce5d58a92256e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.8.1 pkginfo/1.5.0.1 requests/2.20.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.3

Release history Release notifications | RSS feed

This release

1.1.9 This release

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page