https://github.com/mandaw2014/mandawenginesdl
A 2D Python GameEngine Made With PySDL2
https://github.com/mandaw2014/mandawenginesdl
gameengine gameengine2d mandawengine pysdl2 python sdl2
Last synced: 5 months ago
JSON representation
A 2D Python GameEngine Made With PySDL2
- Host: GitHub
- URL: https://github.com/mandaw2014/mandawenginesdl
- Owner: mandaw2014
- License: mit
- Created: 2021-09-04T13:48:24.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-11-22T21:47:09.000Z (over 3 years ago)
- Last Synced: 2024-12-04T20:18:47.846Z (5 months ago)
- Topics: gameengine, gameengine2d, mandawengine, pysdl2, python, sdl2
- Language: Python
- Homepage: https://mandaw2014.github.io/MandawEngineSDL/
- Size: 375 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MandawEngine
A 2D Python GameEngine Made With PySDL2Discord: 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
```py
from mandaw import *
```
Call Mandaw
```py
mandaw = Mandaw(title = "Window!", width = 800, height = 600, bg_color = (0, 0, 0, 255))
```
To run it, type
```py
mandaw.loop()
```# Creating A Square
Here is what we have so far
```py
from mandaw import *mandaw = Mandaw(title = "Window!", width = 800, height = 600, bg_color = (0, 0, 0, 255))
mandaw.loop()
```
To create a square, type
```py
square = Entity(window = mandaw, width = 20, height = 20, x = 0, y = 0, color = (255, 255, 255, 255))
```
Center it with
```py
square.center()
```
Then draw it
```py
@mandaw.draw
def draw():
square.draw()
```
Like this
```py
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
```py
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`
```py
@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