Skip to main content

A 2D GameEngine Made In Python With PySDL2

Project description

MandawEngine

A 2D Python GameEngine Made With PySDL2

Discord: https://discord.gg/MPPqj9PNt3

Installation

To install: Download the zip: Code->Download Zip Extract it Go into the extracted folder and Type in CMD or Terminal:

pip install setup.py

Creating A Window

First, import mandaw

from mandaw import *

Call Mandaw

mandaw = Mandaw(title = "Window!", width = 800, height = 600, bg_color = (0, 0, 0, 255))

To run it, type

mandaw.loop()

Creating A Square

Here is what we have so far

from mandaw import *

mandaw = Mandaw(title = "Window!", width = 800, height = 600, bg_color = (0, 0, 0, 255))

mandaw.loop()

To create a square, type

square = Entity(window = mandaw, width = 20, height = 20, x = 0, y = 0, color = (255, 255, 255, 255))

Center it with

square.center()

Then draw it

@mandaw.draw
def draw():
    square.draw()

Like this

from mandaw import *

mandaw = Mandaw(title = "Window!", width = 800, height = 600, bg_color = (0, 0, 0, 255))

square = Entity(window = mandaw, width = 20, height = 20, x = 0, y = 0, color = (255, 255, 255, 255))
square.center()

@mandaw.draw
def draw():
    square.draw()

mandaw.loop()

Basic Input In MandawEngine

What we have so far

from mandaw import *

mandaw = Mandaw(title = "Input!", width = 800, height = 600, bg_color = (0, 0, 0, 255))

square = Entity(window = mandaw, width = 100, height = 100)
square.center()

@mandaw.draw
def draw():
    square.draw()

mandaw.loop()

To Move the square, we can use the built in update function along with mandaw.input

@mandaw.update
def update(dt):
    if mandaw.input.pressed[mandaw.input.keys["W"]]:
        square.y -= 100 * dt
    if mandaw.input.pressed[mandaw.input.keys["A"]]:
        square.x -= 100 * dt
    if mandaw.input.pressed[mandaw.input.keys["S"]]:
        square.y += 100 * dt
    if mandaw.input.pressed[mandaw.input.keys["D"]]:
        square.x += 100 * dt

dt here, represents deltaTime

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

mandaw-2.3.0.tar.gz (6.8 kB view hashes)

Uploaded Source

Built Distribution

mandaw-2.3.0-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page