├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── ci_check.yml │ ├── lint.yml │ └── mkdocs.yml ├── .gitignore ├── CNAME ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── docs ├── CNAME ├── assets │ ├── gifs │ │ └── example.gif │ ├── logo │ │ ├── fe.png │ │ └── fusion-banner.png │ └── tutorials │ │ └── result.png ├── changelog │ ├── v3.md │ ├── v4.md │ └── v5.md ├── get-started.md ├── index.md ├── legacy │ ├── index.md │ ├── v3 │ │ ├── api │ │ │ ├── api.md │ │ │ ├── color.md │ │ │ ├── fonts.md │ │ │ ├── index.md │ │ │ ├── keys.md │ │ │ └── math.md │ │ ├── assets │ │ │ ├── gifs │ │ │ │ └── example.gif │ │ │ └── logo │ │ │ │ └── fe.png │ │ ├── tutorials │ │ │ ├── basics.md │ │ │ ├── index.md │ │ │ └── setup.md │ │ └── wiki │ │ │ ├── color.md │ │ │ ├── external.md │ │ │ ├── fonts.md │ │ │ ├── keys.md │ │ │ ├── math.md │ │ │ └── wiki.md │ └── v4 │ │ ├── api │ │ ├── api.md │ │ ├── color.md │ │ ├── fonts.md │ │ ├── index.md │ │ └── keys.md │ │ ├── assets │ │ ├── gifs │ │ │ └── example.gif │ │ └── logo │ │ │ └── fe.png │ │ ├── tutorials │ │ ├── basics.md │ │ └── setup.md │ │ └── wiki │ │ ├── color.md │ │ ├── events-keys.md │ │ ├── external.md │ │ ├── extra.md │ │ ├── fonts.md │ │ ├── math.md │ │ ├── music.md │ │ ├── rendering.md │ │ ├── scene.md │ │ ├── storage.md │ │ ├── ui.md │ │ └── window.md ├── tutorials │ ├── basics.md │ ├── character.md │ └── setup.md └── wiki │ ├── animation.md │ ├── color.md │ ├── events-keys.md │ ├── external.md │ ├── extra.md │ ├── math.md │ ├── music.md │ ├── node.md │ ├── rendering.md │ ├── storage.md │ ├── ui.md │ ├── v5-moving.md │ └── window.md ├── icon ├── fe.png ├── fusion-banner.png └── fusion-banner2.png ├── mkdocs.yml ├── pdm.lock ├── pyproject.toml ├── src └── fusionengine │ ├── __init__.py │ ├── backend │ └── deprecations.py │ ├── engine │ ├── animation.py │ ├── color.py │ ├── debug.py │ ├── draw.py │ ├── entity.py │ ├── enums.py │ ├── event.py │ ├── exceptions.py │ ├── image.py │ ├── keys.py │ ├── manager.py │ ├── math.py │ ├── node.py │ ├── scene.py │ ├── shape.py │ ├── sound.py │ ├── spritesheets.py │ ├── storage.py │ ├── ui.py │ ├── vector.py │ └── window.py │ ├── examples │ ├── example1.py │ ├── example2.py │ ├── example3.py │ ├── example4.py │ └── example5.py │ ├── external │ ├── fe.png │ └── font.ttf │ └── fusiongl │ ├── __init__.py │ ├── binding.py │ └── libgl.py └── tests ├── anim.py ├── codon_test.py ├── encode.py ├── gltest.py ├── opengl.py ├── performance.py ├── pygame_test.py ├── spritesheet.py └── storage_test.py /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/ci_check.yml: -------------------------------------------------------------------------------- 1 | name: CI Check 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - dev 8 | pull_request: 9 | branches: 10 | - main 11 | - dev 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | install: 18 | 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - uses: actions/checkout@v3 23 | - name: Set up Python 3.10 24 | uses: actions/setup-python@v3 25 | with: 26 | python-version: "3.10" 27 | 28 | - name: Update PIP 29 | run: python -m pip install --upgrade pip 30 | 31 | - name: Install packages 32 | run: python -m pip install --user pdm 33 | 34 | - name: Install module (pdm) 35 | run: python -m pdm install 36 | 37 | 38 | build: 39 | 40 | runs-on: ubuntu-latest 41 | 42 | steps: 43 | - uses: actions/checkout@v3 44 | - name: Set up Python 3.10 45 | uses: actions/setup-python@v3 46 | with: 47 | python-version: "3.10" 48 | 49 | - name: Update PIP 50 | run: python -m pip install --upgrade pip 51 | 52 | - name: Install packages 53 | run: python -m pip install --user pdm 54 | 55 | - name: Build module (pdm) 56 | run: python -m pdm build -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | lint: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v3 10 | - uses: psf/black@stable -------------------------------------------------------------------------------- /.github/workflows/mkdocs.yml: -------------------------------------------------------------------------------- 1 | name: MkDocs Deploy 2 | on: 3 | push: 4 | branches: 5 | - main 6 | 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | deploy: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Configure Git Credentials 16 | run: | 17 | git config user.name github-actions[bot] 18 | git config user.email 41898282+github-actions[bot]@users.noreply.github.com 19 | - uses: actions/setup-python@v4 20 | with: 21 | python-version: 3.x 22 | - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV 23 | - uses: actions/cache@v3 24 | with: 25 | key: mkdocs-material-${{ env.cache_id }} 26 | path: .cache 27 | restore-keys: | 28 | mkdocs-material- 29 | - run: pip install mkdocs-material 30 | - run: mkdocs gh-deploy --force 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio Code 2 | .vscode/ 3 | 4 | # Sublime Text 5 | *.sublime-* 6 | 7 | # JetBrains 8 | .idea/ 9 | 10 | # Byte-compiled / optimized / DLL files 11 | __pycache__/ 12 | *.py[cod] 13 | *$py.class 14 | 15 | # C 16 | *.so 17 | *.dll 18 | *.c 19 | 20 | # Distribution / packaging 21 | .Python 22 | build/ 23 | develop-eggs/ 24 | dist/ 25 | downloads/ 26 | eggs/ 27 | .eggs/ 28 | lib/ 29 | lib64/ 30 | parts/ 31 | sdist/ 32 | var/ 33 | wheels/ 34 | share/python-wheels/ 35 | *.egg-info/ 36 | .installed.cfg 37 | *.egg 38 | MANIFEST 39 | 40 | # PyInstaller 41 | # Usually these files are written by a python script from a template 42 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 43 | *.manifest 44 | *.spec 45 | 46 | # Installer logs 47 | pip-log.txt 48 | pip-delete-this-directory.txt 49 | 50 | # Unit test / coverage reports 51 | htmlcov/ 52 | .tox/ 53 | .nox/ 54 | .coverage 55 | .coverage.* 56 | .cache 57 | nosetests.xml 58 | coverage.xml 59 | *.cover 60 | *.py,cover 61 | .hypothesis/ 62 | .pytest_cache/ 63 | cover/ 64 | 65 | # Translations 66 | *.mo 67 | *.pot 68 | 69 | # Django stuff: 70 | *.log 71 | local_settings.py 72 | db.sqlite3 73 | db.sqlite3-journal 74 | 75 | # Flask stuff: 76 | instance/ 77 | .webassets-cache 78 | 79 | # Scrapy stuff: 80 | .scrapy 81 | 82 | # Sphinx documentation 83 | docs/_build/ 84 | 85 | # PyBuilder 86 | .pybuilder/ 87 | target/ 88 | 89 | # Jupyter Notebook 90 | .ipynb_checkpoints 91 | 92 | # IPython 93 | profile_default/ 94 | ipython_config.py 95 | 96 | # pyenv 97 | # For a library or package, you might want to ignore these files since the code is 98 | # intended to run in multiple environments; otherwise, check them in: 99 | # .python-version 100 | 101 | # pipenv 102 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 103 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 104 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 105 | # install all needed dependencies. 106 | #Pipfile.lock 107 | 108 | # poetry 109 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 110 | # This is especially recommended for binary packages to ensure reproducibility, and is more 111 | # commonly ignored for libraries. 112 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 113 | #poetry.lock 114 | 115 | # pdm 116 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 117 | #pdm.lock 118 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 119 | # in version control. 120 | # https://pdm.fming.dev/#use-with-ide 121 | .pdm.toml 122 | .pdm-python 123 | .pdm-build/ 124 | 125 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 126 | __pypackages__/ 127 | 128 | # Celery stuff 129 | celerybeat-schedule 130 | celerybeat.pid 131 | 132 | # SageMath parsed files 133 | *.sage.py 134 | 135 | # Environments 136 | .env 137 | .venv 138 | env/ 139 | venv/ 140 | ENV/ 141 | env.bak/ 142 | venv.bak/ 143 | 144 | # Spyder project settings 145 | .spyderproject 146 | .spyproject 147 | 148 | # Rope project settings 149 | .ropeproject 150 | 151 | # mkdocs documentation 152 | /site 153 | 154 | # mypy 155 | .mypy_cache/ 156 | .dmypy.json 157 | dmypy.json 158 | 159 | # Pyre type checker 160 | .pyre/ 161 | 162 | # pytype static type analyzer 163 | .pytype/ 164 | 165 | # Cython debug symbols 166 | cython_debug/ 167 | 168 | # Others 169 | compile/ 170 | **/.DS_Store 171 | 172 | .pypirc 173 | -------------------------------------------------------------------------------- /CNAME: -------------------------------------------------------------------------------- 1 | docs.fusion-engine.tech -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing rules 2 | We are happy and welcome if you want to contribute to fusion engine. But please consider a few details before continuing: 3 | 1. Branch: Please when working on your fork, work in the dev branch, because we only will accept commits to the dev branch. It will later be released with the next version of fusion. 4 | 2. Explain: Please explain why this should be considered and merged. That will make our life easier. 5 | 3. Test: Please test your code before even opening a new pull request. 6 | 4. Documentation: Please, if your adding something new, like a feature, please document everything. 7 | 5. Format: Please, run black for formatting of the code. 8 | 9 | ## Not following these rules 10 | If we see a pull request that doesn't follow these rules, we will tell you that, and close the pull request. 11 | We allow you to re-open a new pull request, but we expect you to have your code fixed. 12 | So make sure that you followed [the rules](#contributing-rules) 13 | 14 | ## Some technologies we are using 15 | - PDM: We are using pdm for our main interaction with the library. 16 | - pyproject.toml: Pythons way for setting up a project. A replacement for setup.py 17 | - pygame-ce: Used for windowing and events 18 | - FusionGL (ctypes): Used for rendering everything. Its a custom wrapper around OpenGL for python 19 | - pymunk: Will be used for physics 20 | - black: We are using black to format code 21 | 22 | ## How to setup the work environment 23 | If you want to contribute, you got to setup the work environment, so you can develop fusion the right way. First, install PDM using pip: 24 | ```bash 25 | pip install --user pdm 26 | ``` 27 | PDM will manage everything for us, like virtual enviorments, packages and scripts. 28 | 29 | Then, fork [the repository](https://github.com/fusionengine-org/fusion) to your profile. 30 | 31 | Then, clone your forked github repository: 32 | ```bash 33 | git clone https://github.com/your_username_/fusion.git 34 | cd fusion-engine 35 | ``` 36 | Then, change the branch to the dev branch to follow rule #1: 37 | ```bash 38 | git checkout dev 39 | ``` 40 | 41 | After that we need to run a special PDM command for creating the venv with the dev dependencies: 42 | ```bash 43 | pdm install --dev 44 | ``` 45 | This will create a .venv, with all dependencies needed and will install a editable version of fusion engine. This will have the same effect as `pip install -e .`. 46 | 47 | To test if it works properly, run one of the example using PDM: 48 | ```bash 49 | pdm run example1 50 | ``` 51 | 52 | If you want to test documentation code, run the mkdocs command for starting a local server with the documentation. Run it with: 53 | ```bash 54 | pdm run docs 55 | ``` 56 | 57 | If you want to run some specific files, then just run: 58 | ```bash 59 | pdm run your_file.py 60 | ``` 61 | 62 | ## Pull Request 63 | If you're ready with your changes, then you must follow a few steps before pull requesting. 64 | First, run black using PDM to format your code: 65 | ```bash 66 | pdm run lint 67 | ``` 68 | 69 | Then make sure your pull request code works without erroring and you followed the [contribution rules](#contributing-rules) 70 | 71 | After all of this, you can create a pull request and one of our main organisation members will look at it. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | > ### Status of this project 3 | > This project is dead. There probably will not be any commits, although pull request are welcome. Discord server is also completely dead. 4 | > We also recommend a Go Game Engine called [Vuelto, which is a fast and lightweight Game Engine, made with usabillity in mind. It is a better alternative to Fusion.](http://vuelto-org.github.io/vuelto) 5 | 6 | > [!WARNING] 7 | > Website is down, and wont be brought up. The links here are not updated. 8 | 9 | > ### The search of a maintainer 10 | > If u like this project and want to work on it, we would happily accept you, but keep in mind that most of the infrastructure is dead or needs maintainance. Feel free to open an issue and tag @dimkauzh for further discussion. 11 | 12 |

13 | logo 14 |

15 | 16 |

17 | PyPI 18 | PyPI - Python Version 19 | PyPI - License 20 | PyPI - Status 21 | PyPI - Downloads 22 | GitHub contributors 23 | Lines of code 24 |

25 | 26 | Fusion is a game engine for creating graphical applications using OpenGL and the programming language Python. It provides a simple coding interface for creating windows, 27 | rendering graphics, and handling user input. It is and engine to create games fast and easy! 28 | 29 | 30 | ## 🗜️ Table of Contents 31 | - [Website](https://fusion-engine.tech/) 32 | - [Installation](#💾-installation) 33 | - [Community](#👥-community) 34 | - [Documentation]() 35 | - [Coming features](#📯-coming-features) 36 | - [License](#🪪-license) 37 | - [About](#🗄️-about) 38 | 39 | 40 | ## 💾 Installation 41 | 42 | ### ➡️ Using PyPi 43 | To install our package, run this: 44 | 45 | ```bash 46 | pip install fusion-engine 47 | ``` 48 | 49 | Our PyPI package is at this [link]() 50 | 51 | ### 🪲 Install from source/devel 52 | if you want to install the package from source and get the latest changes then you do it like this: 53 | 54 | ```bash 55 | git clone https://github.com/dimkauzh/fusion-engine.git 56 | cd fusion-engine 57 | pip install . 58 | ``` 59 | 60 | ### 🏃‍♂️ Run example 61 | The examples are located [here](https://github.com/fusionengine-org/fusion/tree/main/src/fusionengine/examples) 62 | If you want to run the example, then follow these instructions: 63 | 64 | 1. First, make sure you have fusion engine installed. 65 | 2. If fusion engine is installed, you can run the first example with the following command: 66 | ```bash 67 | python -m fusionengine.examples.example1 68 | ``` 69 | For other examples, you can modify the command to run the other example. Just change the number of the example. 70 | 71 | ## 👥 Community 72 | We have a discord server at this [link](). 73 | Need to contact us? Just #dimkauzh in discord and he will try to react as fast as possible 74 | 75 | ## 💁‍♂️ Contributing 76 | Our community is just growing, so if you want to help us with the project, 77 | it will be very helpful! We are welcome to all people who want to contribute, but you do need to follow the [contribution rules](CONTRIBUTING.md) 78 | Special thanks to all the contributors, they made the project even better! 79 | And thanks to our community of course! 80 | 81 | ## 🥎 Tutorials 82 | Are you exited to start with fusion engine but you dont know where to start? Then maybe its worth looking though one of our tutorials! We tried to make them as simple as possible but still very informative. You can find them [here]() 83 | 84 | 85 | ## 📯 Coming features 86 | We are working hard to implement very basic and complex stuff so our engine becomes more rigid. To see our changelog and todo list, please go [to our docs]() 87 | 88 | 💡 - If you have more ideas, please tell us them in our [discord server]() or create an issue! 89 | 90 | ## 🪪 License 91 | See [Licence here](LICENCE.md) 92 | 93 | ## 🗄️ About 94 | This project began May 1, 2023. The original project began in C, but it's entirely rewritten in Python for it's big userbase and ease of use (productivity). This is actually also my EuroPython 2023 project. But after some time, the community has grown, and fusion had a lot of big releases. It was becoming a big project with a giant codebase. 95 | 96 | ### ⭐ Star History 97 | 98 | 99 | 100 | 101 | Star History Chart 102 | 103 | 104 | 105 | ### 🇺🇦 Ukraine 106 | We as fusion team support Ukraine and we hope it will win. Fusion engine is dedicated to Ukraine fighting the Russian invasion. 107 | 🇺🇦 Please support Ukraine! 🇺🇦 108 | 109 | ## 🚀 About Me 110 | A 13-year-old game developer with much passion about game development. So I made this project to grow my programming skills and just make a tool that I can use for myself or a tool for other people to help them develop games. 111 | 112 | -------------------------------------------------------------------------------- /docs/CNAME: -------------------------------------------------------------------------------- 1 | docs.fusion-engine.tech -------------------------------------------------------------------------------- /docs/assets/gifs/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/assets/gifs/example.gif -------------------------------------------------------------------------------- /docs/assets/logo/fe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/assets/logo/fe.png -------------------------------------------------------------------------------- /docs/assets/logo/fusion-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/assets/logo/fusion-banner.png -------------------------------------------------------------------------------- /docs/assets/tutorials/result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/assets/tutorials/result.png -------------------------------------------------------------------------------- /docs/changelog/v3.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## V3 Todo/Changelog 4 | 5 | - [x] Engine 6 | - [x] Window 7 | - [x] Create window 8 | - [x] Get data from window 9 | - [x] Draw shapes 10 | - [x] Draw images 11 | - [x] Input 12 | - [x] Storage system 13 | - [x] Rendering options 14 | - [x] Delta-Time 15 | - [x] Pip package and SetupTools 16 | - [x] Cython 17 | - [x] Implement cython for extra speed 18 | - [x] Dev version without cython 19 | - [x] Vectors (stores x and y coordinates) 20 | - [x] Create vector 21 | - [x] GUI library 22 | - [x] Text 23 | - [x] Drawing (Build in draw function) 24 | - [x] Buttons 25 | - [x] Sound system 26 | - [x] Sound player 27 | - [x] File support 28 | - [x] And more... 29 | -------------------------------------------------------------------------------- /docs/changelog/v4.md: -------------------------------------------------------------------------------- 1 | 2 | # Version 4 Todo/Changelog 3 | 4 | ## V4 5 | - [x] Rewrite codebase 6 | - [x] Cleaner api 7 | - [x] Rewrite documentation 8 | - [x] Better documentation 9 | - [x] Easier usage 10 | 11 | ## V4.1 12 | - [x] Scenes managment 13 | - [x] Creating different scenes 14 | - [x] Scene manager 15 | - [x] Scenes classes 16 | - [x] Main scene class (SceneManager) 17 | - [x] Docs for it 18 | - [x] Paths Rewrite 19 | 20 | 21 | ## V4.2 22 | - [x] Animation system 23 | - [x] Load images 24 | - [x] Play animation 25 | - [x] Entities have frames that you can manipulate 26 | - [x] New keys system 27 | 28 | ## V4.3 29 | - [ ] Good bug fixes 30 | 31 | 32 | -------------------------------------------------------------------------------- /docs/changelog/v5.md: -------------------------------------------------------------------------------- 1 | # Version 5 Todo/Changelog 2 | 3 | ## V5 4 | - [x] Docs cleanup 5 | - [x] New color system 6 | - [x] Optimised font drawing 7 | - [x] OpenGL rendering 8 | 9 | ## V5.1 10 | - [x] New Window features 11 | - [x] Full Screen 12 | - [x] is_fullscreen 13 | - [x] toggle_fullscreen 14 | - [x] Screen Safer 15 | - [x] get_screensafer_allowed 16 | - [x] toggle_screensafer_allowed 17 | - [x] get_vsync_enabled 18 | - [x] get_screen_refresh_rate 19 | - [x] get_display_amount 20 | - [x] get_active 21 | 22 | - [x] SpriteSheet class 23 | - [x] __init__(Image, width, height) 24 | - [x] frames (variable with all your extracted frames) 25 | 26 | - [x] Image system updates 27 | - [x] Added crop() function 28 | - [x] Support for Pillow (PIL) images 29 | 30 | - [x] Animation system 31 | - [x] Fixing Animation system 32 | - [x] Added support for SpriteSheets 33 | - [x] Draw function gets frames argument 34 | 35 | ## V5.2 36 | - [x] Custom OpenGL (FusionGL) 37 | - [x] Using Ctypes 38 | - [x] Ported all functions 39 | 40 | - [x] Removal of PIL 41 | - [x] Moved image system to pygame instead of PIL 42 | 43 | - [x] Removal of 4 dependencies 44 | - [x] PyOpenGL 45 | - [x] PyOpenGL-Accelerate 46 | - [x] PIllow (PIL) 47 | - [x] Pymunk 48 | 49 | - [x] Entities 50 | - [x] Deprecated 51 | - [x] New entities called Nodes 52 | 53 | - [x] Node 54 | - [x] Some new features 55 | - [x] Moved features from entity system (and fixed them) 56 | 57 | ## V5.3 58 | - [ ] State Machine 59 | - [ ] Custom states 60 | - [ ] Easy to use 61 | 62 | 63 | -------------------------------------------------------------------------------- /docs/get-started.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | --- 5 | 6 | 7 | # Getting started with fusion 8 | Welcome to fusion engine. If you're here, that means your interested in fusion. Here is a quick example how to setup fusion engine 9 | 10 | ## 💻 Setting up 11 | 12 | To install it run this: 13 | 14 | ```bash 15 | pip install fusion-engine 16 | ``` 17 | 18 | Then import: 19 | 20 | ```python 21 | import fusionengine as fusion 22 | ``` 23 | And your done! 24 | 25 | ## Next step 26 | After this, you can head into the section tutorials or wiki, to learn more about fusion engine. Have fun! 27 | 28 | - [Tutorials](tutorials/setup.md) 29 | - [Wiki](wiki/window.md) -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | - toc 5 | --- 6 | 7 |

8 | logo 9 |

10 | 11 | 12 |

13 | PyPI 14 | PyPI - Python Version 15 | PyPI - License 16 | PyPI - Status 17 | PyPI - Downloads 18 | GitHub contributors 19 | Lines of code 20 |

21 | 22 | 23 | Fusion is a game engine for creating graphical applications using OpenGL and the programming language Python. It provides a simple coding interface for creating windows, 24 | rendering graphics, and handling user input. It is and engine to create games fast and easy! 25 | 26 | ## 🔨Table of contents 27 | 28 | - [Get started](get-started.md) 29 | - [Tutorials](tutorials/setup.md) 30 | - [Wiki](wiki/window.md) 31 | - [Legacy docs](legacy/index.md) 32 | 33 | ## 👋 Welcome 34 | Welcome to fusion engine documentation! We have seperated the documentation in two parts: wiki and tutorial. 35 | Wiki is made if you need to know what a function does. And in tutorials we made some tutorials for you to better understand fusion! 36 | To get started, head over to the 'Getting Started' section in the navigation bar. You can also choose the wiki or tutorials section in the navigation bar. Or you can use these links 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/legacy/index.md: -------------------------------------------------------------------------------- 1 | # Legacy 2 | ## v4 3 | 4 | ### Api 5 | Wasn't maintaned since fusion 4.1.0 6 | #### Api 7 | - [Setting up](#setting-up) 8 | - [API](v4/api/api.md) 9 | 10 | 11 | ## v3 12 | ### About 13 | The wiki, api and tutorials to the old v3 version of fusion, which is not being under development 14 | 15 | #### Wiki 16 | - [Setting up](#setting-up-v3) 17 | - [Wiki](v3/wiki/wiki.md) 18 | 19 | 20 | #### Tutorials 21 | - [Tutorials](v3/tutorials/setup.md) 22 | 23 | 24 | #### Api 25 | - [Setting up](#setting-up-v3) 26 | - [API](v3/api/api.md) 27 | 28 | 29 | 30 | ### 💻 Setting up v3 31 | 32 | To install it run this: 33 | 34 | ```bash 35 | pip install fusion-engine 36 | ``` 37 | 38 | Then import: 39 | 40 | ```python 41 | import fusionengine as engine 42 | ``` 43 | 44 | And after that you need to create a object of our engine to run functions of it: 45 | 46 | ```python 47 | main = engine.Main() 48 | ``` 49 | -------------------------------------------------------------------------------- /docs/legacy/v3/api/api.md: -------------------------------------------------------------------------------- 1 | 2 | # API 3 | 4 | ## Window 5 | ### main.window 6 | ```python 7 | new_window(title: str, width: int, height: int) 8 | change_icon(image_path: str) 9 | loop(your_loop_func) 10 | set_fps(self, fps: int) 11 | force_quit() 12 | ``` 13 | 14 | ## Event 15 | ### main.event 16 | ```python 17 | key_down(key) 18 | key_down_once(key) 19 | ``` 20 | 21 | ## Draw 22 | ### main.draw 23 | ```python 24 | draw_line(window, x1: int, y1: int, x2: int, y2: int, color: tuple) 25 | draw_line_rect(window, x: int, y: int, width: int, height: int, color: tuple) 26 | draw_rect(window, x: int, y: int, width: int, height: int, color: tuple) 27 | draw_own_rect(window, rect) 28 | set_background_color(window, color: tuple) 29 | ``` 30 | 31 | ## Image 32 | ### main.image 33 | ```python 34 | open_image(window, image_path: str, x: int, y: int, width: int, height: int) 35 | draw_image(image) 36 | ``` 37 | 38 | ## Body 39 | ### main.body 40 | ```python 41 | Entity(window, x: int, y: int, width: int, height: int) 42 | ``` 43 | 44 | ## Shape 45 | ### main.shape 46 | ```python 47 | new_rect(x: int, y: int, width: int, height: int, color: tuple) 48 | new_rect_button(x, y, width, height) 49 | ``` 50 | 51 | ## UI 52 | ### main.ui 53 | #### main.ui.button 54 | ```python 55 | new_button(window: windowfe._CustomRenderer, rect: shape._CustomShape, text: str) 56 | ``` 57 | Some button functions: 58 | ```python 59 | your_button.button_pressed() -> bool 60 | ``` 61 | 62 | #### main.ui.text 63 | ```python 64 | def print_text(window, text: str, x: int, y: int, font_path: str, font_size: int, color: tuple) 65 | ``` 66 | 67 | ## Debug 68 | ### main.debug 69 | ```python 70 | DEBUGIMAGE 71 | ``` 72 | 73 | ## Vector 74 | ### main.vector 75 | ```python 76 | new_vector2d(x: int, y: int) 77 | ``` 78 | 79 | ## Sound 80 | ### main.sound 81 | ```python 82 | load_sound(sound_path: str) 83 | play_background_music(sound_path: str) 84 | set_volume_global(volume) 85 | ``` 86 | 87 | ### Loaded sound API 88 | ```python 89 | play() 90 | stop() 91 | get_volume() 92 | set_volume(volume: int) 93 | fadeout(time: str) 94 | ``` 95 | 96 | -------------------------------------------------------------------------------- /docs/legacy/v3/api/color.md: -------------------------------------------------------------------------------- 1 | 2 | # Color API 3 | 4 | ## Color 5 | ### main.color 6 | ```python 7 | BLUE = (0, 0, 255, 255) 8 | BLACK = (0, 0, 0, 255) 9 | WHITE = (255, 255, 255, 255) 10 | GREEN = (255, 255, 255, 255) 11 | RED = (255, 0, 0, 255) 12 | YELLOW = (255, 255, 0, 255) 13 | PURPLE = (255, 0, 255, 255) 14 | CYAN = (0, 255, 255, 255) 15 | ORANGE = (255, 165, 0, 255) 16 | GRAY = (128, 128, 128, 255) 17 | BROWN = (165, 42, 42, 255) 18 | PINK = (255, 192, 203, 255) 19 | MAGENTA = (255, 0, 255, 255) 20 | SILVER = (192, 192, 192, 255) 21 | GOLD = (255, 215, 0, 255) 22 | BRONZE = (205, 127, 50, 255) 23 | LIME = (0, 255, 0, 255) 24 | OLIVE = (128, 128, 0, 255) 25 | TEAL = (0, 128, 128, 255) 26 | NAVY = (0, 0, 128, 255) 27 | MAROON = (128, 0, 0, 255) 28 | INDIGO = (75, 0, 130, 255) 29 | TURQUOISE = (64, 224, 208, 255) 30 | VIOLET = (238, 130, 238, 255) 31 | AQUA = (0, 255, 255, 255) 32 | TAN = (210, 180, 140, 255) 33 | BEIGE = (245, 245, 220, 255) 34 | IVORY = (255, 255, 240, 255) 35 | LAVENDER = (230, 230, 250, 255) 36 | MINT = (189, 252, 201, 255) 37 | SALMON = (250, 128, 114, 255) 38 | SCARLET = (255, 36, 0, 255) 39 | TEAL = (0, 128, 128, 255) 40 | TOMATO = (255, 99, 71, 255) 41 | CRIMSON = (220, 20, 60, 255) 42 | AZURE = (0, 128, 255, 255) 43 | ``` 44 | ## Colortools 45 | ### main.colortools 46 | ```python 47 | hex_to_rgba(hex) 48 | ``` 49 | -------------------------------------------------------------------------------- /docs/legacy/v3/api/fonts.md: -------------------------------------------------------------------------------- 1 | 2 | # Font API 3 | 4 | ## main.font 5 | 6 | ```python 7 | NUNITO_LIGHT 8 | SAIRACONDENSED_EXTRABOLD 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /docs/legacy/v3/api/index.md: -------------------------------------------------------------------------------- 1 | 2 | # Api 3 | 4 | Welcome to our api! Here you will find all functions that exist in fusion engine and what arguments they get. 5 | We have seperated the api in some parts, like main api, color api and more. You choose one you need. 6 | Can't find something? Then try looking in the main api/ 7 | So have luck! 8 | 9 | ## Table of contents 10 | - [Main API](api.md) 11 | - [Color API](color.md) 12 | - [Font API](fonts.md) 13 | - [Key API](keys.md) 14 | -------------------------------------------------------------------------------- /docs/legacy/v3/api/keys.md: -------------------------------------------------------------------------------- 1 | 2 | # Keys API 3 | ## main.keys 4 | 5 | ```python 6 | KEY_UNKNOWN = sdl2.SDLK_UNKNOWN 7 | KEY_RETURN = sdl2.SDLK_RETURN 8 | KEY_ESCAPE = sdl2.SDLK_ESCAPE 9 | KEY_BACKSPACE = sdl2.SDLK_BACKSPACE 10 | KEY_TAB = sdl2.SDLK_TAB 11 | KEY_SPACE = sdl2.SDLK_SPACE 12 | KEY_EXCLAIM = sdl2.SDLK_EXCLAIM 13 | KEY_QUOTEDBL = sdl2.SDLK_QUOTEDBL 14 | KEY_HASH = sdl2.SDLK_HASH 15 | KEY_PERCENT = sdl2.SDLK_PERCENT 16 | KEY_DOLLAR = sdl2.SDLK_DOLLAR 17 | KEY_AMPERSAND = sdl2.SDLK_AMPERSAND 18 | KEY_QUOTE = sdl2.SDLK_QUOTE 19 | KEY_LEFTPAREN = sdl2.SDLK_LEFTPAREN 20 | KEY_RIGHTPAREN = sdl2.SDLK_RIGHTPAREN 21 | KEY_ASTERISK = sdl2.SDLK_ASTERISK 22 | KEY_PLUS = sdl2.SDLK_PLUS 23 | KEY_COMMA = sdl2.SDLK_COMMA 24 | KEY_MINUS = sdl2.SDLK_MINUS 25 | KEY_PERIOD = sdl2.SDLK_PERIOD 26 | KEY_SLASH = sdl2.SDLK_SLASH 27 | KEY_0 = sdl2.SDLK_0 28 | KEY_1 = sdl2.SDLK_1 29 | KEY_2 = sdl2.SDLK_2 30 | KEY_3 = sdl2.SDLK_3 31 | KEY_4 = sdl2.SDLK_4 32 | KEY_5 = sdl2.SDLK_5 33 | KEY_6 = sdl2.SDLK_6 34 | KEY_7 = sdl2.SDLK_7 35 | KEY_8 = sdl2.SDLK_8 36 | KEY_9 = sdl2.SDLK_9 37 | KEY_COLON = sdl2.SDLK_COLON 38 | KEY_SEMICOLON = sdl2.SDLK_SEMICOLON 39 | KEY_LESS = sdl2.SDLK_LESS 40 | KEY_EQUALS = sdl2.SDLK_EQUALS 41 | KEY_GREATER = sdl2.SDLK_GREATER 42 | KEY_QUESTION = sdl2.SDLK_QUESTION 43 | KEY_AT = sdl2.SDLK_AT 44 | KEY_LEFTBRACKET = sdl2.SDLK_LEFTBRACKET 45 | KEY_BACKSLASH = sdl2.SDLK_BACKSLASH 46 | KEY_RIGHTBRACKET = sdl2.SDLK_RIGHTBRACKET 47 | KEY_CARET = sdl2.SDLK_CARET 48 | KEY_UNDERSCORE = sdl2.SDLK_UNDERSCORE 49 | KEY_BACKQUOTE = sdl2.SDLK_BACKQUOTE 50 | KEY_a = sdl2.SDLK_a 51 | KEY_b = sdl2.SDLK_b 52 | KEY_c = sdl2.SDLK_c 53 | KEY_d = sdl2.SDLK_d 54 | KEY_e = sdl2.SDLK_e 55 | KEY_f = sdl2.SDLK_f 56 | KEY_g = sdl2.SDLK_g 57 | KEY_h = sdl2.SDLK_h 58 | KEY_i = sdl2.SDLK_i 59 | KEY_j = sdl2.SDLK_j 60 | KEY_k = sdl2.SDLK_k 61 | KEY_l = sdl2.SDLK_l 62 | KEY_m = sdl2.SDLK_m 63 | KEY_n = sdl2.SDLK_n 64 | KEY_o = sdl2.SDLK_o 65 | KEY_p = sdl2.SDLK_p 66 | KEY_q = sdl2.SDLK_q 67 | KEY_r = sdl2.SDLK_r 68 | KEY_s = sdl2.SDLK_s 69 | KEY_t = sdl2.SDLK_t 70 | KEY_u = sdl2.SDLK_u 71 | KEY_v = sdl2.SDLK_v 72 | KEY_w = sdl2.SDLK_w 73 | KEY_x = sdl2.SDLK_x 74 | KEY_y = sdl2.SDLK_y 75 | KEY_z = sdl2.SDLK_z 76 | KEY_CAPSLOCK = sdl2.SDLK_CAPSLOCK 77 | KEY_F1 = sdl2.SDLK_F1 78 | KEY_F2 = sdl2.SDLK_F2 79 | KEY_F3 = sdl2.SDLK_F3 80 | KEY_F4 = sdl2.SDLK_F4 81 | KEY_F5 = sdl2.SDLK_F5 82 | KEY_F6 = sdl2.SDLK_F6 83 | KEY_F7 = sdl2.SDLK_F7 84 | KEY_F8 = sdl2.SDLK_F8 85 | KEY_F9 = sdl2.SDLK_F9 86 | KEY_F10 = sdl2.SDLK_F10 87 | KEY_F11 = sdl2.SDLK_F11 88 | KEY_F12 = sdl2.SDLK_F12 89 | KEY_PRINTSCREEN = sdl2.SDLK_PRINTSCREEN 90 | KEY_SCROLLLOCK = sdl2.SDLK_SCROLLLOCK 91 | KEY_PAUSE = sdl2.SDLK_PAUSE 92 | KEY_INSERT = sdl2.SDLK_INSERT 93 | KEY_HOME = sdl2.SDLK_HOME 94 | KEY_PAGEUP = sdl2.SDLK_PAGEUP 95 | KEY_DELETE = sdl2.SDLK_DELETE 96 | KEY_END = sdl2.SDLK_END 97 | KEY_PAGEDOWN = sdl2.SDLK_PAGEDOWN 98 | KEY_RIGHT = sdl2.SDLK_RIGHT 99 | KEY_LEFT = sdl2.SDLK_LEFT 100 | KEY_DOWN = sdl2.SDLK_DOWN 101 | KEY_UP = sdl2.SDLK_UP 102 | KEY_NUMLOCKCLEAR = sdl2.SDLK_NUMLOCKCLEAR 103 | KEY_KP_DIVIDE = sdl2.SDLK_KP_DIVIDE 104 | KEY_KP_MULTIPLY = sdl2.SDLK_KP_MULTIPLY 105 | KEY_KP_MINUS = sdl2.SDLK_KP_MINUS 106 | KEY_KP_PLUS = sdl2.SDLK_KP_PLUS 107 | KEY_KP_ENTER = sdl2.SDLK_KP_ENTER 108 | KEY_KP_1 = sdl2.SDLK_KP_1 109 | KEY_KP_2 = sdl2.SDLK_KP_2 110 | KEY_KP_3 = sdl2.SDLK_KP_3 111 | KEY_KP_4 = sdl2.SDLK_KP_4 112 | KEY_KP_5 = sdl2.SDLK_KP_5 113 | KEY_KP_6 = sdl2.SDLK_KP_6 114 | KEY_KP_7 = sdl2.SDLK_KP_7 115 | KEY_KP_8 = sdl2.SDLK_KP_8 116 | KEY_KP_9 = sdl2.SDLK_KP_9 117 | KEY_KP_0 = sdl2.SDLK_KP_0 118 | KEY_KP_PERIOD = sdl2.SDLK_KP_PERIOD 119 | KEY_APPLICATION = sdl2.SDLK_APPLICATION 120 | KEY_POWER = sdl2.SDLK_POWER 121 | KEY_KP_EQUALS = sdl2.SDLK_KP_EQUALS 122 | KEY_F13 = sdl2.SDLK_F13 123 | KEY_F14 = sdl2.SDLK_F14 124 | KEY_F15 = sdl2.SDLK_F15 125 | KEY_F16 = sdl2.SDLK_F16 126 | KEY_F17 = sdl2.SDLK_F17 127 | KEY_F18 = sdl2.SDLK_F18 128 | KEY_F19 = sdl2.SDLK_F19 129 | KEY_F20 = sdl2.SDLK_F20 130 | KEY_F21 = sdl2.SDLK_F21 131 | KEY_F22 = sdl2.SDLK_F22 132 | KEY_F23 = sdl2.SDLK_F23 133 | KEY_F24 = sdl2.SDLK_F24 134 | KEY_EXECUTE = sdl2.SDLK_EXECUTE 135 | KEY_HELP = sdl2.SDLK_HELP 136 | KEY_MENU = sdl2.SDLK_MENU 137 | KEY_SELECT = sdl2.SDLK_SELECT 138 | KEY_STOP = sdl2.SDLK_STOP 139 | KEY_AGAIN = sdl2.SDLK_AGAIN 140 | KEY_UNDO = sdl2.SDLK_UNDO 141 | KEY_CUT = sdl2.SDLK_CUT 142 | KEY_COPY = sdl2.SDLK_COPY 143 | KEY_PASTE = sdl2.SDLK_PASTE 144 | KEY_FIND = sdl2.SDLK_FIND 145 | KEY_MUTE = sdl2.SDLK_MUTE 146 | KEY_VOLUMEUP = sdl2.SDLK_VOLUMEUP 147 | KEY_VOLUMEDOWN = sdl2.SDLK_VOLUMEDOWN 148 | KEY_KP_COMMA = sdl2.SDLK_KP_COMMA 149 | KEY_KP_EQUALSAS400 = sdl2.SDLK_KP_EQUALSAS400 150 | KEY_ALTERASE = sdl2.SDLK_ALTERASE 151 | KEY_SYSREQ = sdl2.SDLK_SYSREQ 152 | KEY_CANCEL = sdl2.SDLK_CANCEL 153 | KEY_CLEAR = sdl2.SDLK_CLEAR 154 | KEY_PRIOR = sdl2.SDLK_PRIOR 155 | KEY_RETURN2 = sdl2.SDLK_RETURN2 156 | KEY_SEPARATOR = sdl2.SDLK_SEPARATOR 157 | KEY_OUT = sdl2.SDLK_OUT 158 | KEY_OPER = sdl2.SDLK_OPER 159 | KEY_CLEARAGAIN = sdl2.SDLK_CLEARAGAIN 160 | KEY_CRSEL = sdl2.SDLK_CRSEL 161 | KEY_EXSEL = sdl2.SDLK_EXSEL 162 | KEY_KP_00 = sdl2.SDLK_KP_00 163 | KEY_KP_000 = sdl2.SDLK_KP_000 164 | KEY_THOUSANDSSEPARATOR = sdl2.SDLK_THOUSANDSSEPARATOR 165 | KEY_DECIMALSEPARATOR = sdl2.SDLK_DECIMALSEPARATOR 166 | KEY_CURRENCYUNIT = sdl2.SDLK_CURRENCYUNIT 167 | KEY_CURRENCYSUBUNIT = sdl2.SDLK_CURRENCYSUBUNIT 168 | KEY_KP_LEFTPAREN = sdl2.SDLK_KP_LEFTPAREN 169 | KEY_KP_RIGHTPAREN = sdl2.SDLK_KP_RIGHTPAREN 170 | KEY_KP_LEFTBRACE = sdl2.SDLK_KP_LEFTBRACE 171 | KEY_KP_RIGHTBRACE = sdl2.SDLK_KP_RIGHTBRACE 172 | KEY_KP_TAB = sdl2.SDLK_KP_TAB 173 | KEY_KP_BACKSPACE = sdl2.SDLK_KP_BACKSPACE 174 | KEY_KP_A = sdl2.SDLK_KP_A 175 | KEY_KP_B = sdl2.SDLK_KP_B 176 | KEY_KP_C = sdl2.SDLK_KP_C 177 | KEY_KP_D = sdl2.SDLK_KP_D 178 | KEY_KP_E = sdl2.SDLK_KP_E 179 | KEY_KP_F = sdl2.SDLK_KP_F 180 | KEY_KP_XOR = sdl2.SDLK_KP_XOR 181 | KEY_KP_POWER = sdl2.SDLK_KP_POWER 182 | KEY_KP_PERCENT = sdl2.SDLK_KP_PERCENT 183 | KEY_KP_LESS = sdl2.SDLK_KP_LESS 184 | KEY_KP_GREATER = sdl2.SDLK_KP_GREATER 185 | KEY_KP_AMPERSAND = sdl2.SDLK_KP_AMPERSAND 186 | KEY_KP_DBLAMPERSAND = sdl2.SDLK_KP_DBLAMPERSAND 187 | KEY_KP_VERTICALBAR = sdl2.SDLK_KP_VERTICALBAR 188 | KEY_KP_DBLVERTICALBAR = sdl2.SDLK_KP_DBLVERTICALBAR 189 | KEY_KP_COLON = sdl2.SDLK_KP_COLON 190 | KEY_KP_HASH = sdl2.SDLK_KP_HASH 191 | KEY_KP_SPACE = sdl2.SDLK_KP_SPACE 192 | KEY_KP_AT = sdl2.SDLK_KP_AT 193 | KEY_KP_EXCLAM = sdl2.SDLK_KP_EXCLAM 194 | KEY_KP_MEMSTORE = sdl2.SDLK_KP_MEMSTORE 195 | KEY_KP_MEMRECALL = sdl2.SDLK_KP_MEMRECALL 196 | KEY_KP_MEMCLEAR = sdl2.SDLK_KP_MEMCLEAR 197 | KEY_KP_MEMADD = sdl2.SDLK_KP_MEMADD 198 | KEY_KP_MEMSUBTRACT = sdl2.SDLK_KP_MEMSUBTRACT 199 | KEY_KP_MEMMULTIPLY = sdl2.SDLK_KP_MEMMULTIPLY 200 | KEY_KP_MEMDIVIDE = sdl2.SDLK_KP_MEMDIVIDE 201 | KEY_KP_PLUSMINUS = sdl2.SDLK_KP_PLUSMINUS 202 | KEY_KP_CLEAR = sdl2.SDLK_KP_CLEAR 203 | KEY_KP_CLEARENTRY = sdl2.SDLK_KP_CLEARENTRY 204 | KEY_KP_BINARY = sdl2.SDLK_KP_BINARY 205 | KEY_KP_OCTAL = sdl2.SDLK_KP_OCTAL 206 | KEY_KP_DECIMAL = sdl2.SDLK_KP_DECIMAL 207 | KEY_KP_HEXADECIMAL = sdl2.SDLK_KP_HEXADECIMAL 208 | KEY_LCTRL = sdl2.SDLK_LCTRL 209 | KEY_LSHIFT = sdl2.SDLK_LSHIFT 210 | KEY_LALT = sdl2.SDLK_LALT 211 | KEY_LGUI = sdl2.SDLK_LGUI 212 | KEY_RCTRL = sdl2.SDLK_RCTRL 213 | KEY_RSHIFT = sdl2.SDLK_RSHIFT 214 | KEY_RALT = sdl2.SDLK_RALT 215 | KEY_RGUI = sdl2.SDLK_RGUI 216 | KEY_MODE = sdl2.SDLK_MODE 217 | KEY_AUDIONEXT = sdl2.SDLK_AUDIONEXT 218 | KEY_AUDIOPREV = sdl2.SDLK_AUDIOPREV 219 | KEY_AUDIOSTOP = sdl2.SDLK_AUDIOSTOP 220 | KEY_AUDIOPLAY = sdl2.SDLK_AUDIOPLAY 221 | KEY_AUDIOMUTE = sdl2.SDLK_AUDIOMUTE 222 | KEY_MEDIASELECT = sdl2.SDLK_MEDIASELECT 223 | KEY_WWW = sdl2.SDLK_WWW 224 | KEY_MAIL = sdl2.SDLK_MAIL 225 | KEY_CALCULATOR = sdl2.SDLK_CALCULATOR 226 | KEY_COMPUTER = sdl2.SDLK_COMPUTER 227 | KEY_AC_SEARCH = sdl2.SDLK_AC_SEARCH 228 | KEY_AC_HOME = sdl2.SDLK_AC_HOME 229 | KEY_AC_BACK = sdl2.SDLK_AC_BACK 230 | KEY_AC_FORWARD = sdl2.SDLK_AC_FORWARD 231 | KEY_AC_STOP = sdl2.SDLK_AC_STOP 232 | KEY_AC_REFRESH = sdl2.SDLK_AC_REFRESH 233 | KEY_AC_BOOKMARKS = sdl2.SDLK_AC_BOOKMARKS 234 | KEY_BRIGHTNESSDOWN = sdl2.SDLK_BRIGHTNESSDOWN 235 | KEY_BRIGHTNESSUP = sdl2.SDLK_BRIGHTNESSUP 236 | KEY_DISPLAYSWITCH = sdl2.SDLK_DISPLAYSWITCH 237 | KEY_KBDILLUMTOGGLE = sdl2.SDLK_KBDILLUMTOGGLE 238 | KEY_KBDILLUMDOWN = sdl2.SDLK_KBDILLUMDOWN 239 | KEY_KBDILLUMUP = sdl2.SDLK_KBDILLUMUP 240 | KEY_EJECT = sdl2.SDLK_EJECT 241 | KEY_SLEEP = sdl2.SDLK_SLEEP 242 | ``` 243 | -------------------------------------------------------------------------------- /docs/legacy/v3/api/math.md: -------------------------------------------------------------------------------- 1 | 2 | # Math API 3 | ## main.math 4 | 5 | ```python 6 | PI = 3.141592653589793238462643383279502884197 7 | EULERNUMBER = 2.718281828459045 8 | main.math.FLOOR(3.4) 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /docs/legacy/v3/assets/gifs/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/legacy/v3/assets/gifs/example.gif -------------------------------------------------------------------------------- /docs/legacy/v3/assets/logo/fe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/legacy/v3/assets/logo/fe.png -------------------------------------------------------------------------------- /docs/legacy/v3/tutorials/basics.md: -------------------------------------------------------------------------------- 1 | 2 | # Basic rendering tutorial 3 | 4 | ## Introduction 5 | This is a tutorial so you would understand the basics of the engine and how it works. In this tutorial we will learn how to render a window and draw some images on it. If you want to learn more, then go to [our docs](https://docs.fusion-engine.tech) and select wiki. 6 | 7 | This tutorial also expect you to have everything setup, if not, head over to [tutorial 1: setting everything up](setup.md) 8 | 9 | The Final Product Should Look like This: 10 | ![gif](../assets/gifs/example.gif) 11 | 12 | ## Creating a window 13 | 14 | So if you read tutorial 1 you know we have the main variable running our engine object. So now we create a window with the help of that main object: 15 | ```python 16 | window = main.window.new_window("Tutorial 2", 600, 600) 17 | ``` 18 | The first argument that we give our function is our title, second argument is our width and third one is height 19 | 20 | ## Pre-loading image 21 | We will now pre-load a image so we can draw it later on our window. We do it like this: 22 | ```python 23 | image = main.image.open_image(window, main.debug.DEBUGIMAGE, 0, 0, 600, 600) 24 | ``` 25 | Fist argument is our window, second is our image path, third is our x position, fourth is our y position, fifth is our width and sixth is our height. As you maybe see were using main.debug.DEBUGIMAGE, which is a build in image into our engine for testing purposes. We will use it for our tutorial 26 | 27 | ## Starting a loop 28 | A loop is basicly what lets our window be open the whole time and not be automaticly closed. You also run there functions that need to ran every frame. So we start a loop like this: 29 | ```python 30 | @main.window.loop 31 | def loop(): 32 | ... # Code goes here 33 | 34 | ``` 35 | 36 | ## Drawing image 37 | So we still need to draw our image after loading it, and you can do that easily inside a loop like this: 38 | ```python 39 | @main.window.loop 40 | def loop(): 41 | main.image.draw_image(image) 42 | 43 | ``` 44 | As you see we have a draw_image function in our loop with the image loaded image as argument. 45 | 46 | ## Full code 47 | Here is our full code that we could through this tutorial: 48 | ```python 49 | import fusionengine as fusion 50 | 51 | main = fusion.Main() 52 | 53 | window = main.window.new_window("Example: 1", 600, 600) 54 | image = main.image.open_image(window, main.debug.DEBUGIMAGE, 0, 0, 600, 600) 55 | 56 | 57 | @main.window.loop 58 | def loop(): 59 | main.image.draw_image(image) 60 | ``` 61 | 62 | ## Ending 63 | This was our basic tutorial to images. There are (or will be) more tutorials, so check them our. Or otherwise you could check our [docs]() for more information. Happy coding! 64 | 65 | -------------------------------------------------------------------------------- /docs/legacy/v3/tutorials/index.md: -------------------------------------------------------------------------------- 1 | 2 | # Fusion engine tutorials 3 | ## Unveiling the Tutorials 4 | Welcome to our tutorials! Here you will find step by step tutorials so you can understand fusion engine better! There are couple tutorials to get you started with basics and some are more advanced so you can create your first game with ease! 5 | 6 | ## Table of contents 7 | - [Tutorial 1: Setting Everything Up](tutorial-1:setting-everyting-up) 8 | - [Tutorial 2: Basic Rendering](tutorial-2:basic-rendering) 9 | 10 | ### Tutorial 1: Setting Everything Up 11 | This tutorial is about setting up fusion-engine so you can work on your project. Have fun! 12 | [Start your journey: Tutorial 1](setup.md) 13 | 14 | ### Tutorial 2: Basic Rendering 15 | In this tutorial we're covering the basics like creating a window and rendering a image. Before this tutorial, make sure you have everything setup, if not you can follow tutorial-1. Have fun! 16 | [Start your journey: Tutorial 2](basics.md) 17 | -------------------------------------------------------------------------------- /docs/legacy/v3/tutorials/setup.md: -------------------------------------------------------------------------------- 1 | 2 | # Setting everything up 3 | 4 | ## Introduction 5 | Welcome to our fusion-engine tutorials! Here you can learn about our engine and how to use it! This will go easy over everything you need to know to start programming with fusion! 6 | 7 | So this tutorial is made to setup everything, so you can start programming with fusion-engine! But if you already have everything setup then head over to [tutorial 2: basic rendering](basics.md) 8 | 9 | ## Installing 10 | So firstly we need to install fusion-engine. We have our package hoster at pypi so you can easly install it by running: 11 | ```bash 12 | pip install fusion-engine 13 | ``` 14 | 15 | ## Importing 16 | Now we need to import fusion-engine to our project. We do it like this: 17 | ```python 18 | import fusionengine as engine 19 | ``` 20 | 21 | ## Setting up 22 | So after inporting we need to do some setup. We need to create a object of our engine so we can use it. We do it like this: 23 | ```python 24 | main = engine.Main() 25 | ``` 26 | 27 | ## Ending 28 | That was it, our engine is now setup! Now every function works from our main variable, as you might see later. 29 | -------------------------------------------------------------------------------- /docs/legacy/v3/wiki/color.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Using colors 4 | Our engine has some build in predefined colors so it's a bit easier for you with colors, to acess the colors you run: 5 | ```python 6 | main.color.WHITE 7 | ``` 8 | ## All colors 9 |
Deprecated 10 | 11 | The color name is always in capital letters. Here are all predefined colors: 12 | ```python 13 | BLUE = (0, 0, 255, 255) 14 | BLACK = (0, 0, 0, 255) 15 | WHITE = (255, 255, 255, 255) 16 | GREEN = (255, 255, 255, 255) 17 | RED = (255, 0, 0, 255) 18 | YELLOW = (255, 255, 0, 255) 19 | PURPLE = (255, 0, 255, 255) 20 | CYAN = (0, 255, 255, 255) 21 | ORANGE = (255, 165, 0, 255) 22 | GRAY = (128, 128, 128, 255) 23 | BROWN = (165, 42, 42, 255) 24 | PINK = (255, 192, 203, 255) 25 | MAGENTA = (255, 0, 255, 255) 26 | SILVER = (192, 192, 192, 255) 27 | GOLD = (255, 215, 0, 255) 28 | BRONZE = (205, 127, 50, 255) 29 | LIME = (0, 255, 0, 255) 30 | OLIVE = (128, 128, 0, 255) 31 | TEAL = (0, 128, 128, 255) 32 | NAVY = (0, 0, 128, 255) 33 | MAROON = (128, 0, 0, 255) 34 | INDIGO = (75, 0, 130, 255) 35 | TURQUOISE = (64, 224, 208, 255) 36 | VIOLET = (238, 130, 238, 255) 37 | AQUA = (0, 255, 255, 255) 38 | TAN = (210, 180, 140, 255) 39 | BEIGE = (245, 245, 220, 255) 40 | IVORY = (255, 255, 240, 255) 41 | LAVENDER = (230, 230, 250, 255) 42 | MINT = (189, 252, 201, 255) 43 | SALMON = (250, 128, 114, 255) 44 | SCARLET = (255, 36, 0, 255) 45 | TEAL = (0, 128, 128, 255) 46 | TOMATO = (255, 99, 71, 255) 47 | CRIMSON = (220, 20, 60, 255) 48 | AZURE = (0, 128, 255, 255) 49 | ``` 50 |
51 | 52 | The color name is always capitalised as per [PEP 8 → Constants](https://peps.python.org/pep-0008/#constants). All colors are defined and named (with capitalised form) as per [Sublime Text → Docs → Color Schemes → Appendix - CSS Colors](https://www.sublimetext.com/docs/color_schemes.html#appendix-css-colors). 53 | 54 | ## Custom color 55 | If you want your own color, you just give your function a tuple argument with RGBA colors, here is an example: 56 | ```python 57 | main.draw.drawRect(window, 100, 100, 400, 400, (255, 255, 255, 0)) 58 | ``` 59 | 60 | ## Hex to rgba 61 | If you have a hex color and want to convert it to rgba you can use this function: 62 | ```python 63 | main.colortools.hex_to_rgba(hex) 64 | ``` 65 | -------------------------------------------------------------------------------- /docs/legacy/v3/wiki/external.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # External tools 4 | 5 | ## Using pygame 6 | If you cant find some function you need in this engine, the you could use pygame as the engine is build on pygame. You dont need to import pygame, as that can make so issues, you just use: 7 | ```python 8 | fusion.pg 9 | ``` 10 | Make sure your not using main (the initialized class) but the module itself. 11 | 12 | ## Using Codon Compiler 13 | So you heard of [codon](https://docs.exaloop.io/codon/), a python compiler with can compile your python code to machine code, which makes your code a lot faster But how do you use it? Well, its easy! You just install it and then modify these things in your code: 14 | 15 | Imports: 16 | ```python 17 | from python import fusionengine as fusion 18 | ``` 19 | 20 | Loop: 21 | You need to modify our loop to support codon, so you need to change it to this: 22 | ```python 23 | while main.window.running(window): 24 | ... # Your own loop thing 25 | ``` 26 | You may reconise this type of while loop from the main wiki as your second option. -------------------------------------------------------------------------------- /docs/legacy/v3/wiki/fonts.md: -------------------------------------------------------------------------------- 1 | 2 | ## Fonts 3 | Our engine has some build in fonts, the following fonts are available: 4 | 5 | Nunito Sans Light: 6 | ```python 7 | main.fonts.NUNITO_LIGHT 8 | ``` 9 | Saira Condensed Extrabold: 10 | ```python 11 | main.fonts.SAIRACONDENSED_EXTRABOLD 12 | ``` 13 | 14 | There will be more fonts available in the future. 15 | -------------------------------------------------------------------------------- /docs/legacy/v3/wiki/keys.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Keys 4 | We use PySDL2 for this, here are our key bindings to the sdl2 keys: 5 | ```python 6 | KEY_UNKNOWN = sdl2.SDLK_UNKNOWN 7 | KEY_RETURN = sdl2.SDLK_RETURN 8 | KEY_ESCAPE = sdl2.SDLK_ESCAPE 9 | KEY_BACKSPACE = sdl2.SDLK_BACKSPACE 10 | KEY_TAB = sdl2.SDLK_TAB 11 | KEY_SPACE = sdl2.SDLK_SPACE 12 | KEY_EXCLAIM = sdl2.SDLK_EXCLAIM 13 | KEY_QUOTEDBL = sdl2.SDLK_QUOTEDBL 14 | KEY_HASH = sdl2.SDLK_HASH 15 | KEY_PERCENT = sdl2.SDLK_PERCENT 16 | KEY_DOLLAR = sdl2.SDLK_DOLLAR 17 | KEY_AMPERSAND = sdl2.SDLK_AMPERSAND 18 | KEY_QUOTE = sdl2.SDLK_QUOTE 19 | KEY_LEFTPAREN = sdl2.SDLK_LEFTPAREN 20 | KEY_RIGHTPAREN = sdl2.SDLK_RIGHTPAREN 21 | KEY_ASTERISK = sdl2.SDLK_ASTERISK 22 | KEY_PLUS = sdl2.SDLK_PLUS 23 | KEY_COMMA = sdl2.SDLK_COMMA 24 | KEY_MINUS = sdl2.SDLK_MINUS 25 | KEY_PERIOD = sdl2.SDLK_PERIOD 26 | KEY_SLASH = sdl2.SDLK_SLASH 27 | KEY_0 = sdl2.SDLK_0 28 | KEY_1 = sdl2.SDLK_1 29 | KEY_2 = sdl2.SDLK_2 30 | KEY_3 = sdl2.SDLK_3 31 | KEY_4 = sdl2.SDLK_4 32 | KEY_5 = sdl2.SDLK_5 33 | KEY_6 = sdl2.SDLK_6 34 | KEY_7 = sdl2.SDLK_7 35 | KEY_8 = sdl2.SDLK_8 36 | KEY_9 = sdl2.SDLK_9 37 | KEY_COLON = sdl2.SDLK_COLON 38 | KEY_SEMICOLON = sdl2.SDLK_SEMICOLON 39 | KEY_LESS = sdl2.SDLK_LESS 40 | KEY_EQUALS = sdl2.SDLK_EQUALS 41 | KEY_GREATER = sdl2.SDLK_GREATER 42 | KEY_QUESTION = sdl2.SDLK_QUESTION 43 | KEY_AT = sdl2.SDLK_AT 44 | KEY_LEFTBRACKET = sdl2.SDLK_LEFTBRACKET 45 | KEY_BACKSLASH = sdl2.SDLK_BACKSLASH 46 | KEY_RIGHTBRACKET = sdl2.SDLK_RIGHTBRACKET 47 | KEY_CARET = sdl2.SDLK_CARET 48 | KEY_UNDERSCORE = sdl2.SDLK_UNDERSCORE 49 | KEY_BACKQUOTE = sdl2.SDLK_BACKQUOTE 50 | KEY_a = sdl2.SDLK_a 51 | KEY_b = sdl2.SDLK_b 52 | KEY_c = sdl2.SDLK_c 53 | KEY_d = sdl2.SDLK_d 54 | KEY_e = sdl2.SDLK_e 55 | KEY_f = sdl2.SDLK_f 56 | KEY_g = sdl2.SDLK_g 57 | KEY_h = sdl2.SDLK_h 58 | KEY_i = sdl2.SDLK_i 59 | KEY_j = sdl2.SDLK_j 60 | KEY_k = sdl2.SDLK_k 61 | KEY_l = sdl2.SDLK_l 62 | KEY_m = sdl2.SDLK_m 63 | KEY_n = sdl2.SDLK_n 64 | KEY_o = sdl2.SDLK_o 65 | KEY_p = sdl2.SDLK_p 66 | KEY_q = sdl2.SDLK_q 67 | KEY_r = sdl2.SDLK_r 68 | KEY_s = sdl2.SDLK_s 69 | KEY_t = sdl2.SDLK_t 70 | KEY_u = sdl2.SDLK_u 71 | KEY_v = sdl2.SDLK_v 72 | KEY_w = sdl2.SDLK_w 73 | KEY_x = sdl2.SDLK_x 74 | KEY_y = sdl2.SDLK_y 75 | KEY_z = sdl2.SDLK_z 76 | KEY_CAPSLOCK = sdl2.SDLK_CAPSLOCK 77 | KEY_F1 = sdl2.SDLK_F1 78 | KEY_F2 = sdl2.SDLK_F2 79 | KEY_F3 = sdl2.SDLK_F3 80 | KEY_F4 = sdl2.SDLK_F4 81 | KEY_F5 = sdl2.SDLK_F5 82 | KEY_F6 = sdl2.SDLK_F6 83 | KEY_F7 = sdl2.SDLK_F7 84 | KEY_F8 = sdl2.SDLK_F8 85 | KEY_F9 = sdl2.SDLK_F9 86 | KEY_F10 = sdl2.SDLK_F10 87 | KEY_F11 = sdl2.SDLK_F11 88 | KEY_F12 = sdl2.SDLK_F12 89 | KEY_PRINTSCREEN = sdl2.SDLK_PRINTSCREEN 90 | KEY_SCROLLLOCK = sdl2.SDLK_SCROLLLOCK 91 | KEY_PAUSE = sdl2.SDLK_PAUSE 92 | KEY_INSERT = sdl2.SDLK_INSERT 93 | KEY_HOME = sdl2.SDLK_HOME 94 | KEY_PAGEUP = sdl2.SDLK_PAGEUP 95 | KEY_DELETE = sdl2.SDLK_DELETE 96 | KEY_END = sdl2.SDLK_END 97 | KEY_PAGEDOWN = sdl2.SDLK_PAGEDOWN 98 | KEY_RIGHT = sdl2.SDLK_RIGHT 99 | KEY_LEFT = sdl2.SDLK_LEFT 100 | KEY_DOWN = sdl2.SDLK_DOWN 101 | KEY_UP = sdl2.SDLK_UP 102 | KEY_NUMLOCKCLEAR = sdl2.SDLK_NUMLOCKCLEAR 103 | KEY_KP_DIVIDE = sdl2.SDLK_KP_DIVIDE 104 | KEY_KP_MULTIPLY = sdl2.SDLK_KP_MULTIPLY 105 | KEY_KP_MINUS = sdl2.SDLK_KP_MINUS 106 | KEY_KP_PLUS = sdl2.SDLK_KP_PLUS 107 | KEY_KP_ENTER = sdl2.SDLK_KP_ENTER 108 | KEY_KP_1 = sdl2.SDLK_KP_1 109 | KEY_KP_2 = sdl2.SDLK_KP_2 110 | KEY_KP_3 = sdl2.SDLK_KP_3 111 | KEY_KP_4 = sdl2.SDLK_KP_4 112 | KEY_KP_5 = sdl2.SDLK_KP_5 113 | KEY_KP_6 = sdl2.SDLK_KP_6 114 | KEY_KP_7 = sdl2.SDLK_KP_7 115 | KEY_KP_8 = sdl2.SDLK_KP_8 116 | KEY_KP_9 = sdl2.SDLK_KP_9 117 | KEY_KP_0 = sdl2.SDLK_KP_0 118 | KEY_KP_PERIOD = sdl2.SDLK_KP_PERIOD 119 | KEY_APPLICATION = sdl2.SDLK_APPLICATION 120 | KEY_POWER = sdl2.SDLK_POWER 121 | KEY_KP_EQUALS = sdl2.SDLK_KP_EQUALS 122 | KEY_F13 = sdl2.SDLK_F13 123 | KEY_F14 = sdl2.SDLK_F14 124 | KEY_F15 = sdl2.SDLK_F15 125 | KEY_F16 = sdl2.SDLK_F16 126 | KEY_F17 = sdl2.SDLK_F17 127 | KEY_F18 = sdl2.SDLK_F18 128 | KEY_F19 = sdl2.SDLK_F19 129 | KEY_F20 = sdl2.SDLK_F20 130 | KEY_F21 = sdl2.SDLK_F21 131 | KEY_F22 = sdl2.SDLK_F22 132 | KEY_F23 = sdl2.SDLK_F23 133 | KEY_F24 = sdl2.SDLK_F24 134 | KEY_EXECUTE = sdl2.SDLK_EXECUTE 135 | KEY_HELP = sdl2.SDLK_HELP 136 | KEY_MENU = sdl2.SDLK_MENU 137 | KEY_SELECT = sdl2.SDLK_SELECT 138 | KEY_STOP = sdl2.SDLK_STOP 139 | KEY_AGAIN = sdl2.SDLK_AGAIN 140 | KEY_UNDO = sdl2.SDLK_UNDO 141 | KEY_CUT = sdl2.SDLK_CUT 142 | KEY_COPY = sdl2.SDLK_COPY 143 | KEY_PASTE = sdl2.SDLK_PASTE 144 | KEY_FIND = sdl2.SDLK_FIND 145 | KEY_MUTE = sdl2.SDLK_MUTE 146 | KEY_VOLUMEUP = sdl2.SDLK_VOLUMEUP 147 | KEY_VOLUMEDOWN = sdl2.SDLK_VOLUMEDOWN 148 | KEY_KP_COMMA = sdl2.SDLK_KP_COMMA 149 | KEY_KP_EQUALSAS400 = sdl2.SDLK_KP_EQUALSAS400 150 | KEY_ALTERASE = sdl2.SDLK_ALTERASE 151 | KEY_SYSREQ = sdl2.SDLK_SYSREQ 152 | KEY_CANCEL = sdl2.SDLK_CANCEL 153 | KEY_CLEAR = sdl2.SDLK_CLEAR 154 | KEY_PRIOR = sdl2.SDLK_PRIOR 155 | KEY_RETURN2 = sdl2.SDLK_RETURN2 156 | KEY_SEPARATOR = sdl2.SDLK_SEPARATOR 157 | KEY_OUT = sdl2.SDLK_OUT 158 | KEY_OPER = sdl2.SDLK_OPER 159 | KEY_CLEARAGAIN = sdl2.SDLK_CLEARAGAIN 160 | KEY_CRSEL = sdl2.SDLK_CRSEL 161 | KEY_EXSEL = sdl2.SDLK_EXSEL 162 | KEY_KP_00 = sdl2.SDLK_KP_00 163 | KEY_KP_000 = sdl2.SDLK_KP_000 164 | KEY_THOUSANDSSEPARATOR = sdl2.SDLK_THOUSANDSSEPARATOR 165 | KEY_DECIMALSEPARATOR = sdl2.SDLK_DECIMALSEPARATOR 166 | KEY_CURRENCYUNIT = sdl2.SDLK_CURRENCYUNIT 167 | KEY_CURRENCYSUBUNIT = sdl2.SDLK_CURRENCYSUBUNIT 168 | KEY_KP_LEFTPAREN = sdl2.SDLK_KP_LEFTPAREN 169 | KEY_KP_RIGHTPAREN = sdl2.SDLK_KP_RIGHTPAREN 170 | KEY_KP_LEFTBRACE = sdl2.SDLK_KP_LEFTBRACE 171 | KEY_KP_RIGHTBRACE = sdl2.SDLK_KP_RIGHTBRACE 172 | KEY_KP_TAB = sdl2.SDLK_KP_TAB 173 | KEY_KP_BACKSPACE = sdl2.SDLK_KP_BACKSPACE 174 | KEY_KP_A = sdl2.SDLK_KP_A 175 | KEY_KP_B = sdl2.SDLK_KP_B 176 | KEY_KP_C = sdl2.SDLK_KP_C 177 | KEY_KP_D = sdl2.SDLK_KP_D 178 | KEY_KP_E = sdl2.SDLK_KP_E 179 | KEY_KP_F = sdl2.SDLK_KP_F 180 | KEY_KP_XOR = sdl2.SDLK_KP_XOR 181 | KEY_KP_POWER = sdl2.SDLK_KP_POWER 182 | KEY_KP_PERCENT = sdl2.SDLK_KP_PERCENT 183 | KEY_KP_LESS = sdl2.SDLK_KP_LESS 184 | KEY_KP_GREATER = sdl2.SDLK_KP_GREATER 185 | KEY_KP_AMPERSAND = sdl2.SDLK_KP_AMPERSAND 186 | KEY_KP_DBLAMPERSAND = sdl2.SDLK_KP_DBLAMPERSAND 187 | KEY_KP_VERTICALBAR = sdl2.SDLK_KP_VERTICALBAR 188 | KEY_KP_DBLVERTICALBAR = sdl2.SDLK_KP_DBLVERTICALBAR 189 | KEY_KP_COLON = sdl2.SDLK_KP_COLON 190 | KEY_KP_HASH = sdl2.SDLK_KP_HASH 191 | KEY_KP_SPACE = sdl2.SDLK_KP_SPACE 192 | KEY_KP_AT = sdl2.SDLK_KP_AT 193 | KEY_KP_EXCLAM = sdl2.SDLK_KP_EXCLAM 194 | KEY_KP_MEMSTORE = sdl2.SDLK_KP_MEMSTORE 195 | KEY_KP_MEMRECALL = sdl2.SDLK_KP_MEMRECALL 196 | KEY_KP_MEMCLEAR = sdl2.SDLK_KP_MEMCLEAR 197 | KEY_KP_MEMADD = sdl2.SDLK_KP_MEMADD 198 | KEY_KP_MEMSUBTRACT = sdl2.SDLK_KP_MEMSUBTRACT 199 | KEY_KP_MEMMULTIPLY = sdl2.SDLK_KP_MEMMULTIPLY 200 | KEY_KP_MEMDIVIDE = sdl2.SDLK_KP_MEMDIVIDE 201 | KEY_KP_PLUSMINUS = sdl2.SDLK_KP_PLUSMINUS 202 | KEY_KP_CLEAR = sdl2.SDLK_KP_CLEAR 203 | KEY_KP_CLEARENTRY = sdl2.SDLK_KP_CLEARENTRY 204 | KEY_KP_BINARY = sdl2.SDLK_KP_BINARY 205 | KEY_KP_OCTAL = sdl2.SDLK_KP_OCTAL 206 | KEY_KP_DECIMAL = sdl2.SDLK_KP_DECIMAL 207 | KEY_KP_HEXADECIMAL = sdl2.SDLK_KP_HEXADECIMAL 208 | KEY_LCTRL = sdl2.SDLK_LCTRL 209 | KEY_LSHIFT = sdl2.SDLK_LSHIFT 210 | KEY_LALT = sdl2.SDLK_LALT 211 | KEY_LGUI = sdl2.SDLK_LGUI 212 | KEY_RCTRL = sdl2.SDLK_RCTRL 213 | KEY_RSHIFT = sdl2.SDLK_RSHIFT 214 | KEY_RALT = sdl2.SDLK_RALT 215 | KEY_RGUI = sdl2.SDLK_RGUI 216 | KEY_MODE = sdl2.SDLK_MODE 217 | KEY_AUDIONEXT = sdl2.SDLK_AUDIONEXT 218 | KEY_AUDIOPREV = sdl2.SDLK_AUDIOPREV 219 | KEY_AUDIOSTOP = sdl2.SDLK_AUDIOSTOP 220 | KEY_AUDIOPLAY = sdl2.SDLK_AUDIOPLAY 221 | KEY_AUDIOMUTE = sdl2.SDLK_AUDIOMUTE 222 | KEY_MEDIASELECT = sdl2.SDLK_MEDIASELECT 223 | KEY_WWW = sdl2.SDLK_WWW 224 | KEY_MAIL = sdl2.SDLK_MAIL 225 | KEY_CALCULATOR = sdl2.SDLK_CALCULATOR 226 | KEY_COMPUTER = sdl2.SDLK_COMPUTER 227 | KEY_AC_SEARCH = sdl2.SDLK_AC_SEARCH 228 | KEY_AC_HOME = sdl2.SDLK_AC_HOME 229 | KEY_AC_BACK = sdl2.SDLK_AC_BACK 230 | KEY_AC_FORWARD = sdl2.SDLK_AC_FORWARD 231 | KEY_AC_STOP = sdl2.SDLK_AC_STOP 232 | KEY_AC_REFRESH = sdl2.SDLK_AC_REFRESH 233 | KEY_AC_BOOKMARKS = sdl2.SDLK_AC_BOOKMARKS 234 | KEY_BRIGHTNESSDOWN = sdl2.SDLK_BRIGHTNESSDOWN 235 | KEY_BRIGHTNESSUP = sdl2.SDLK_BRIGHTNESSUP 236 | KEY_DISPLAYSWITCH = sdl2.SDLK_DISPLAYSWITCH 237 | KEY_KBDILLUMTOGGLE = sdl2.SDLK_KBDILLUMTOGGLE 238 | KEY_KBDILLUMDOWN = sdl2.SDLK_KBDILLUMDOWN 239 | KEY_KBDILLUMUP = sdl2.SDLK_KBDILLUMUP 240 | KEY_EJECT = sdl2.SDLK_EJECT 241 | KEY_SLEEP = sdl2.SDLK_SLEEP 242 | ``` 243 | -------------------------------------------------------------------------------- /docs/legacy/v3/wiki/math.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Types of PI in Fusion Engine 4 | These are used for certain miscellaneous math things. 5 | 6 | Full version of pi (3.141592653589793238462643383279502884197): 7 | ```python 8 | main.math.PI 9 | ``` 10 | A slightly smaller version that python's math library uses (3.141592653589793): 11 | ```python 12 | main.math.SMALLERPI 13 | ``` 14 | An extremely shortened version of pi (3.14): 15 | ```python 16 | main.math.SMALLPI 17 | ``` 18 | 19 | This allows you to get the floor value of a number. 20 | ```python 21 | main.math.FLOOR(3.4) 22 | ``` 23 | ## Euler's Number 24 | You can read more about it [here.](https://en.wikipedia.org/wiki/E_(mathematical_constant)) 25 | ```python 26 | main.math.EULERNUMBER 27 | ``` 28 | -------------------------------------------------------------------------------- /docs/legacy/v3/wiki/wiki.md: -------------------------------------------------------------------------------- 1 | 2 | # Main Wiki 3 | 4 | ## Create window 5 | 6 | To create a window were thing are draw, then you need to use this: 7 | 8 | ```python 9 | window = main.window.new_window("Example: 1", 800, 600) 10 | ``` 11 | 12 | ## Start loop 13 | 14 | In a loop you can draw things and it will run with the FPS that is setup. To start a loop, you have two choices: 15 | 16 | Choice 1: 17 | 18 | ```python 19 | @main.window.loop 20 | def loop(): 21 | ... # Your own loop things 22 | ``` 23 | 24 | Choice 2: 25 | 26 | ```python 27 | while main.window.running(window): 28 | ... # Your own loop thing 29 | 30 | ``` 31 | 32 | There is basically no difference, they all are doing the same thing, you use what you prefer. In our examples we use choice 1. 33 | 34 | ## Default message 35 | If you tried using our engine you may have encountered this message being printed to terminal: 36 | 37 | ```bash 38 | Fusion Engine 1.0.2 (Pygame-ce 2.3.0, Python 3.11.4) 39 | Welcome to Fusion Engine! https://github.com/dimkauzh/fusion-engine 40 | ``` 41 | 42 | To disable this behavior, you just give the main class when initting this argument: ``` message=False ```, like this: 43 | ```python 44 | import fusionengine as fusion 45 | 46 | main = fusion.Main("message=False") 47 | ``` 48 | 49 | ## Set Background color 50 | 51 | If you want to set a background color, you use this function before all draw functions: 52 | 53 | ```python 54 | main.draw.set_background_color(window, main.color.WHITE) 55 | ``` 56 | 57 | ## DeltaTime 58 | 59 | if you want to access delta time, you use this: 60 | 61 | ```python 62 | main.window.DELTATIME 63 | ``` 64 | 65 | ## Predefined shapes 66 | 67 | We have some predefined shapes that can be used and be drew on the screen. Here are some: 68 | 69 | Rectangle: 70 | 71 | ```python 72 | main.shape.new_rect(x, y, width, height, color) 73 | ``` 74 | 75 | - More shapes will be coming soon 76 | 77 | ## Window icon 78 | So you want to change the icon of your window? Well, its easy: 79 | 80 | ```python 81 | main.window.change_icon("path_to_icon") 82 | ``` 83 | 84 | ## Set FPS 85 | To set the framerate of your window, you use this: 86 | 87 | ```python 88 | main.window.set_fps(60) 89 | 90 | ``` 91 | 92 | ## Vectors 93 | 94 | ### Vector2d 95 | 96 | If you want to create a 2d vector that stores x and y, then you do this: 97 | 98 | ```python 99 | 100 | vector = main.vector.new_vector2d(10, 10) 101 | ``` 102 | 103 | ## Draw a line 104 | To draw a line, you use this: 105 | 106 | ```python 107 | # x1 y1 x2 y2 color 108 | main.draw.draw_line(window, 100, 100, 200, 200, main.color.BLUE) 109 | ``` 110 | 111 | 112 | ## Draw rectangle 113 | 114 | If you just want to draw a rectangle to test or to use it for your game/app, then you have 3 options: 115 | 116 | Option one: just draw a rectangle 117 | 118 | ```python 119 | main.draw.draw_rect(window, 100, 100, 400, 400, main.color.BLUE) 120 | ``` 121 | 122 | Second option: draw predefined rectangle: 123 | 124 | ```python 125 | main.draw.draw_own_rect(window, your_rect) 126 | ``` 127 | 128 | Third option: Draw a rectangle of lines 129 | 130 | ```python 131 | # x y w h color 132 | main.draw.draw_line_rect(window, 100, 100, 400, 400, main.color.BLUE) 133 | ``` 134 | 135 | 136 | ## Draw image 137 | 138 | You first need to create a variable with your image and image data: 139 | 140 | ```python 141 | image = main.image.open_image(window, main.DEBUGIMAGE, 100, 100, 400, 400) 142 | ``` 143 | 144 | main.DEBUGIMAGE is an image that is included with the engine, so you can use it freely. 145 | Then you need to render it (In the best situation this will happen in your loop): 146 | 147 | ```python 148 | main.image.draw_image(image) 149 | ``` 150 | 151 | ## Create entity WARNING: PRE ALPHA (It's in really early stages) 152 | 153 | If you want a player or an enemy or some moving object in your game, you can use an entity, thats an object that 154 | helps you manage things in your game: 155 | 156 | ```python 157 | # x y w h 158 | entity = main.body.Entity(window, 100, 100, 50, 50) 159 | ``` 160 | 161 | ### Draw rect with entity 162 | 163 | If you want to draw a rectangle that is basically in your entity, then you do it like this: 164 | 165 | ```python 166 | entity.draw_image(main.color.BLACK) 167 | 168 | ``` 169 | 170 | ### Draw image with entity 171 | 172 | If you want to draw a image on your entity, then you do this: 173 | 174 | ```python 175 | entity.image("image_path") 176 | ``` 177 | 178 | ## Sound 179 | 180 | ### Load sound 181 | 182 | To load a sound you do this: 183 | 184 | ```python 185 | your_sound = main.sound.load_sound("path_to_sound") 186 | ``` 187 | 188 | ### Play sound 189 | 190 | To play your loaded sound you use this: 191 | 192 | ```python 193 | your_sound.play() 194 | ``` 195 | 196 | ### Stop sound 197 | To stop your playing sound you use this: 198 | ```python 199 | your_sound.stop() 200 | ``` 201 | 202 | ### Backround music 203 | To start playing background music you use this: 204 | ```python 205 | main.sound.play_background_music("path_to_sound") 206 | ``` 207 | 208 | 209 | ## Storage system 210 | ### Init 211 | 212 | ```python 213 | my_db = JsonStorage("my_db.json") 214 | ``` 215 | This how you initialize your json storage system 216 | 217 | ### Insertion 218 | 219 | ```python 220 | my_db.insert({"first_name": "john", "last_name": "wick", "gold": 50}) 221 | my_db.insert({"first_name": "alexander", "last_name": "wick", "gold": 20}) 222 | ``` 223 | The code inserts two entries into the storage. The inserted data contains information about individuals' first names, last names, and gold amounts. 224 | 225 | ### Reading 226 | 227 | ```python 228 | Copy code 229 | my_db.search({"last_name": "wick"}) 230 | my_db.search({"last_name": "wick"}, get_index=True) 231 | ``` 232 | The code demonstrates reading operations. It searches for entries with the last name "wick" and retrieves results with and without index information. 233 | 234 | ### Updating 235 | 236 | ```python 237 | alex['gold'] += 20 238 | my_db.update(alex_index, alex) 239 | ``` 240 | The code showcases how to update data in the storage. In this case, it increases the "gold" value for an entry with the first name "alexander" by 20. 241 | 242 | ### Deleting 243 | 244 | ```python 245 | my_db.delete(john_index) 246 | ``` 247 | The code demonstrates deletion of data by removing an entry with the first name "john" from the storage. 248 | 249 | ### Saving to Disk 250 | ```python 251 | my_db.save() 252 | ``` 253 | The code shows how to save the modified data back to the storage file on disk. 254 | 255 | 256 | ## Keyboard input 257 | 258 | ### Keydown 259 | 260 | if you need keyboard input, then use this if statement with your own key (see key tab for all key names): 261 | 262 | ```python 263 | if main.event.key_down(main.keys.KEY_a): 264 | print("Key A pressed") 265 | ``` 266 | 267 | ### Keydown once 268 | 269 | If you need keydown to be only once, then you use this: 270 | 271 | ```python 272 | if main.event.key_down_once(main.keys.KEY_a): 273 | print("Key A pressed") 274 | ``` 275 | 276 | 277 | ## User Interface (UI) 278 | 279 | Creating a small ui for your application/game is easy with our following tools: 280 | 281 | ### Buttons 282 | 283 | To create a simple button we do the following: 284 | 285 | ```python 286 | 287 | # Create the button outside the loop 288 | button = main.ui.button.new_button( 289 | window, 290 | main.shape.new_rect_button(200, 200, 200, 200), 291 | "Hello World" 292 | ) 293 | 294 | ``` 295 | 296 | #### Button clicked 297 | 298 | If you want to check if your button was pressed or is being pressed, then you do that this way: 299 | 300 | ```python 301 | @main.window.loop 302 | def loop(): 303 | if button.button_pressed(): 304 | ... # Do your stuff 305 | ``` 306 | 307 | ### Rendering text 308 | If you want to render some fonts, then you can do it like this: 309 | 310 | - Option 1: Render text with build into fusion or your own font 311 | ```python 312 | # x y font size color 313 | main.ui.text.print_text(window, "Your text", 10, 10, main.fonts.NUNITO_LIGHT, 20, main.color.WHITE) 314 | ``` 315 | 316 | - Option 2: Render text with system font 317 | Its the same option 1, but you change the font to name of the font, like this: 318 | ```python 319 | main.ui.text.print_text(window, "Your text", 10, 10, "Arial", 20, main.color.WHITE) 320 | ``` 321 | 322 | ## Quit 323 | 324 | The quitting of the engine is done automaticly for you, so you dont have to worry about it. 325 | 326 | ### Force to quit 327 | If you want to force quit due to some reason, its pretty easy: 328 | ```python 329 | main.window.force_quit() 330 | ``` 331 | 332 | -------------------------------------------------------------------------------- /docs/legacy/v4/api/api.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | --- 5 | 6 | # API 7 | 8 | ## Window 9 | ```python 10 | Window(title: str, width: int, height: int) -> your_window 11 | ``` 12 | ### your_window: 13 | ```python 14 | change_icon(image_path: str) 15 | loop(your_loop_func) 16 | running(self) -> bool 17 | set_fps(self, fps: int) 18 | force_quit() 19 | toggle_quittable(self) 20 | ``` 21 | 22 | ## Events 23 | ```python 24 | key_down(key) 25 | key_down_once(key) 26 | ``` 27 | 28 | ## Draw 29 | ```python 30 | draw_line(window: Window, x1: int, y1: int, x2: int, y2: int, color: tuple) 31 | draw_line_rect(window: Window, x: int, y: int, width: int, height: int, color: tuple) 32 | draw_rect(window: Window, x: int, y: int, width: int, height: int, color: tuple) 33 | set_background_color(window: Window, color: tuple) 34 | set_pixel(window: Window, x: int, y: int, color: tuple) 35 | ``` 36 | 37 | ## Image 38 | ```python 39 | Image(window: Window, image_path: str, x: int, y: int, width: int, height: int) 40 | ``` 41 | 42 | ## Body 43 | ```python 44 | Entity(window: Window, x: int, y: int, width: int, height: int) 45 | ``` 46 | 47 | ## Shape 48 | ```python 49 | Rect(window: Window, x: int, y: int, width: int, height: int, color: tuple) -> your_rect 50 | ``` 51 | your_rect: 52 | ```python 53 | draw() 54 | ``` 55 | 56 | ## UI 57 | ```python 58 | Button(rect: Rect, text: str) -> your_button 59 | Text(window: Window, text: str, x: int, y: int, font_path: str, font_size: int, color: tuple) 60 | ``` 61 | your_button: 62 | ```python 63 | your_button.button_pressed() -> bool 64 | ``` 65 | 66 | ## Debug files 67 | ```python 68 | DEBUGIMAGE 69 | ``` 70 | 71 | ## Vector 72 | ```python 73 | Vector2D(x: int, y: int) 74 | Vector3D(x: int, y: int, z: int) 75 | ``` 76 | 77 | ## Sound 78 | ```python 79 | Sound(sound_path: str) -> your_sound 80 | BackgroundMusic(sound_path: str) -> your_backgroundmusic 81 | ``` 82 | your_sound: 83 | ```python 84 | play() 85 | stop() 86 | get_volume() 87 | set_volume(volume: int) 88 | fadeout(time: str) 89 | ``` 90 | your_backgroundmusic: 91 | ```python 92 | set_volume(volume: int) 93 | ``` 94 | 95 | 96 | # Math 97 | ```python 98 | PI = 3.141592653589793238462643383279502884197 99 | EULERNUMBER = 2.718281828459045 100 | main.math.FLOOR(3.4) 101 | ``` 102 | 103 | -------------------------------------------------------------------------------- /docs/legacy/v4/api/color.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | --- 5 | 6 | # Color API 7 | 8 | ## Color 9 | ```python 10 | ALICEBLUE = (240, 248, 255, 255) 11 | ANTIQUEWHITE = (250, 235, 215, 255) 12 | AQUA = (0, 255, 255, 255) 13 | AQUAMARINE = (127, 255, 212, 255) 14 | AZURE = (240, 255, 255, 255) 15 | BEIGE = (245, 245, 220, 255) 16 | BISQUE = (255, 228, 196, 255) 17 | BLACK = (0, 0, 0, 255) 18 | BLANCHEDALMOND = (255, 235, 205, 255) 19 | BLUE = (0, 0, 255, 255) 20 | BLUEVIOLET = (138, 43, 226, 255) 21 | BROWN = (165, 42, 42, 255) 22 | BURLYWOOD = (222, 184, 135, 255) 23 | CADETBLUE = (95, 158, 160, 255) 24 | CHARTREUSE = (127, 255, 0, 255) 25 | CHOCOLATE = (210, 105, 30, 255) 26 | CORAL = (255, 127, 80, 255) 27 | CORNFLOWERBLUE = (100, 149, 237, 255) 28 | CORNSILK = (255, 248, 220, 255) 29 | CRIMSON = (220, 20, 60, 255) 30 | CYAN = (0, 255, 255, 255) 31 | DARKBLUE = (0, 0, 139, 255) 32 | DARKCYAN = (0, 139, 139, 255) 33 | DARKGOLDENROD = (184, 134, 11, 255) 34 | DARKGRAY = (169, 169, 169, 255) 35 | DARKGREEN = (0, 100, 0, 255) 36 | DARKKHAKI = (189, 183, 107, 255) 37 | DARKMAGENTA = (139, 0, 139, 255) 38 | DARKOLIVEGREEN = (85, 107, 47, 255) 39 | DARKORANGE = (255, 140, 0, 255) 40 | DARKORCHID = (153, 50, 204, 255) 41 | DARKRED = (139, 0, 0, 255) 42 | DARKSALMON = (233, 150, 122, 255) 43 | DARKSEAGREEN = (143, 188, 143, 255) 44 | DARKSLATEBLUE = (72, 61, 139, 255) 45 | DARKSLATEGRAY = (47, 79, 79, 255) 46 | DARKTURQUOISE = (0, 206, 209, 255) 47 | DARKVIOLET = (148, 0, 211, 255) 48 | DEEPPINK = (255, 20, 147, 255) 49 | DEEPSKYBLUE = (0, 191, 255, 255) 50 | DIMGRAY = (105, 105, 105, 255) 51 | DODGERBLUE = (30, 144, 255, 255) 52 | FIREBRICK = (178, 34, 34, 255) 53 | FLORALWHITE = (255, 250, 240, 255) 54 | FORESTGREEN = (34, 139, 34, 255) 55 | FUCHSIA = (255, 0, 255, 255) 56 | GAINSBORO = (220, 220, 220, 255) 57 | GHOSTWHITE = (248, 248, 255, 255) 58 | GOLD = (255, 215, 0, 255) 59 | GOLDENROD = (218, 165, 32, 255) 60 | GRAY = (128, 128, 128, 255) 61 | GREEN = (0, 128, 0, 255) 62 | GREENYELLOW = (173, 255, 47, 255) 63 | HONEYDEW = (240, 255, 240, 255) 64 | HOTPINK = (255, 105, 180, 255) 65 | INDIANRED = (205, 92, 92, 255) 66 | INDIGO = (75, 0, 130, 255) 67 | IVORY = (255, 255, 240, 255) 68 | KHAKI = (240, 230, 140, 255) 69 | LAVENDER = (230, 230, 250, 255) 70 | LAVENDERBLUSH = (255, 240, 245, 255) 71 | LAWNGREEN = (124, 252, 0, 255) 72 | LEMONCHIFFON = (255, 250, 205, 255) 73 | LIGHTBLUE = (173, 216, 230, 255) 74 | LIGHTCORAL = (240, 128, 128, 255) 75 | LIGHTCYAN = (224, 255, 255, 255) 76 | LIGHTGOLDENRODYELLOW = (250, 250, 210, 255) 77 | LIGHTGRAY = (211, 211, 211, 255) 78 | LIGHTGREEN = (144, 238, 144, 255) 79 | LIGHTSALMON = (255, 182, 193, 255) 80 | LIGHTSEAGREEN = (32, 178, 170, 255) 81 | LIGHTSKYBLUE = (135, 206, 250, 255) 82 | LIGHTSLATEGRAY = (119, 136, 153, 255) 83 | LIGHTSTEELBLUE = (176, 196, 222, 255) 84 | LIGHTYELLOW = (255, 255, 224, 255) 85 | LIME = (0, 255, 0, 255) 86 | LIMEGREEN = (50, 205, 50, 255) 87 | LINEN = (250, 240, 230, 255) 88 | MAGENTA = (255, 0, 255, 255) 89 | MAROON = (128, 0, 0, 255) 90 | MEDIUMAQUAMARINE = (102, 205, 170, 255) 91 | MEDIUMBLUE = (0, 0, 205, 255) 92 | MEDIUMORCHID = (186, 85, 211, 255) 93 | MEDIUMPURPLE = (147, 112, 219, 255) 94 | MEDIUMSEAGREEN = (60, 179, 113, 255) 95 | MEDIUMSLATEBLUE = (123, 104, 238, 255) 96 | MEDIUMSPRINGGREEN = (0, 250, 154, 255) 97 | MEDIUMTURQUOISE = (72, 209, 204, 255) 98 | MEDIUMVIOLETRED = (199, 21, 133, 255) 99 | MIDNIGHTBLUE = (25, 25, 112, 255) 100 | MINTCREAM = (245, 255, 250, 255) 101 | MISTYROSE = (255, 228, 225, 255) 102 | MOCCASIN = (255, 228, 181, 255) 103 | NAVAJOWHITE = (255, 222, 173, 255) 104 | NAVY = (0, 0, 128, 255) 105 | OLDLACE = (253, 245, 230, 255) 106 | OLIVE = (128, 128, 0, 255) 107 | OLIVEDRAB = (107, 142, 35, 255) 108 | ORANGE = (255, 165, 0, 255) 109 | ORANGERED = (255, 69, 0, 255) 110 | ORCHID = (218, 112, 214, 255) 111 | PALEGOLDENROD = (238, 232, 170, 255) 112 | PALEGREEN = (152, 251, 152, 255) 113 | PALETURQUOISE = (175, 238, 238, 255) 114 | PALEVIOLETRED = (219, 112, 147, 255) 115 | PAPAYAWHIP = (255, 239, 213, 255) 116 | PEACHPUFF = (255, 218, 185, 255) 117 | PERU = (205, 133, 63, 255) 118 | PINK = (255, 192, 203, 255) 119 | PLUM = (221, 160, 221, 255) 120 | POWDERBLUE = (176, 224, 230, 255) 121 | PURPLE = (128, 0, 128, 255) 122 | REBECCAPURPLE = (102, 51, 153, 255) 123 | RED = (255, 0, 0, 255) 124 | ROSYBROWN = (188, 143, 143, 255) 125 | ROYALBLUE = (65, 105, 225, 255) 126 | SADDLEBROWN = (139, 69, 19, 255) 127 | SALMON = (250, 128, 114, 255) 128 | SANDYBROWN = (244, 164, 96, 255) 129 | SEAGREEN = (46, 139, 87, 255) 130 | SEASHELL = (255, 245, 238, 255) 131 | SIENNA = (160, 82, 45, 255) 132 | SILVER = (192, 192, 192, 255) 133 | SKYBLUE = (135, 206, 235, 255) 134 | SLATEBLUE = (106, 90, 205, 255) 135 | SLATEGRAY = (112, 128, 144, 255) 136 | SNOW = (255, 250, 250, 255) 137 | SPRINGGREEN = (0, 255, 127, 255) 138 | STEELBLUE = (70, 130, 180, 255) 139 | TAN = (210, 180, 140, 255) 140 | TEAL = (0, 128, 128, 255) 141 | THISTLE = (216, 191, 216, 255) 142 | TOMATO = (255, 99, 71, 255) 143 | TURQUOISE = (64, 224, 208, 255) 144 | VIOLET = (238, 130, 238, 255) 145 | WHEAT = (245, 222, 179, 255) 146 | WHITE = (255, 255, 255, 255) 147 | WHITESMOKE = (245, 245, 245, 255) 148 | YELLOW = (255, 255, 0, 255) 149 | YELLOWGREEN = (154, 205, 50, 255) 150 | ``` 151 | ## Color tools 152 | ```python 153 | hex_to_rgba(hex) 154 | hsv_to_rgb(hue, sat, val, alpha: int) -> tuple[int, int, int, int] 155 | ``` 156 | -------------------------------------------------------------------------------- /docs/legacy/v4/api/fonts.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | --- 5 | 6 | # Font API 7 | 8 | ```python 9 | NUNITO_LIGHT 10 | SAIRACONDENSED_EXTRABOLD 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /docs/legacy/v4/api/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | --- 5 | 6 | # Api 7 | 8 | This isn't maintained since fusion v4.1.0 9 | 10 | ## Table of contents 11 | - [Main API](api.md) 12 | - [Color API](color.md) 13 | - [Font API](fonts.md) 14 | - [Key API](keys.md) 15 | -------------------------------------------------------------------------------- /docs/legacy/v4/api/keys.md: -------------------------------------------------------------------------------- 1 | --- 2 | hide: 3 | - navigation 4 | --- 5 | 6 | # Keys API 7 | ```python 8 | KEY_UNKNOWN = pg.K_UNKNOWN 9 | KEY_RETURN = pg.K_RETURN 10 | KEY_ESCAPE = pg.K_ESCAPE 11 | KEY_BACKSPACE = pg.K_BACKSPACE 12 | KEY_TAB = pg.K_TAB 13 | KEY_SPACE = pg.K_SPACE 14 | KEY_EXCLAIM = pg.K_EXCLAIM 15 | KEY_QUOTEDBL = pg.K_QUOTEDBL 16 | KEY_HASH = pg.K_HASH 17 | KEY_PERCENT = pg.K_PERCENT 18 | KEY_DOLLAR = pg.K_DOLLAR 19 | KEY_AMPERSAND = pg.K_AMPERSAND 20 | KEY_QUOTE = pg.K_QUOTE 21 | KEY_LEFTPAREN = pg.K_LEFTPAREN 22 | KEY_RIGHTPAREN = pg.K_RIGHTPAREN 23 | KEY_ASTERISK = pg.K_ASTERISK 24 | KEY_PLUS = pg.K_PLUS 25 | KEY_COMMA = pg.K_COMMA 26 | KEY_MINUS = pg.K_MINUS 27 | KEY_PERIOD = pg.K_PERIOD 28 | KEY_SLASH = pg.K_SLASH 29 | KEY_0 = pg.K_0 30 | KEY_1 = pg.K_1 31 | KEY_2 = pg.K_2 32 | KEY_3 = pg.K_3 33 | KEY_4 = pg.K_4 34 | KEY_5 = pg.K_5 35 | KEY_6 = pg.K_6 36 | KEY_7 = pg.K_7 37 | KEY_8 = pg.K_8 38 | KEY_9 = pg.K_9 39 | KEY_COLON = pg.K_COLON 40 | KEY_SEMICOLON = pg.K_SEMICOLON 41 | KEY_LESS = pg.K_LESS 42 | KEY_EQUALS = pg.K_EQUALS 43 | KEY_GREATER = pg.K_GREATER 44 | KEY_QUESTION = pg.K_QUESTION 45 | KEY_AT = pg.K_AT 46 | KEY_LEFTBRACKET = pg.K_LEFTBRACKET 47 | KEY_BACKSLASH = pg.K_BACKSLASH 48 | KEY_RIGHTBRACKET = pg.K_RIGHTBRACKET 49 | KEY_CARET = pg.K_CARET 50 | KEY_UNDERSCORE = pg.K_UNDERSCORE 51 | KEY_BACKQUOTE = pg.K_BACKQUOTE 52 | KEY_a = pg.K_a 53 | KEY_b = pg.K_b 54 | KEY_c = pg.K_c 55 | KEY_d = pg.K_d 56 | KEY_e = pg.K_e 57 | KEY_f = pg.K_f 58 | KEY_g = pg.K_g 59 | KEY_h = pg.K_h 60 | KEY_i = pg.K_i 61 | KEY_j = pg.K_j 62 | KEY_k = pg.K_k 63 | KEY_l = pg.K_l 64 | KEY_m = pg.K_m 65 | KEY_n = pg.K_n 66 | KEY_o = pg.K_o 67 | KEY_p = pg.K_p 68 | KEY_q = pg.K_q 69 | KEY_r = pg.K_r 70 | KEY_s = pg.K_s 71 | KEY_t = pg.K_t 72 | KEY_u = pg.K_u 73 | KEY_v = pg.K_v 74 | KEY_w = pg.K_w 75 | KEY_x = pg.K_x 76 | KEY_y = pg.K_y 77 | KEY_z = pg.K_z 78 | KEY_CAPSLOCK = pg.K_CAPSLOCK 79 | KEY_F1 = pg.K_F1 80 | KEY_F2 = pg.K_F2 81 | KEY_F3 = pg.K_F3 82 | KEY_F4 = pg.K_F4 83 | KEY_F5 = pg.K_F5 84 | KEY_F6 = pg.K_F6 85 | KEY_F7 = pg.K_F7 86 | KEY_F8 = pg.K_F8 87 | KEY_F9 = pg.K_F9 88 | KEY_F10 = pg.K_F10 89 | KEY_F11 = pg.K_F11 90 | KEY_F12 = pg.K_F12 91 | KEY_PRINTSCREEN = pg.K_PRINT 92 | KEY_SCROLLLOCK = pg.K_SCROLLLOCK 93 | KEY_PAUSE = pg.K_PAUSE 94 | KEY_INSERT = pg.K_INSERT 95 | KEY_HOME = pg.K_HOME 96 | KEY_PAGEUP = pg.K_PAGEUP 97 | KEY_DELETE = pg.K_DELETE 98 | KEY_END = pg.K_END 99 | KEY_PAGEDOWN = pg.K_PAGEDOWN 100 | KEY_RIGHT = pg.K_RIGHT 101 | KEY_LEFT = pg.K_LEFT 102 | KEY_DOWN = pg.K_DOWN 103 | KEY_UP = pg.K_UP 104 | KEY_NUMLOCKCLEAR = pg.K_NUMLOCK 105 | KEY_KP_DIVIDE = pg.K_KP_DIVIDE 106 | KEY_KP_MULTIPLY = pg.K_KP_MULTIPLY 107 | KEY_KP_MINUS = pg.K_KP_MINUS 108 | KEY_KP_PLUS = pg.K_KP_PLUS 109 | KEY_KP_ENTER = pg.K_KP_ENTER 110 | KEY_KP_1 = pg.K_KP1 111 | KEY_KP_2 = pg.K_KP2 112 | KEY_KP_3 = pg.K_KP3 113 | KEY_KP_4 = pg.K_KP4 114 | KEY_KP_5 = pg.K_KP5 115 | KEY_KP_6 = pg.K_KP6 116 | KEY_KP_7 = pg.K_KP7 117 | KEY_KP_8 = pg.K_KP8 118 | KEY_KP_9 = pg.K_KP9 119 | KEY_KP_0 = pg.K_KP0 120 | KEY_KP_PERIOD = pg.K_KP_PERIOD 121 | KEY_POWER = pg.K_POWER 122 | KEY_KP_EQUALS = pg.K_KP_EQUALS 123 | KEY_F13 = pg.K_F13 124 | KEY_F14 = pg.K_F14 125 | KEY_F15 = pg.K_F15 126 | KEY_HELP = pg.K_HELP 127 | KEY_MENU = pg.K_MENU 128 | KEY_SYSREQ = pg.K_SYSREQ 129 | KEY_CLEAR = pg.K_CLEAR 130 | KEY_CURRENCYUNIT = pg.K_CURRENCYUNIT 131 | KEY_CURRENCYSUBUNIT = pg.K_CURRENCYSUBUNIT 132 | KEY_LCTRL = pg.K_LCTRL 133 | KEY_LSHIFT = pg.K_LSHIFT 134 | KEY_LALT = pg.K_LALT 135 | KEY_LGUI = pg.K_LMETA 136 | KEY_RCTRL = pg.K_RCTRL 137 | KEY_RSHIFT = pg.K_RSHIFT 138 | KEY_RALT = pg.K_RALT 139 | KEY_RGUI = pg.K_RMETA 140 | KEY_MODE = pg.K_MODE 141 | KEY_AC_BACK = pg.K_AC_BACK 142 | ``` 143 | -------------------------------------------------------------------------------- /docs/legacy/v4/assets/gifs/example.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/legacy/v4/assets/gifs/example.gif -------------------------------------------------------------------------------- /docs/legacy/v4/assets/logo/fe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/docs/legacy/v4/assets/logo/fe.png -------------------------------------------------------------------------------- /docs/legacy/v4/tutorials/basics.md: -------------------------------------------------------------------------------- 1 | logo 2 | # Basic rendering tutorial 3 | 4 | ## Introduction 5 | This is a tutorial so you would understand the basics of the engine and how it works. In this tutorial we will learn how to render a window and draw some images on it. If you want to learn more, then go to [our docs](https://docs.fusion-engine.tech) and select wiki. 6 | 7 | This tutorial also expect you to have everything setup, if not, head over to [tutorial 1: setting everything up](setup.md) 8 | 9 | The Final Product Should Look like This: 10 | ![gif](../assets/gifs/example.gif) 11 | 12 | ## Creating a window 13 | 14 | So if you read tutorial 1 you know we have the main variable running our engine object. So now we create a window with the help of that main object: 15 | ```python 16 | window = fusion.Window("Tutorial 2", 600, 600) 17 | ``` 18 | The first argument that we give our function is our title, second argument is our width and third one is height 19 | 20 | ## Pre-loading image 21 | We will now pre-load a image so we can draw it later on our window. We do it like this: 22 | ```python 23 | image = fusion.Image(window, fusion.DEBUGIMAGE, 0, 0, 600, 600) 24 | ``` 25 | Fist argument is our window, second is our image path, third is our x position, fourth is our y position, fifth is our width and sixth is our height. As you maybe see were using fusion.DEBUGIMAGE, which is a build in image into our engine for testing purposes. We will use it for our tutorial 26 | 27 | ## Starting a loop 28 | A loop is basicly what lets our window be open the whole time and not be automaticly closed. You also run there functions that need to ran every frame. So we start a loop like this: 29 | ```python 30 | @window.loop 31 | def loop(): 32 | ... # Code goes here 33 | 34 | ``` 35 | 36 | ## Drawing image 37 | So we still need to draw our image after loading it, and you can do that easily inside a loop like this: 38 | ```python 39 | @main.window.loop 40 | def loop(): 41 | image.draw() 42 | 43 | ``` 44 | As you see we have a draw function in our loop with the image loaded image as base (object). 45 | 46 | ## Full code 47 | Here is our full code that we could through this tutorial: 48 | ```python 49 | import fusionengine as fusion 50 | 51 | window = fusion.Window("Example: 1", 600, 600) 52 | image = fusion.Image(window, fusion.DEBUGIMAGE, 0, 0, 600, 600) 53 | 54 | 55 | @window.loop 56 | def loop(): 57 | image.draw() 58 | 59 | ``` 60 | 61 | ## Ending 62 | This was our basic tutorial to images. There are (or will be) more tutorials, so check them our. Or otherwise you could check our [docs]() for more information. Happy coding! 63 | 64 | -------------------------------------------------------------------------------- /docs/legacy/v4/tutorials/setup.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Setting everything up 4 | 5 | ## Introduction 6 | Welcome to our fusion-engine tutorials! Here you can learn about our engine and how to use it! This will go easy over everything you need to know to start programming with fusion! 7 | 8 | So this tutorial is made to setup everything, so you can start programming with fusion-engine! But if you already have everything setup then head over to [tutorial 2: basic rendering](basics.md) 9 | 10 | ## Installing 11 | So firstly we need to install fusion-engine. We have our package hoster at pypi so you can easly install it by running: 12 | ```bash 13 | pip install fusion-engine 14 | ``` 15 | 16 | ## Importing 17 | Now we need to import fusion-engine to our project. We do it like this: 18 | ```python 19 | import fusionengine as fusion 20 | ``` 21 | 22 | ## Ending 23 | That was it, our engine is now setup! Now every function works from our main variable, as you might see later. 24 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/color.md: -------------------------------------------------------------------------------- 1 | ## Using colors 2 | Our engine has some build in predefined colors so it's a bit easier for you with colors, to acess the colors you run: 3 | ```python 4 | fusion.WHITE 5 | ``` 6 | ## All colors 7 | The color name is always capitalised as per [PEP 8 → Constants](https://peps.python.org/pep-0008/#constants). All colors are defined and named (with capitalised form) as per [Sublime Text → Docs → Color Schemes → Appendix - CSS Colors](https://www.sublimetext.com/docs/color_schemes.html#appendix-css-colors). 8 | 9 | ## Custom color 10 | If you want your own color, you just give your function a tuple argument with RGBA colors, here is an example: 11 | ```python 12 | fusion.draw_rect(window, 100, 100, 400, 400, (255, 255, 255, 0)) 13 | ``` 14 | 15 | ## Hex to rgba 16 | If you have a hex color and want to convert it to rgba you can use this function: 17 | ```python 18 | fusion.hex_to_rgba(hex) 19 | ``` 20 | 21 | ## HSV to RGB 22 | If you have a HSV color and want to convert it to RGB you can use this function: 23 | ```python 24 | fusion.hsv_to_rgb(h, s, v) 25 | ``` 26 | hsv_to_rgb(hue, sat, val, alpha) -> tuple[int, int, int, int] -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/events-keys.md: -------------------------------------------------------------------------------- 1 | # Events and keys 2 | ## Keyboard input 3 | 4 | ### Keydown 5 | 6 | if you need keyboard input, then use this if statement with your own key (see key tab for all key names): 7 | 8 | ```python 9 | if fusion.key_down(fusion.KEY_A): 10 | print("Key A pressed") 11 | ``` 12 | 13 | Or you can do it this way: 14 | ```python 15 | if fusion.Key(fusion.KEY_A).key_down(): 16 | print("Key A pressed") 17 | ``` 18 | 19 | ### Keydown once 20 | 21 | If you need keydown to be only once, then you use this: 22 | ```python 23 | if fusion.key_down_once(fusion.KEY_A): 24 | print("Key A pressed") 25 | 26 | ``` 27 | 28 | Or you can do it this way: 29 | ```python 30 | if fusion.Key(fusion.KEY_A).key_down_once(): 31 | print("Key A pressed") 32 | ``` 33 | 34 | 35 | 36 | ## Keys 37 | We use Pygame for this, here are our key bindings to the pygame keys: 38 | ```python 39 | KEY_UNKNOWN = pg.K_UNKNOWN 40 | KEY_RETURN = pg.K_RETURN 41 | KEY_ESCAPE = pg.K_ESCAPE 42 | KEY_BACKSPACE = pg.K_BACKSPACE 43 | KEY_TAB = pg.K_TAB 44 | KEY_SPACE = pg.K_SPACE 45 | KEY_EXCLAIM = pg.K_EXCLAIM 46 | KEY_QUOTEDBL = pg.K_QUOTEDBL 47 | KEY_HASH = pg.K_HASH 48 | KEY_PERCENT = pg.K_PERCENT 49 | KEY_DOLLAR = pg.K_DOLLAR 50 | KEY_AMPERSAND = pg.K_AMPERSAND 51 | KEY_QUOTE = pg.K_QUOTE 52 | KEY_LEFTPAREN = pg.K_LEFTPAREN 53 | KEY_RIGHTPAREN = pg.K_RIGHTPAREN 54 | KEY_ASTERISK = pg.K_ASTERISK 55 | KEY_PLUS = pg.K_PLUS 56 | KEY_COMMA = pg.K_COMMA 57 | KEY_MINUS = pg.K_MINUS 58 | KEY_PERIOD = pg.K_PERIOD 59 | KEY_SLASH = pg.K_SLASH 60 | 61 | KEY_0 = pg.K_0 62 | KEY_1 = pg.K_1 63 | KEY_2 = pg.K_2 64 | KEY_3 = pg.K_3 65 | KEY_4 = pg.K_4 66 | KEY_5 = pg.K_5 67 | KEY_6 = pg.K_6 68 | KEY_7 = pg.K_7 69 | KEY_8 = pg.K_8 70 | KEY_9 = pg.K_9 71 | 72 | KEY_COLON = pg.K_COLON 73 | KEY_SEMICOLON = pg.K_SEMICOLON 74 | KEY_LESS = pg.K_LESS 75 | KEY_EQUALS = pg.K_EQUALS 76 | KEY_GREATER = pg.K_GREATER 77 | KEY_QUESTION = pg.K_QUESTION 78 | KEY_AT = pg.K_AT 79 | KEY_LEFTBRACKET = pg.K_LEFTBRACKET 80 | KEY_BACKSLASH = pg.K_BACKSLASH 81 | KEY_RIGHTBRACKET = pg.K_RIGHTBRACKET 82 | KEY_CARET = pg.K_CARET 83 | KEY_UNDERSCORE = pg.K_UNDERSCORE 84 | KEY_BACKQUOTE = pg.K_BACKQUOTE 85 | 86 | KEY_a = pg.K_a 87 | KEY_b = pg.K_b 88 | KEY_c = pg.K_c 89 | KEY_d = pg.K_d 90 | KEY_e = pg.K_e 91 | KEY_f = pg.K_f 92 | KEY_g = pg.K_g 93 | KEY_h = pg.K_h 94 | KEY_i = pg.K_i 95 | KEY_j = pg.K_j 96 | KEY_k = pg.K_k 97 | KEY_l = pg.K_l 98 | KEY_m = pg.K_m 99 | KEY_n = pg.K_n 100 | KEY_o = pg.K_o 101 | KEY_p = pg.K_p 102 | KEY_q = pg.K_q 103 | KEY_r = pg.K_r 104 | KEY_s = pg.K_s 105 | KEY_t = pg.K_t 106 | KEY_u = pg.K_u 107 | KEY_v = pg.K_v 108 | KEY_w = pg.K_w 109 | KEY_x = pg.K_x 110 | KEY_y = pg.K_y 111 | KEY_z = pg.K_z 112 | 113 | KEY_A = pg.K_a 114 | KEY_B = pg.K_b 115 | KEY_C = pg.K_c 116 | KEY_D = pg.K_d 117 | KEY_E = pg.K_e 118 | KEY_F = pg.K_f 119 | KEY_G = pg.K_g 120 | KEY_H = pg.K_h 121 | KEY_I = pg.K_i 122 | KEY_J = pg.K_j 123 | KEY_K = pg.K_k 124 | KEY_L = pg.K_l 125 | KEY_M = pg.K_m 126 | KEY_N = pg.K_n 127 | KEY_O = pg.K_o 128 | KEY_P = pg.K_p 129 | KEY_Q = pg.K_q 130 | KEY_R = pg.K_r 131 | KEY_S = pg.K_s 132 | KEY_T = pg.K_t 133 | KEY_U = pg.K_u 134 | KEY_V = pg.K_v 135 | KEY_W = pg.K_w 136 | KEY_X = pg.K_x 137 | KEY_Y = pg.K_y 138 | KEY_Z = pg.K_z 139 | 140 | KEY_CAPSLOCK = pg.K_CAPSLOCK 141 | 142 | KEY_F1 = pg.K_F1 143 | KEY_F2 = pg.K_F2 144 | KEY_F3 = pg.K_F3 145 | KEY_F4 = pg.K_F4 146 | KEY_F5 = pg.K_F5 147 | KEY_F6 = pg.K_F6 148 | KEY_F7 = pg.K_F7 149 | KEY_F8 = pg.K_F8 150 | KEY_F9 = pg.K_F9 151 | KEY_F10 = pg.K_F10 152 | KEY_F11 = pg.K_F11 153 | KEY_F12 = pg.K_F12 154 | KEY_F13 = pg.K_F13 155 | KEY_F14 = pg.K_F14 156 | KEY_F15 = pg.K_F15 157 | 158 | KEY_PRINTSCREEN = pg.K_PRINT 159 | KEY_SCROLLLOCK = pg.K_SCROLLLOCK 160 | KEY_PAUSE = pg.K_PAUSE 161 | KEY_INSERT = pg.K_INSERT 162 | KEY_HOME = pg.K_HOME 163 | KEY_PAGEUP = pg.K_PAGEUP 164 | KEY_DELETE = pg.K_DELETE 165 | KEY_END = pg.K_END 166 | KEY_PAGEDOWN = pg.K_PAGEDOWN 167 | KEY_RIGHT = pg.K_RIGHT 168 | KEY_LEFT = pg.K_LEFT 169 | KEY_DOWN = pg.K_DOWN 170 | KEY_UP = pg.K_UP 171 | KEY_NUMLOCKCLEAR = pg.K_NUMLOCK 172 | KEY_KP_DIVIDE = pg.K_KP_DIVIDE 173 | KEY_KP_MULTIPLY = pg.K_KP_MULTIPLY 174 | KEY_KP_MINUS = pg.K_KP_MINUS 175 | KEY_KP_PLUS = pg.K_KP_PLUS 176 | KEY_KP_ENTER = pg.K_KP_ENTER 177 | 178 | KEY_KP_1 = pg.K_KP1 179 | KEY_KP_2 = pg.K_KP2 180 | KEY_KP_3 = pg.K_KP3 181 | KEY_KP_4 = pg.K_KP4 182 | KEY_KP_5 = pg.K_KP5 183 | KEY_KP_6 = pg.K_KP6 184 | KEY_KP_7 = pg.K_KP7 185 | KEY_KP_8 = pg.K_KP8 186 | KEY_KP_9 = pg.K_KP9 187 | KEY_KP_0 = pg.K_KP0 188 | 189 | KEY_KP_PERIOD = pg.K_KP_PERIOD 190 | KEY_POWER = pg.K_POWER 191 | KEY_KP_EQUALS = pg.K_KP_EQUALS 192 | KEY_HELP = pg.K_HELP 193 | KEY_MENU = pg.K_MENU 194 | KEY_SYSREQ = pg.K_SYSREQ 195 | KEY_CLEAR = pg.K_CLEAR 196 | KEY_CURRENCYUNIT = pg.K_CURRENCYUNIT 197 | KEY_CURRENCYSUBUNIT = pg.K_CURRENCYSUBUNIT 198 | KEY_LCTRL = pg.K_LCTRL 199 | KEY_LSHIFT = pg.K_LSHIFT 200 | KEY_LALT = pg.K_LALT 201 | KEY_LGUI = pg.K_LMETA 202 | KEY_RCTRL = pg.K_RCTRL 203 | KEY_RSHIFT = pg.K_RSHIFT 204 | KEY_RALT = pg.K_RALT 205 | KEY_RGUI = pg.K_RMETA 206 | KEY_MODE = pg.K_MODE 207 | KEY_AC_BACK = pg.K_AC_BACK 208 | ``` 209 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/external.md: -------------------------------------------------------------------------------- 1 | # External tools 2 | 3 | ## Using pygame 4 | If you cant find some function you need in this engine, the you could use pygame as the engine is build on pygame. You dont need to import pygame, as that can make some issues, you just use: 5 | ```python 6 | fusion.pg 7 | ``` 8 | 9 | ## Using pygame 10 | If you cant find some gui functions, you can use pygame gui, as the engine is using pygame_gui library. You dont need to import pygame gui, as that can make some issues, you just use: 11 | ```python 12 | fusion.gui 13 | ``` 14 | 15 | ## Using Codon Compiler 16 | So you heard of [codon](https://docs.exaloop.io/codon/), a python compiler with can compile your python code to machine code, which makes your code a lot faster But how do you use it? Well, its easy! You just install it and then modify these things in your code: 17 | 18 | Imports: 19 | ```python 20 | from python import fusionengine as fusion 21 | ``` 22 | 23 | Loop: 24 | You need to modify our loop to support codon, so you need to change it to this: 25 | ```python 26 | while your_window.running(): 27 | ... # Your own loop thing 28 | ``` 29 | You may reconise this type of while loop from the main wiki as your second option. -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/extra.md: -------------------------------------------------------------------------------- 1 | # Extra things 2 | 3 | ## Default message 4 | If you tried using our engine you may have encountered this message being printed to terminal: 5 | 6 | ```bash 7 | Fusion Engine 4.0.0 (Pygame-ce 2.4.0, Python 3.11.7) 8 | Welcome to Fusion Engine! https://github.com/dimkauzh/fusion-engine 9 | ``` 10 | 11 | To disable this behavior, you just give the main class when initting this argument, set your "FUSION_HIDE_PROMPT" enviorment variable to "no". -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/fonts.md: -------------------------------------------------------------------------------- 1 | ## Fonts 2 | Our engine has some build in fonts, the following fonts are available: 3 | 4 | Nunito Sans Light: 5 | ```python 6 | fusion.NUNITO_LIGHT 7 | ``` 8 | Saira Condensed Extrabold: 9 | ```python 10 | fusion.SAIRACONDENSED_EXTRABOLD 11 | ``` 12 | 13 | There will be more fonts available in the future. 14 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/math.md: -------------------------------------------------------------------------------- 1 | # Small math module 2 | ## Vectors 3 | ### Vector2d 4 | 5 | If you want to create a 2d vector that stores x and y, then you do this: 6 | 7 | ```python 8 | vector = fusion.Vector2D(10, 10) 9 | ``` 10 | This creates a vector with the x being 10 and the y also being 10. 11 | 12 | ### Vector3d 13 | if you want to create a 3d vector that stores x, y and z, then you do this: 14 | ```python 15 | vector = fusion.Vector3D(10, 10, 10) 16 | ``` 17 | This creates a 3d vector with the x, y and z being 10. 18 | 19 | ## Types of PI in Fusion Engine 20 | These are used for certain miscellaneous math things. 21 | 22 | Full version of pi (3.141592653589793238462643383279502884197): 23 | ```python 24 | fusion.PI 25 | ``` 26 | A slightly smaller version that python's math library uses (3.141592653589793): 27 | ```python 28 | fusion.SMALLERPI 29 | ``` 30 | An extremely shortened version of pi (3.14): 31 | ```python 32 | fusion.SMALLPI 33 | ``` 34 | 35 | This allows you to get the floor value of a number. 36 | ```python 37 | fusion.FLOOR(3.4) 38 | ``` 39 | ## Euler's Number 40 | You can read more about it [here.](https://en.wikipedia.org/wiki/E_(mathematical_constant)) 41 | ```python 42 | fusion.EULERNUMBER 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/music.md: -------------------------------------------------------------------------------- 1 | ## Sound 2 | 3 | ### Load sound 4 | 5 | To load a sound you do this: 6 | 7 | ```python 8 | your_sound = fusion.Sound("path_to_sound") 9 | ``` 10 | 11 | ### Play sound 12 | 13 | To play your loaded sound you use this: 14 | 15 | ```python 16 | your_sound.play() 17 | ``` 18 | 19 | ### Stop sound 20 | To stop your playing sound you use this: 21 | ```python 22 | your_sound.stop() 23 | ``` 24 | 25 | ### Get volume 26 | To get the volume of your sound you use this: 27 | ```python 28 | your_sound.get_volume() 29 | ``` 30 | 31 | ### Set volume 32 | To set the volume of your sound you use this: 33 | ```python 34 | your_sound.set_volume(0.5) 35 | ``` 36 | 37 | ### Fadeout 38 | To fadeout your sound you use this: 39 | ```python 40 | your_sound.fadeout(1000) 41 | ``` 42 | 43 | 44 | ### Backround music 45 | To start playing background music you use this: 46 | ```python 47 | your_backgroundmusic = fusion.BackgroundMusic("path_to_sound") 48 | ``` 49 | 50 | #### Set background music volume 51 | To set the volume of your background music you use this: 52 | ```python 53 | your_backgroundmusic.set_volume(0.5) 54 | ``` 55 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/rendering.md: -------------------------------------------------------------------------------- 1 | # Rendering 2 | ## Set Background color 3 | 4 | If you want to set a background color, you use this function before all draw functions: 5 | 6 | ```python 7 | fusion.set_background_color(window, fusion.WHITE) 8 | ``` 9 | 10 | 11 | ## Predefined shapes 12 | 13 | We have some predefined shapes that can be used and be drew on the screen. Here are some: 14 | 15 | Rectangle: 16 | 17 | ```python 18 | your_shape = fusion.Rect(window, x, y, width, height, color) 19 | ``` 20 | 21 | ### Drawing the shape 22 | To draw your shape, you use this: 23 | ```python 24 | your_shape.draw() 25 | ``` 26 | 27 | - More shapes will be coming soon 28 | 29 | 30 | ## Draw a line 31 | To draw a line, you use this: 32 | 33 | ```python 34 | # x1 y1 x2 y2 color 35 | fusion.draw_line(window, 100, 100, 200, 200, fusion.BLUE) 36 | ``` 37 | 38 | ## Draw rectangle 39 | 40 | If you just want to draw a rectangle to test or to use it for your game/app, then you have 3 options: 41 | 42 | Option one: just draw a rectangle 43 | 44 | ```python 45 | # x y w h color 46 | fusion.draw_rect(window, 100, 100, 400, 400, fusion.BLUE) 47 | ``` 48 | 49 | Third option: Draw a rectangle of lines 50 | 51 | ```python 52 | # x y w h color 53 | fusion.draw_line_rect(window, 100, 100, 400, 400, fusion.BLUE) 54 | ``` 55 | 56 | 57 | ## Draw image 58 | 59 | You first need to create a variable with your image and image data: 60 | 61 | ```python 62 | your_image = fusion.Image(window, fusion.DEBUGIMAGE, 100, 100, 400, 400) 63 | ``` 64 | 65 | main.DEBUGIMAGE is an image that is included with the engine, so you can use it freely. 66 | Then you need to render it (In the best situation this will happen in your loop): 67 | 68 | ```python 69 | your_image.draw() 70 | ``` 71 | 72 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/scene.md: -------------------------------------------------------------------------------- 1 | # Scenes, Entities and animations 2 | 3 | ## Scene manager 4 | See in [this example](https://github.com/dimkauzh/fusion-engine/blob/main/examples/example5.py) how to use the scene manager. 5 | 6 | ## Entities 7 | 8 | If you want a player or an enemy or some moving object in your game, you can use an entity, thats an object that 9 | helps you manage things in your game: 10 | 11 | ```python 12 | # x y w h 13 | your_entity = fusion.Entity(window, 100, 100, 50, 50) 14 | ``` 15 | 16 | ### Draw rect with entity 17 | 18 | If you want to draw a rectangle that is basically in your entity, then you do it like this: 19 | 20 | ```python 21 | your_entity.load_rect(fusion.BLACK) 22 | ``` 23 | Then you can draw it with: 24 | 25 | ```python 26 | your_entity.draw_rect() 27 | ``` 28 | 29 | ### Draw image with entity 30 | 31 | If you want to draw a image on your entity, then you do this: 32 | 33 | ```python 34 | your_entity.load_image("image_path") 35 | ``` 36 | 37 | Then you can draw it with: 38 | 39 | ```python 40 | your_entity.draw_image() 41 | ``` 42 | 43 | ### Custom animations with entities 44 | Fusion has some build-in features into entity system to make animations more easy, here are some ways to use it 45 | 46 | #### Load frames 47 | First of all, you need to load frames, and you can do this using this way: 48 | ```python 49 | your_entity.load_animation(images: tuple) 50 | ``` 51 | 52 | #### Setting current frame 53 | You can set the current frame with this function 54 | ```python 55 | your_entity.set_frame(frame: int) 56 | ``` 57 | 58 | #### Getting current frame 59 | To get the current frame, run: 60 | ```python 61 | my_frame_var = your_entity.get_frame() 62 | ``` 63 | 64 | #### Drawing current frame 65 | To draw current frame, use this function 66 | ```python 67 | your_entity.draw_animation() 68 | ``` 69 | 70 | ## Animation system (Early stages) 71 | If you want to draw a animation, then you can do it this way 72 | 73 | ### Loading the animations 74 | To load the animation, run 75 | ```python 76 | my_anim = fusion.Animation(your_window, your_images: tuple, fps: int) 77 | ``` 78 | 79 | ### Drawing animation 80 | To draw it then, run: 81 | ```python 82 | my_anim.draw() 83 | ``` 84 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/storage.md: -------------------------------------------------------------------------------- 1 | # Storage system 2 | ## Init 3 | 4 | ```python 5 | my_db = fusion.JsonStorage("my_db.json") 6 | ``` 7 | This how you initialize your json storage system 8 | 9 | ## Insertion 10 | 11 | ```python 12 | my_db.insert({"first_name": "john", "last_name": "wick", "gold": 50}) 13 | my_db.insert({"first_name": "alexander", "last_name": "wick", "gold": 20}) 14 | ``` 15 | The code inserts two entries into the storage. The inserted data contains information about individuals' first names, last names, and gold amounts. 16 | 17 | ## Reading 18 | 19 | ```python 20 | Copy code 21 | my_db.search({"last_name": "wick"}) 22 | my_db.search({"last_name": "wick"}, get_index=True) 23 | ``` 24 | The code demonstrates reading operations. It searches for entries with the last name "wick" and retrieves results with and without index information. 25 | 26 | ## Updating 27 | 28 | ```python 29 | alex['gold'] += 20 30 | my_db.update(alex_index, alex) 31 | ``` 32 | The code showcases how to update data in the storage. In this case, it increases the "gold" value for an entry with the first name "alexander" by 20. 33 | 34 | ## Deleting 35 | 36 | ```python 37 | my_db.delete(john_index) 38 | ``` 39 | The code demonstrates deletion of data by removing an entry with the first name "john" from the storage. 40 | 41 | ## Saving to Disk 42 | ```python 43 | my_db.save() 44 | ``` 45 | The code shows how to save the modified data back to the storage file on disk. 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/ui.md: -------------------------------------------------------------------------------- 1 | # User Interface (UI) 2 | 3 | Creating a small ui for your application/game is easy with our following tools: 4 | 5 | ## Buttons 6 | 7 | To create a simple button we do the following: 8 | 9 | ```python 10 | 11 | # Create the button outside the loop 12 | your_button = fusion.Button( 13 | fusion.Rect(200, 200, 200, 200), 14 | "Hello World" 15 | ) 16 | 17 | ``` 18 | 19 | ### Button clicked 20 | 21 | If you want to check if your button was pressed or is being pressed, then you do that this way: 22 | 23 | ```python 24 | @main.window.loop 25 | def loop(): 26 | if your_button.button_pressed(): 27 | ... # Do your stuff 28 | ``` 29 | 30 | 31 | ## Rendering text 32 | If you want to render some fonts, then you can do it like this: 33 | 34 | - Option 1: Render text with build into fusion or your own font 35 | ```python 36 | # x y font size color 37 | fusion.Text(window, "Your text", 10, 10, fusion.NUNITO_LIGHT, 20, fusion.WHITE) 38 | ``` 39 | 40 | - Option 2: Render text with system font 41 | Its the same option 1, but you change the font to name of the font, like this: 42 | ```python 43 | fusion.Text(window, "Your text", 10, 10, "Arial", 20, main.color.WHITE) 44 | ``` 45 | 46 | -------------------------------------------------------------------------------- /docs/legacy/v4/wiki/window.md: -------------------------------------------------------------------------------- 1 | # Main Wiki 2 | 3 | ## Create window 4 | 5 | To create a window were thing are draw, then you need to use this: 6 | 7 | ```python 8 | your_window = fusion.Window("Example", 800, 600) 9 | ``` 10 | 11 | ## Start loop 12 | 13 | In a loop you can draw things and it will run with the FPS that is setup. To start a loop, you have two choices: 14 | 15 | Choice 1: 16 | 17 | ```python 18 | @your_window.loop 19 | def loop(): 20 | ... # Your own loop things 21 | ``` 22 | 23 | Choice 2: 24 | 25 | ```python 26 | while your_window.running(): 27 | ... # Your own loop thing 28 | 29 | ``` 30 | 31 | There is basically no difference, they all are doing the same thing, you use what you prefer. In our examples we use choice 1. 32 | 33 | 34 | ## Set FPS 35 | To set the framerate of your window, you use this: 36 | 37 | ```python 38 | your_window.set_fps(60) 39 | 40 | ``` 41 | 42 | ## Window icon 43 | So you want to change the icon of your window? Well, its easy: 44 | 45 | ```python 46 | your_window.change_icon("path_to_icon.png") 47 | ``` 48 | 49 | ## DeltaTime 50 | 51 | if you want to access delta time, you use this: 52 | 53 | ```python 54 | your_window.DELTATIME 55 | ``` 56 | 57 | ## Quit 58 | 59 | The quitting of the engine is done automaticly for you, so you dont have to worry about it. 60 | 61 | ### Force to quit 62 | If you want to force quit due to some reason, its pretty easy: 63 | ```python 64 | your_window.force_quit() 65 | ``` 66 | -------------------------------------------------------------------------------- /docs/tutorials/basics.md: -------------------------------------------------------------------------------- 1 | 2 | # Basic rendering tutorial 3 | 4 | ## Introduction 5 | This is a tutorial so you would understand the basics of the engine and how it works. In this tutorial we will learn how to render a window and draw some images on it. If you want to learn more, then go to [our docs](https://docs.fusion-engine.tech) and select wiki. 6 | 7 | This tutorial also expect you to have everything setup, if not, head over to [tutorial 1: setting everything up](setup.md) 8 | 9 | The Final Product Should Look like This: 10 | 11 | logo 12 | 13 | ## Creating a window 14 | 15 | So if you read tutorial 1 you know we have the main variable running our engine object. So now we create a window with the help of that main object: 16 | ```python 17 | window = fusion.Window("Tutorial 2", 600, 600) 18 | ``` 19 | The first argument that we give our function is our title, second argument is our width and third one is height 20 | 21 | ## Pre-loading image 22 | We will now pre-load a image so we can draw it later on our window. We do it like this: 23 | ```python 24 | image = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600) 25 | ``` 26 | Fist argument is our window, second is our image path, third is our x position, fourth is our y position, fifth is our width and sixth is our height. As you maybe see were using fusion.DEBUGIMAGE, which is a build in image into our engine for testing purposes. We will use it for our tutorial 27 | 28 | ## Starting a loop 29 | A loop is basicly what lets our window be open the whole time and not be automaticly closed. You also run there functions that need to ran every frame. So we start a loop like this: 30 | ```python 31 | @window.loop 32 | def loop(): 33 | ... # Code goes here 34 | 35 | ``` 36 | 37 | ## Drawing image 38 | So we still need to draw our image after loading it, and you can do that easily inside a loop like this: 39 | ```python 40 | @window.loop 41 | def loop(): 42 | image.draw() 43 | 44 | ``` 45 | As you see we have a draw function in our loop with the image loaded image as base (object). 46 | 47 | ## Full code 48 | Here is our full code that we could through this tutorial: 49 | ```python 50 | import fusionengine as fusion 51 | 52 | window = fusion.Window("Example: 1", 600, 600) 53 | image = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600) 54 | 55 | 56 | @window.loop 57 | def loop(): 58 | image.draw() 59 | 60 | ``` 61 | 62 | ## Ending 63 | This was our basic tutorial to images. There are (or will be) more tutorials, so check them our. Or otherwise you could check our [docs]() for more information. Happy coding! 64 | 65 | -------------------------------------------------------------------------------- /docs/tutorials/character.md: -------------------------------------------------------------------------------- 1 | # Basic Moving Character Tutorial 2 | This is a tutorial how to build a basic moving character using fusion-engine. We wil be using the new Node system introduced in V5.2 to make everything easier. 3 | We are going to make a small moving character. The character is gonna be a node with the fusion icon as image. 4 | 5 | ## Setting up 6 | First, make sure you have the latest version of Fusion installed (V5.2 and later). Without this it won't work, as we will be using a feature introduced in that version. 7 | If you want have fusion yet setup, then go back to [the setup tutorial](setup.md) 8 | 9 | ## Basic things 10 | First, lets get the basic things setup, like a window and a loop. 11 | 12 | First, we import `fusionengine` as `fusion`: 13 | ```python 14 | import fusionengine as fusion 15 | ``` 16 | 17 | Then we create a window where all drawing will take place: 18 | ```python 19 | window = fusion.Window("Basic Character - Fusion Engine", 800, 600) 20 | ``` 21 | 22 | After the window is done, we can create the loop: 23 | ```python 24 | @window.loop 25 | def loop(): 26 | ... # Our code is gonna go here 27 | ``` 28 | Thats it! We have a basic window and loop setup! 29 | 30 | ## Getting the Node setup 31 | 32 | -------------------------------------------------------------------------------- /docs/tutorials/setup.md: -------------------------------------------------------------------------------- 1 | 2 | # Setting everything up 3 | 4 | ## Introduction 5 | Welcome to our fusion-engine tutorials! Here you can learn about our engine and how to use it! This will go easy over everything you need to know to start programming with fusion! 6 | 7 | So this tutorial is made to setup everything, so you can start programming with fusion-engine! But if you already have everything setup then head over to [tutorial 2: basic rendering](basics.md) 8 | 9 | ## Installing 10 | So firstly we need to install fusion-engine. We have our package hoster at pypi so you can easly install it by running: 11 | ```bash 12 | pip install fusion-engine 13 | ``` 14 | 15 | ## Importing 16 | Now we need to import fusion-engine to our project. We do it like this: 17 | ```python 18 | import fusionengine as fusion 19 | ``` 20 | 21 | ## Ending 22 | That was it, our engine is now setup! Now every function works from our main variable, as you might see later. 23 | -------------------------------------------------------------------------------- /docs/wiki/animation.md: -------------------------------------------------------------------------------- 1 | # Animations and Spritesheets 2 | 3 | ## Animation system (Early stages) 4 | If you want to draw a animation, then you can do it this way 5 | 6 | ### Loading the animations 7 | To load the animation, run 8 | ```python 9 | my_anim = fusion.Animation(your_window: Window, your_images: tuple | Spritesheet, frames: int) 10 | ``` 11 | 12 | ### Drawing animation 13 | To draw it then, run: 14 | ```python 15 | my_anim.draw() 16 | ``` 17 | The frames specify the number of frames to draw each time. It can be as low as you like, or as high as you like, depending on the speed of the animation that you want. 18 | 19 | ## Spritesheets 20 | ### Creating spritesheets 21 | First, create your spritesheet. You can do it this way: 22 | ```python 23 | spr = fusion.SpriteSheet(fusion.DEBUGIMAGE, 100, 100) 24 | ``` 25 | This will cut down your spritesheet in 100x100 pixels images. Then it will be places inside `spr.frames` as `Image` objects. The images are cut from corner up-left to up-right. Then it goes a row lower and cuts futher. 26 | 27 | Then, set the size of each image and then set the coordinates. (This is required or else they will be automatically set to 0) 28 | Set the size: 29 | ```python 30 | spr.frame_size(60, 60) 31 | ``` 32 | 33 | This will set the size of each image 60x60 pixels. 34 | Then, set the coordinates: 35 | ```python 36 | spr.frame_pos(50, 50) 37 | ``` 38 | This will set the X-axis and Y-axis to 50. 39 | -------------------------------------------------------------------------------- /docs/wiki/color.md: -------------------------------------------------------------------------------- 1 | ## Using colors 2 | Our engine has some build in predefined colors so it's a bit easier for you with colors, to acess the colors you run: 3 | ```python 4 | fusion.WHITE 5 | ``` 6 | ## All colors 7 | The color name is always capitalised as per [PEP 8 → Constants](https://peps.python.org/pep-0008/#constants). All colors are defined and named (with capitalised form) as per [Sublime Text → Docs → Color Schemes → Appendix - CSS Colors](https://www.sublimetext.com/docs/color_schemes.html#appendix-css-colors). 8 | 9 | ## Custom color 10 | If you want your own color, you just give your function a Color object as argument with RGBA colors, here is an example: 11 | ```python 12 | fusion.draw_rect(100, 100, 400, 400, fusion.Color(255, 255, 255, 255)) 13 | ``` 14 | 15 | ## Hex to rgba 16 | If you have a hex color and want to convert it to rgba you can use this function: 17 | ```python 18 | fusion.hex_to_rgba(hex) 19 | ``` 20 | 21 | ## HSV to RGB 22 | If you have a HSV color and want to convert it to RGB you can use this function: 23 | ```python 24 | fusion.hsv_to_rgb(h, s, v) 25 | ``` 26 | hsv_to_rgb(hue, sat, val, alpha) -> Color -------------------------------------------------------------------------------- /docs/wiki/events-keys.md: -------------------------------------------------------------------------------- 1 | # Events and keys 2 | 3 | ## Keyboard input 4 | ## Get mouse position 5 | If you need to get the mouse position within the window, you can use a function like this: 6 | ```python 7 | mouse_x, mouse_y = fusion.get_mouse_pos() 8 | ``` 9 | 10 | ### Keydown 11 | 12 | if you need keyboard input, then use this if statement with your own key (see key tab for all key names): 13 | 14 | ```python 15 | if fusion.key_down(fusion.KEY_A): 16 | print("Key A pressed") 17 | ``` 18 | 19 | Or you can do it this way: 20 | ```python 21 | if fusion.Key(fusion.KEY_A).key_down(): 22 | print("Key A pressed") 23 | ``` 24 | 25 | ### Keydown once 26 | 27 | If you need keydown to be only once, then you use this: 28 | ```python 29 | if fusion.key_down_once(fusion.KEY_A): 30 | print("Key A pressed") 31 | 32 | ``` 33 | 34 | Or you can do it this way: 35 | ```python 36 | if fusion.Key(fusion.KEY_A).key_down_once(): 37 | print("Key A pressed") 38 | ``` 39 | 40 | 41 | 42 | ## Keys 43 | We use Pygame for this, here are our key bindings to the sdl2 keys: 44 | ```python 45 | KEY_UNKNOWN = pg.K_UNKNOWN 46 | KEY_RETURN = pg.K_RETURN 47 | KEY_ESCAPE = pg.K_ESCAPE 48 | KEY_BACKSPACE = pg.K_BACKSPACE 49 | KEY_TAB = pg.K_TAB 50 | KEY_SPACE = pg.K_SPACE 51 | KEY_EXCLAIM = pg.K_EXCLAIM 52 | KEY_QUOTEDBL = pg.K_QUOTEDBL 53 | KEY_HASH = pg.K_HASH 54 | KEY_PERCENT = pg.K_PERCENT 55 | KEY_DOLLAR = pg.K_DOLLAR 56 | KEY_AMPERSAND = pg.K_AMPERSAND 57 | KEY_QUOTE = pg.K_QUOTE 58 | KEY_LEFTPAREN = pg.K_LEFTPAREN 59 | KEY_RIGHTPAREN = pg.K_RIGHTPAREN 60 | KEY_ASTERISK = pg.K_ASTERISK 61 | KEY_PLUS = pg.K_PLUS 62 | KEY_COMMA = pg.K_COMMA 63 | KEY_MINUS = pg.K_MINUS 64 | KEY_PERIOD = pg.K_PERIOD 65 | KEY_SLASH = pg.K_SLASH 66 | 67 | KEY_0 = pg.K_0 68 | KEY_1 = pg.K_1 69 | KEY_2 = pg.K_2 70 | KEY_3 = pg.K_3 71 | KEY_4 = pg.K_4 72 | KEY_5 = pg.K_5 73 | KEY_6 = pg.K_6 74 | KEY_7 = pg.K_7 75 | KEY_8 = pg.K_8 76 | KEY_9 = pg.K_9 77 | 78 | KEY_COLON = pg.K_COLON 79 | KEY_SEMICOLON = pg.K_SEMICOLON 80 | KEY_LESS = pg.K_LESS 81 | KEY_EQUALS = pg.K_EQUALS 82 | KEY_GREATER = pg.K_GREATER 83 | KEY_QUESTION = pg.K_QUESTION 84 | KEY_AT = pg.K_AT 85 | KEY_LEFTBRACKET = pg.K_LEFTBRACKET 86 | KEY_BACKSLASH = pg.K_BACKSLASH 87 | KEY_RIGHTBRACKET = pg.K_RIGHTBRACKET 88 | KEY_CARET = pg.K_CARET 89 | KEY_UNDERSCORE = pg.K_UNDERSCORE 90 | KEY_BACKQUOTE = pg.K_BACKQUOTE 91 | 92 | KEY_a = pg.K_a 93 | KEY_b = pg.K_b 94 | KEY_c = pg.K_c 95 | KEY_d = pg.K_d 96 | KEY_e = pg.K_e 97 | KEY_f = pg.K_f 98 | KEY_g = pg.K_g 99 | KEY_h = pg.K_h 100 | KEY_i = pg.K_i 101 | KEY_j = pg.K_j 102 | KEY_k = pg.K_k 103 | KEY_l = pg.K_l 104 | KEY_m = pg.K_m 105 | KEY_n = pg.K_n 106 | KEY_o = pg.K_o 107 | KEY_p = pg.K_p 108 | KEY_q = pg.K_q 109 | KEY_r = pg.K_r 110 | KEY_s = pg.K_s 111 | KEY_t = pg.K_t 112 | KEY_u = pg.K_u 113 | KEY_v = pg.K_v 114 | KEY_w = pg.K_w 115 | KEY_x = pg.K_x 116 | KEY_y = pg.K_y 117 | KEY_z = pg.K_z 118 | 119 | KEY_A = pg.K_a 120 | KEY_B = pg.K_b 121 | KEY_C = pg.K_c 122 | KEY_D = pg.K_d 123 | KEY_E = pg.K_e 124 | KEY_F = pg.K_f 125 | KEY_G = pg.K_g 126 | KEY_H = pg.K_h 127 | KEY_I = pg.K_i 128 | KEY_J = pg.K_j 129 | KEY_K = pg.K_k 130 | KEY_L = pg.K_l 131 | KEY_M = pg.K_m 132 | KEY_N = pg.K_n 133 | KEY_O = pg.K_o 134 | KEY_P = pg.K_p 135 | KEY_Q = pg.K_q 136 | KEY_R = pg.K_r 137 | KEY_S = pg.K_s 138 | KEY_T = pg.K_t 139 | KEY_U = pg.K_u 140 | KEY_V = pg.K_v 141 | KEY_W = pg.K_w 142 | KEY_X = pg.K_x 143 | KEY_Y = pg.K_y 144 | KEY_Z = pg.K_z 145 | 146 | KEY_CAPSLOCK = pg.K_CAPSLOCK 147 | 148 | KEY_F1 = pg.K_F1 149 | KEY_F2 = pg.K_F2 150 | KEY_F3 = pg.K_F3 151 | KEY_F4 = pg.K_F4 152 | KEY_F5 = pg.K_F5 153 | KEY_F6 = pg.K_F6 154 | KEY_F7 = pg.K_F7 155 | KEY_F8 = pg.K_F8 156 | KEY_F9 = pg.K_F9 157 | KEY_F10 = pg.K_F10 158 | KEY_F11 = pg.K_F11 159 | KEY_F12 = pg.K_F12 160 | KEY_F13 = pg.K_F13 161 | KEY_F14 = pg.K_F14 162 | KEY_F15 = pg.K_F15 163 | 164 | KEY_PRINTSCREEN = pg.K_PRINT 165 | KEY_SCROLLLOCK = pg.K_SCROLLLOCK 166 | KEY_PAUSE = pg.K_PAUSE 167 | KEY_INSERT = pg.K_INSERT 168 | KEY_HOME = pg.K_HOME 169 | KEY_PAGEUP = pg.K_PAGEUP 170 | KEY_DELETE = pg.K_DELETE 171 | KEY_END = pg.K_END 172 | KEY_PAGEDOWN = pg.K_PAGEDOWN 173 | KEY_RIGHT = pg.K_RIGHT 174 | KEY_LEFT = pg.K_LEFT 175 | KEY_DOWN = pg.K_DOWN 176 | KEY_UP = pg.K_UP 177 | KEY_NUMLOCKCLEAR = pg.K_NUMLOCK 178 | KEY_KP_DIVIDE = pg.K_KP_DIVIDE 179 | KEY_KP_MULTIPLY = pg.K_KP_MULTIPLY 180 | KEY_KP_MINUS = pg.K_KP_MINUS 181 | KEY_KP_PLUS = pg.K_KP_PLUS 182 | KEY_KP_ENTER = pg.K_KP_ENTER 183 | 184 | KEY_KP_1 = pg.K_KP1 185 | KEY_KP_2 = pg.K_KP2 186 | KEY_KP_3 = pg.K_KP3 187 | KEY_KP_4 = pg.K_KP4 188 | KEY_KP_5 = pg.K_KP5 189 | KEY_KP_6 = pg.K_KP6 190 | KEY_KP_7 = pg.K_KP7 191 | KEY_KP_8 = pg.K_KP8 192 | KEY_KP_9 = pg.K_KP9 193 | KEY_KP_0 = pg.K_KP0 194 | 195 | KEY_KP_PERIOD = pg.K_KP_PERIOD 196 | KEY_POWER = pg.K_POWER 197 | KEY_KP_EQUALS = pg.K_KP_EQUALS 198 | KEY_HELP = pg.K_HELP 199 | KEY_MENU = pg.K_MENU 200 | KEY_SYSREQ = pg.K_SYSREQ 201 | KEY_CLEAR = pg.K_CLEAR 202 | KEY_CURRENCYUNIT = pg.K_CURRENCYUNIT 203 | KEY_CURRENCYSUBUNIT = pg.K_CURRENCYSUBUNIT 204 | KEY_LCTRL = pg.K_LCTRL 205 | KEY_LSHIFT = pg.K_LSHIFT 206 | KEY_LALT = pg.K_LALT 207 | KEY_LGUI = pg.K_LMETA 208 | KEY_RCTRL = pg.K_RCTRL 209 | KEY_RSHIFT = pg.K_RSHIFT 210 | KEY_RALT = pg.K_RALT 211 | KEY_RGUI = pg.K_RMETA 212 | KEY_MODE = pg.K_MODE 213 | KEY_AC_BACK = pg.K_AC_BACK 214 | ``` 215 | -------------------------------------------------------------------------------- /docs/wiki/external.md: -------------------------------------------------------------------------------- 1 | # External tools 2 | 3 | ## Using OpenGL 4 | Fusion is build on its own custom OpenGL binding using CTypes (FusionGL). If you want to use GL for yourself, you can try to use our own wrapper, but keep in mind that our own implementation only has the functions we need. Use it like this: `fusionengine.fusiongl` 5 | 6 | If you want to use PyOpenGL, you should be able to do that without any problems. 7 | 8 | ### Where to put code 9 | All the rendering code should be placed inside the while loop, and fusion should render it for you. Do not clear the screen as that will be automatically done for you. 10 | 11 | ### Warning 12 | This is not tested. It may not work or work as expected. If you find any bugs, please create a issue on github. Thank you. 13 | 14 | ## Using Codon Compiler 15 | So you heard of [codon](https://docs.exaloop.io/codon/), a python compiler with can compile your python code to machine code, which makes your code a lot faster But how do you use it? Well, its easy! You just install it and then modify these things in your code: 16 | 17 | Imports: 18 | ```python 19 | from python import fusionengine as fusion 20 | ``` 21 | 22 | Loop: 23 | You need to modify our loop to support codon, so you need to change it to this: 24 | ```python 25 | while your_window.running(): 26 | ... # Your own loop thing 27 | ``` 28 | You may reconise this type of while loop from the main wiki as your second option. 29 | -------------------------------------------------------------------------------- /docs/wiki/extra.md: -------------------------------------------------------------------------------- 1 | # Extra things 2 | 3 | ## Default message 4 | If you tried using our engine you may have encountered this message being printed to terminal: 5 | 6 | ```bash 7 | Fusion Engine 5.0.0 (FusionGL 1.0.0, Pygame-ce 2.4.0, Python 3.11.7) 8 | Welcome to Fusion Engine! Check out our website at https://fusion-engine.tech/ 9 | ``` 10 | 11 | To disable this behavior, you just give the main class when initting this argument, set your "FUSION_HIDE_PROMPT" enviorment variable to "no" or anything else. 12 | Or you can set the message variable to False: 13 | ```python 14 | import fusionengine as fusion 15 | 16 | fusion.message = False 17 | ``` 18 | 19 | ## GL support 20 | If you are using a OS that isn't officially being supported by Fusion and it still works, you can disable this warning: 21 | ```bash 22 | Your platform could not be resolved. Defaulting to OpenGL as GL. Rever to the documentation to learn about how to remove this warning. 23 | ``` 24 | To disable this behavior, you just give the main class when initting this argument, set your "FUSION_HIDE_GL_PROMPT" enviorment variable to "no" or anything else. 25 | -------------------------------------------------------------------------------- /docs/wiki/math.md: -------------------------------------------------------------------------------- 1 | # Small math module 2 | ## Vectors 3 | ### Vector2d 4 | 5 | If you want to create a 2d vector that stores x and y, then you do this: 6 | 7 | ```python 8 | vector = fusion.Vector2D(10, 10) 9 | ``` 10 | This creates a vector with the x being 10 and the y also being 10. 11 | 12 | ### Vector3d 13 | if you want to create a 3d vector that stores x, y and z, then you do this: 14 | ```python 15 | vector = fusion.Vector3D(10, 10, 10) 16 | ``` 17 | This creates a 3d vector with the x, y and z being 10. 18 | 19 | ## Types of PI in Fusion Engine 20 | These are used for certain miscellaneous math things. 21 | 22 | Full version of pi (3.141592653589793238462643383279502884197): 23 | ```python 24 | fusion.PI 25 | ``` 26 | A slightly smaller version that python's math library uses (3.141592653589793): 27 | ```python 28 | fusion.SMALLERPI 29 | ``` 30 | An extremely shortened version of pi (3.14): 31 | ```python 32 | fusion.SMALLPI 33 | ``` 34 | 35 | This allows you to get the floor value of a number. 36 | ```python 37 | fusion.FLOOR(3.4) 38 | ``` 39 | ## Euler's Number 40 | You can read more about it [here.](https://en.wikipedia.org/wiki/E_(mathematical_constant)) 41 | ```python 42 | fusion.EULERNUMBER 43 | ``` 44 | -------------------------------------------------------------------------------- /docs/wiki/music.md: -------------------------------------------------------------------------------- 1 | ## Sound 2 | 3 | ### Load sound 4 | 5 | To load a sound you do this: 6 | 7 | ```python 8 | your_sound = fusion.Sound("path_to_sound") 9 | ``` 10 | 11 | ### Play sound 12 | 13 | To play your loaded sound you use this: 14 | 15 | ```python 16 | your_sound.play() 17 | ``` 18 | 19 | ### Stop sound 20 | To stop your playing sound you use this: 21 | ```python 22 | your_sound.stop() 23 | ``` 24 | 25 | ### Get volume 26 | To get the volume of your sound you use this: 27 | ```python 28 | your_sound.get_volume() 29 | ``` 30 | 31 | ### Set volume 32 | To set the volume of your sound you use this: 33 | ```python 34 | your_sound.set_volume(0.5) 35 | ``` 36 | 37 | ### Fadeout 38 | To fadeout your sound you use this: 39 | ```python 40 | your_sound.fadeout(1000) 41 | ``` 42 | 43 | 44 | ### Backround music 45 | To start playing background music you use this: 46 | ```python 47 | your_backgroundmusic = fusion.BackgroundMusic("path_to_sound") 48 | ``` 49 | 50 | #### Set background music volume 51 | To set the volume of your background music you use this: 52 | ```python 53 | your_backgroundmusic.set_volume(0.5) 54 | ``` 55 | -------------------------------------------------------------------------------- /docs/wiki/node.md: -------------------------------------------------------------------------------- 1 | # Node and Scenes 2 | 3 | ## Node 4 | If you want a player or an enemy or some moving object in your game, you can use an Node, thats an object that 5 | helps you manage things in your game: 6 | 7 | ```python 8 | # x y w h 9 | your_node = fusion.Node(window, 100, 100, 50, 50) 10 | ``` 11 | 12 | ### Get Cordinates 13 | If you want to get the cordinates, then there are a few ways to do it. 14 | 15 | #### As a tuple 16 | If you want to get the Cordinates as a tuple, then do the following: 17 | ```python 18 | my_cor = your_node.get_coord_tuple() 19 | ``` 20 | 21 | #### As a Vector2D 22 | If you want to get the Cordinates as a Vector2D, then do the following: 23 | ```python 24 | my_cor = your_node.get_coord_vec2() 25 | ``` 26 | 27 | ### Loading a Rect 28 | If you plan on having the main shape of your Node a rect, or just having a rect connected to the size and position of youe Node, 29 | then you can load the rect using this way: 30 | ```python 31 | your_node.load_rect(fusion.BLACK) 32 | ``` 33 | 34 | ### Loading an Image 35 | If you just want a static image on your Node or just a image on the size and position of your Node then use this. 36 | 37 | ```python 38 | your_node.load_image("image_path") 39 | ``` 40 | 41 | ### Animations with a Node 42 | Fusion has some build-in features into Node system to make animations more easy, here are some ways to use it. 43 | 44 | #### Animation object 45 | If you want to load a object of Animation, then you can do it like this: 46 | ```python 47 | your_node.load_animation(animation: Animation) 48 | ``` 49 | #### Load frames 50 | First of all, you need to load frames, and you can do this using this way: 51 | ```python 52 | your_node.load_animation(images: tuple) 53 | ``` 54 | 55 | #### Setting current frame 56 | You can set the current frame with this function 57 | ```python 58 | your_node.set_frame(frame: int) 59 | ``` 60 | 61 | #### Getting current frame 62 | To get the current frame, run: 63 | ```python 64 | my_frame_var = your_node.get_frame() 65 | ``` 66 | 67 | ### Drawing everything 68 | If you want to draw everything, in the same order as you loaded it, you can do that this way: 69 | ```python 70 | my_node.update() 71 | ``` 72 | 73 | ## Scene manager 74 | See in [this example](https://github.com/dimkauzh/fusion-engine/blob/main/examples/example4.py) how to use the scene manager. 75 | -------------------------------------------------------------------------------- /docs/wiki/rendering.md: -------------------------------------------------------------------------------- 1 | # Rendering 2 | ## Set Background color 3 | 4 | If you want to set a background color, you use this function before all draw functions: 5 | 6 | ```python 7 | fusion.set_background_color(fusion.WHITE) 8 | ``` 9 | 10 | 11 | ## Predefined shapes 12 | 13 | We have some predefined shapes that can be used and be drew on the screen. Here are some: 14 | 15 | Rectangle: 16 | 17 | ```python 18 | your_shape = fusion.Rect(x, y, width, height, color) 19 | ``` 20 | 21 | ### Drawing the shape 22 | To draw your shape, you use this: 23 | ```python 24 | your_shape.draw() 25 | ``` 26 | 27 | - More shapes will be coming soon 28 | 29 | 30 | ## Draw a line 31 | To draw a line, you use this: 32 | 33 | ```python 34 | # x1 y1 x2 y2 color 35 | fusion.draw_line(100, 100, 200, 200, fusion.BLUE) 36 | ``` 37 | 38 | ## Draw rectangle 39 | 40 | If you just want to draw a rectangle to test or to use it for your game/app, then you have 3 options: 41 | 42 | Option one: just draw a rectangle 43 | 44 | ```python 45 | # x y w h color 46 | fusion.draw_rect(window, 100, 100, 400, 400, fusion.BLUE) 47 | ``` 48 | 49 | Third option: Draw a rectangle of lines 50 | 51 | ```python 52 | # x y w h color 53 | fusion.draw_line_rect(window, 100, 100, 400, 400, fusion.BLUE) 54 | ``` 55 | 56 | 57 | ## Draw image 58 | 59 | You first need to create a variable with your image and image data: 60 | 61 | ```python 62 | your_image = fusion.Image(window, fusion.DEBUGIMAGE, 100, 100, 400, 400) 63 | ``` 64 | 65 | `fusion.DEBUGIMAGE` is an image that is included with the engine, so you can use it freely. You can pass your own image path or a Pygame image/surface. 66 | Then you need to render it (In the best situation this will happen in your loop): 67 | 68 | ```python 69 | your_image.draw() 70 | ``` 71 | 72 | -------------------------------------------------------------------------------- /docs/wiki/storage.md: -------------------------------------------------------------------------------- 1 | # Storage system 2 | ## Init 3 | 4 | ```python 5 | my_db = fusion.JsonStorage("my_db.json") 6 | ``` 7 | This how you initialize your json storage system 8 | 9 | ## Insertion 10 | 11 | ```python 12 | my_db.insert({"first_name": "john", "last_name": "wick", "gold": 50}) 13 | my_db.insert({"first_name": "alexander", "last_name": "wick", "gold": 20}) 14 | ``` 15 | The code inserts two entries into the storage. The inserted data contains information about individuals' first names, last names, and gold amounts. 16 | 17 | ## Reading 18 | 19 | ```python 20 | Copy code 21 | my_db.search({"last_name": "wick"}) 22 | my_db.search({"last_name": "wick"}, get_index=True) 23 | ``` 24 | The code demonstrates reading operations. It searches for entries with the last name "wick" and retrieves results with and without index information. 25 | 26 | ## Updating 27 | 28 | ```python 29 | alex['gold'] += 20 30 | my_db.update(alex_index, alex) 31 | ``` 32 | The code showcases how to update data in the storage. In this case, it increases the "gold" value for an entry with the first name "alexander" by 20. 33 | 34 | ## Deleting 35 | 36 | ```python 37 | my_db.delete(john_index) 38 | ``` 39 | The code demonstrates deletion of data by removing an entry with the first name "john" from the storage. 40 | 41 | ## Saving to Disk 42 | ```python 43 | my_db.save() 44 | ``` 45 | The code shows how to save the modified data back to the storage file on disk. 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/wiki/ui.md: -------------------------------------------------------------------------------- 1 | # User Interface (UI) 2 | 3 | Creating a small ui for your application/game is easy with our following tools: 4 | 5 | ## Buttons 6 | Creating simple buttons 7 | ### Normal button 8 | ```python 9 | # Create the button outside the loop. 10 | my_button = fusion.Button(window, 15, 15, 200, 200, 20, "Test") 11 | ``` 12 | ### Custom font button 13 | ```python 14 | # Create the button outside the loop. 15 | my_button = fusion.Button(15, 15, 200, 200, 20, "Test", "path/to/my_font.ttf") 16 | ``` 17 | 18 | ### Button clicked 19 | 20 | If you want to check if your button was pressed or is being pressed, then you do that this way: 21 | 22 | ```python 23 | @window.loop 24 | def loop(): 25 | if your_button.is_pressed(): 26 | ... # Do your stuff 27 | ``` 28 | 29 | 30 | ## Rendering text 31 | If you want to render some fonts, then you can do it like this: 32 | 33 | - Option 1: Render text with build into fusion or your own font 34 | ```python 35 | # x y font size color 36 | mytext = fusion.Text("Your text", 10, 10, fusion.DEBUGFONT, 20, fusion.WHITE) 37 | ``` 38 | 39 | - Option 2: Render text with system font 40 | Its the same option 1, but you change the font to name of the font, like this: 41 | ```python 42 | mytext = fusion.Text("Your text", 10, 10, "Arial", 20, fusion.WHITE) 43 | ``` 44 | 45 | And then you can render if inside your loop: 46 | ```python 47 | @window.loop 48 | def loop(): 49 | mytext.draw() 50 | ``` 51 | -------------------------------------------------------------------------------- /docs/wiki/v5-moving.md: -------------------------------------------------------------------------------- 1 | # Moving to v5 2 | If your moving to v5 from v4. then here is the things you might need to take care about for your application to support v5. 3 | 4 | ## Drawing functions 5 | All functions that draw something on the screen got rid of the first argument, aka your window. These function/classes include: 6 | 7 | Classes: 8 | ```python 9 | fusion.Image() 10 | fusion.Button() 11 | fusion.Text() 12 | ``` 13 | 14 | Functions: 15 | ```python 16 | fusion.draw_rect() 17 | fusion.draw_image() 18 | fusion.set_background_color() 19 | fusion.draw_line() 20 | fusion.draw_line_rect() 21 | fusion.draw_arbitrary_polygon_outline() 22 | fusion.set_pixel() 23 | ``` 24 | 25 | ## Custom colors 26 | If you used color that are not automatically specified in the api, but rather with a custom tuple, then you might need to migrate to the 27 | new way of colors in fusion engine. Here is the new way to handle colors in fusion v5: 28 | ```python 29 | fusion.Color(255, 255, 255, 255) 30 | ``` 31 | So instead of using a tuple, you use a object of Color class. This is appleid to all functions from before. 32 | 33 | ## Drawing text 34 | Normally if you used the text class, then you used it inside a loop. The new way is to load it ouside the loop and then render it inside the loop. Here is a example 35 | ```python 36 | my_text = fusion.Text("test", 10, 10, "Arial", 12, fusion.BLUE) 37 | 38 | @your_window.loop 39 | def loop(): 40 | my_text.draw() 41 | ``` 42 | 43 | ## Build-in fonts 44 | There are no build-in font anymore except the DEBUGFONT in fusion. This font is Nunito Light font, that you can use as you want. If not, you can always use your own font or the os build in font. 45 | 46 | ## draw_image_file 47 | This function has been renamed to draw_image. 48 | 49 | ## Removal of pygame-gui and some aspects of pygame-ce 50 | ### pygame-gui 51 | You can no longer use pygame-gui with fusion. Instead, you can use build in UI library 52 | ### pygame-ce 53 | You can no longer use your own drawing code in pygame-ce with fusion, as fusion moved to custom OpenGL bindings called FusionGL for rendering purposes. If you want to know how to use PyOpenGL with fusion, go to the external page of the wiki. 54 | 55 | ## Buttons 56 | Making button is now different than before. Now you don't pass a rect, instead you pass all of this: 57 | 58 | - Window 59 | - X 60 | - Y 61 | - Width 62 | - Height 63 | - Font_size 64 | - Text 65 | - Font (Optional, if not given then the default font will be used) 66 | 67 | So like this: 68 | ```python 69 | my_button = fusion.Button(15, 15, 200, 200, 20, "Test") 70 | ``` 71 | 72 | ### Drawing it 73 | Drawing the button is really easy, just like this: 74 | 75 | ```python 76 | @your_window.loop 77 | def loop(): 78 | my_button.draw() 79 | ``` 80 | 81 | ### Gettig if clicked 82 | If you want to get if a button is pressed, just do it this new way: 83 | ```python 84 | @window.loop 85 | def loop(): 86 | if your_button.is_pressed(): 87 | ... # Do your stuff 88 | ``` 89 | 90 | ## Force quit naming 91 | The force_quit() function inside the window class has been changed to quit() instead. It operates the same way as before. -------------------------------------------------------------------------------- /docs/wiki/window.md: -------------------------------------------------------------------------------- 1 | # Windowing 2 | 3 | ## Create window 4 | 5 | To create a window were thing are draw, then you need to use this: 6 | 7 | ```python 8 | your_window = fusion.Window("Example", 800, 600) 9 | ``` 10 | 11 | ## Start loop 12 | 13 | In a loop you can draw things and it will run with the FPS that is setup. To start a loop, you have two choices: 14 | 15 | Choice 1: 16 | 17 | ```python 18 | @your_window.loop 19 | def loop(): 20 | ... # Your own loop things 21 | ``` 22 | 23 | Choice 2: 24 | 25 | ```python 26 | while your_window.running(): 27 | ... # Your own loop thing 28 | 29 | ``` 30 | 31 | There is basically no difference, they all are doing the same thing, you use what you prefer. In our examples we use choice 1. 32 | 33 | 34 | ## Set FPS 35 | To set the framerate of your window, you use this: 36 | 37 | ```python 38 | your_window.set_fps(60) 39 | 40 | ``` 41 | 42 | ## Window icon 43 | So you want to change the icon of your window? Well, its easy: 44 | 45 | ```python 46 | your_window.change_icon("path_to_icon.png") 47 | ``` 48 | 49 | ## DeltaTime 50 | 51 | if you want to access delta time, you use this: 52 | 53 | ```python 54 | your_window.DELTATIME 55 | ``` 56 | 57 | ## Quit 58 | 59 | The quitting of the engine is done automaticly for you, so you dont have to worry about it. 60 | 61 | ### Force to quit 62 | If you want to force quit due to some reason, its pretty easy: 63 | ```python 64 | your_window.force_quit() 65 | ``` 66 | 67 | ## Full Screen 68 | If you want to know if the window is full screen then run the following command: 69 | ```python 70 | your_var = your_window.is_fullscreen() 71 | ``` 72 | 73 | If you want to toggle the fullscreen on your window then run the following command: 74 | ```python 75 | your_window.toggle_fullscreen() 76 | ``` 77 | 78 | ## Screen Safer 79 | If you want to know if screen safer is allowed on the current machine then run the following command: 80 | ```python 81 | your_var = your_window.get_screensafer_allowed() 82 | ``` 83 | 84 | If you want to toggle the screen safer allowed on the current machine then run the following command: 85 | ```python 86 | your_window.toggle_screensafer_allowed() 87 | ``` 88 | 89 | ## Vsync 90 | If you want to know if VSync in enabled on the current machine then run the following command: 91 | ```python 92 | my_var = your_window.get_vsync_enabled() 93 | ``` 94 | 95 | ## Displays 96 | ### Refresh rate 97 | If you want to get the display refresh rate on the current machine then run the following command: 98 | ```python 99 | my_var = your_window.get_screen_refresh_rate() 100 | ``` 101 | 102 | ## Display amount 103 | If you want to get the display amount on the current machine then run the following command: 104 | ```python 105 | my_var = your_window.get_display_amount() 106 | ``` 107 | 108 | ## Active 109 | If you want to get the active state on the current machine then run the following command: 110 | ```python 111 | my_var = your_window.get_active() 112 | ``` -------------------------------------------------------------------------------- /icon/fe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/icon/fe.png -------------------------------------------------------------------------------- /icon/fusion-banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/icon/fusion-banner.png -------------------------------------------------------------------------------- /icon/fusion-banner2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/icon/fusion-banner2.png -------------------------------------------------------------------------------- /mkdocs.yml: -------------------------------------------------------------------------------- 1 | site_name: Fusion Engine Documentation 2 | site_description: A custom open-source game engine on OpenGL and Python, it’s written in pure Python! It’s easy and fast! 3 | 4 | repo_name: fusionengine-org/fusion 5 | repo_url: https://github.com/fusionengine-org/fusion 6 | 7 | nav: 8 | - Home: 'index.md' 9 | 10 | - Getting Started: 'get-started.md' 11 | 12 | - Wiki: 13 | - Window with fusion: 'wiki/window.md' 14 | - Rendering with fusion: 'wiki/rendering.md' 15 | - Events and Keys: 'wiki/events-keys.md' 16 | - Color and colortools: 'wiki/color.md' 17 | - Managing sounds and music: 'wiki/music.md' 18 | - Nodes and Scenes: 'wiki/node.md' 19 | - Storage system: 'wiki/storage.md' 20 | - Animations and Spritesheets: 'wiki/animation.md' 21 | - UI module: 'wiki/ui.md' 22 | - Math and Vectors: 'wiki/math.md' 23 | - Extra stuff: 'wiki/extra.md' 24 | - External tools: 'wiki/external.md' 25 | - Moving from v4 to v5: 'wiki/v5-moving.md' 26 | 27 | - Tutorials: 28 | - Setting up Fusion Engine: 'tutorials/setup.md' 29 | - Basics of Fusion Engine: 'tutorials/basics.md' 30 | 31 | 32 | - Changelog: 33 | - V5: 'changelog/v5.md' 34 | - V4: 'changelog/v4.md' 35 | - V3: 'changelog/v3.md' 36 | 37 | - Legacy: 38 | - Start: 'legacy/index.md' 39 | - V3: 40 | - Wiki: 41 | - Main page: 'legacy/v3/wiki/wiki.md' 42 | - Keys page: 'legacy/v3/wiki/keys.md' 43 | - Color page: 'legacy/v3/wiki/color.md' 44 | - Math page: 'legacy/v3/wiki/math.md' 45 | - Fonts page: 'legacy/v3/wiki/fonts.md' 46 | - External page: 'legacy/v3/wiki/external.md' 47 | 48 | - Api: 49 | - Main page: 'legacy/v3/api/index.md' 50 | - API page: 'legacy/v3/api/api.md' 51 | - Color page: 'legacy/v3/api/color.md' 52 | - Keys page: 'legacy/v3/api/keys.md' 53 | - Fonts page: 'legacy/v3/api/fonts.md' 54 | - Math page: 'legacy/v3/api/math.md' 55 | 56 | 57 | - Tutorial: 58 | - Main page: 'legacy/v3/tutorials/index.md' 59 | - Setup: 'legacy/v3/tutorials/setup.md' 60 | - Basics: 'legacy/v3/tutorials/basics.md' 61 | 62 | - V4: 63 | - Wiki: 64 | - Window with fusion: 'legacy/v4/wiki/window.md' 65 | - Rendering with fusion: 'legacy/v4/wiki/rendering.md' 66 | - Events and Keys: 'legacy/v4/wiki/events-keys.md' 67 | - Color and colortools: 'legacy/v4/wiki/color.md' 68 | - Managing sounds and music: 'legacy/v4/wiki/music.md' 69 | - Scenes, entities and animations: 'legacy/v4/wiki/scene.md' 70 | - Storage system: 'legacy/v4/wiki/storage.md' 71 | - UI module: 'legacy/v4/wiki/ui.md' 72 | - Math and Vectors: 'legacy/v4/wiki/math.md' 73 | - Build in Fonts: 'legacy/v4/wiki/fonts.md' 74 | - Extra stuff: 'legacy/v4/wiki/extra.md' 75 | - External tools: 'legacy/v4/wiki/external.md' 76 | 77 | - Tutorial: 78 | - Setup: 'legacy/v4/tutorials/setup.md' 79 | - Basics: 'legacy/v4/tutorials/basics.md' 80 | 81 | - API: 82 | - Main Page: 'legacy/v4/api/index.md' 83 | - Api Page: 'legacy/v4/api/api.md' 84 | - Color Page: 'legacy/v4/api/color.md' 85 | - Keys Page: 'legacy/v4/api/keys.md' 86 | - Fonts Page: 'legacy/v4/api/fonts.md' 87 | 88 | 89 | 90 | theme: 91 | name: material 92 | 93 | logo: assets/logo/fe.png 94 | favicon: assets/logo/fe.png 95 | 96 | features: 97 | - navigation.path 98 | - navigation.tabs 99 | - navigation.tabs.sticky 100 | - navigation.top 101 | - toc.follow 102 | - navigation.expand 103 | 104 | - content.code.copy 105 | 106 | 107 | palette: 108 | - media: "(prefers-color-scheme)" 109 | toggle: 110 | icon: material/link 111 | name: Switch to light mode 112 | - media: "(prefers-color-scheme: light)" 113 | scheme: default 114 | primary: indigo 115 | accent: indigo 116 | toggle: 117 | icon: material/toggle-switch 118 | name: Switch to dark mode 119 | - media: "(prefers-color-scheme: dark)" 120 | scheme: slate 121 | primary: black 122 | accent: indigo 123 | toggle: 124 | icon: material/toggle-switch-off 125 | name: Switch to system preference 126 | 127 | markdown_extensions: 128 | - abbr 129 | - admonition 130 | - attr_list 131 | - def_list 132 | - footnotes 133 | - md_in_html 134 | - toc: 135 | permalink: true 136 | - pymdownx.arithmatex: 137 | generic: true 138 | - pymdownx.betterem: 139 | smart_enable: all 140 | - pymdownx.caret 141 | - pymdownx.details 142 | - pymdownx.highlight: 143 | anchor_linenums: true 144 | line_spans: __span 145 | pygments_lang_class: true 146 | - pymdownx.inlinehilite 147 | - pymdownx.keys 148 | - pymdownx.magiclink: 149 | normalize_issue_symbols: true 150 | repo_url_shorthand: true 151 | user: squidfunk 152 | repo: mkdocs-material 153 | - pymdownx.mark 154 | - pymdownx.smartsymbols 155 | - pymdownx.superfences: 156 | custom_fences: 157 | - name: mermaid 158 | class: mermaid 159 | format: !!python/name:pymdownx.superfences.fence_code_format 160 | - pymdownx.tasklist: 161 | custom_checkbox: true 162 | - pymdownx.tilde 163 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["pdm-backend"] 3 | build-backend = "pdm.backend" 4 | 5 | [project] 6 | name = "fusion-engine" 7 | dynamic = ["version"] 8 | description = "A custom open-source game engine on OpenGL and Python, it’s written in pure Python! It’s easy and fast!" 9 | requires-python = ">=3.8" 10 | readme = { file = "README.md", content-type = "text/markdown" } 11 | license = { text = "GNU GPLv3" } 12 | authors = [{ name = "Dimkauzh", email = "uzhdimka@gmail.com" }] 13 | keywords = [ 14 | "game", 15 | "python", 16 | "gamedev", 17 | "game-engine", 18 | "pygame", 19 | "game-development", 20 | "pure-python", 21 | "pygame-mixer", 22 | "pygame-ttf", 23 | "pygame-image", 24 | "python-game", 25 | "pygame-library", 26 | "python-game-library", 27 | "python-game-engine", 28 | "python-games", 29 | ] 30 | classifiers = [ 31 | "Development Status :: 5 - Production/Stable", 32 | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", 33 | "Natural Language :: English", 34 | "Operating System :: MacOS", 35 | "Operating System :: Microsoft :: Windows", 36 | "Operating System :: Unix", 37 | "Programming Language :: Python :: 3", 38 | "Programming Language :: Python :: 3 :: Only", 39 | "Programming Language :: Python :: 3.8", 40 | "Programming Language :: Python :: 3.9", 41 | "Programming Language :: Python :: 3.10", 42 | "Programming Language :: Python :: 3.11", 43 | "Programming Language :: Python :: 3.12", 44 | "Topic :: Games/Entertainment", 45 | "Topic :: Multimedia :: Graphics", 46 | "Topic :: Multimedia :: Video", 47 | ] 48 | dependencies = [ 49 | "pygame-ce>=2.4.0", 50 | ] 51 | 52 | [tool.pdm] 53 | distribution = true 54 | 55 | [tool.pdm.options] 56 | includes = ["**/*.png", "**/*.ttf"] 57 | 58 | [tool.pdm.build] 59 | package-dir = "src" 60 | 61 | [tool.pdm.version] 62 | source = "file" 63 | path = "src/fusionengine/__init__.py" 64 | 65 | [tool.pdm.dev-dependencies] 66 | lint = ["black", "mkdocs-material"] 67 | 68 | [tool.pdm.scripts] 69 | example1 = "python src/fusionengine/examples/example1.py" 70 | example2 = "python src/fusionengine/examples/example2.py" 71 | example3 = "python src/fusionengine/examples/example3.py" 72 | example4 = "python src/fusionengine/examples/example4.py" 73 | example5 = "python src/fusionengine/examples/example5.py" 74 | 75 | gltest = "python tests/gltest.py" 76 | 77 | docs = "mkdocs serve" 78 | 79 | lint = "black ." 80 | -------------------------------------------------------------------------------- /src/fusionengine/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = "Fusion Engine Team" 2 | __version__ = "5.2.0" 3 | 4 | import sys 5 | import os 6 | import warnings 7 | import platform 8 | 9 | os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide" 10 | 11 | # Core 12 | from fusionengine.engine.window import * 13 | from fusionengine.engine.image import * 14 | from fusionengine.engine.draw import * 15 | from fusionengine.engine.shape import * 16 | 17 | # Events 18 | from fusionengine.engine.event import * 19 | from fusionengine.engine.keys import * 20 | 21 | # Colors 22 | from fusionengine.engine.color import * 23 | 24 | # Entity 25 | from fusionengine.engine.entity import * 26 | 27 | # Node 28 | from fusionengine.engine.node import * 29 | 30 | # Storage 31 | from fusionengine.engine.storage import * 32 | 33 | # UI 34 | from fusionengine.engine.ui import * 35 | 36 | # Math 37 | from fusionengine.engine.vector import * 38 | from fusionengine.engine.math import * 39 | 40 | # Sound 41 | from fusionengine.engine.sound import * 42 | 43 | # Scene 44 | from fusionengine.engine.scene import * 45 | from fusionengine.engine.manager import * 46 | 47 | # Tools 48 | from fusionengine.engine.debug import * 49 | 50 | # Animation 51 | from fusionengine.engine.animation import * 52 | from fusionengine.engine.spritesheets import * 53 | 54 | # GL 55 | import fusionengine.fusiongl as gl 56 | 57 | import pygame as pg 58 | 59 | message = True 60 | 61 | if os.environ.get("FUSION_HIDE_PROMPT") is None or not message: 62 | python_version = sys.version.split()[0] 63 | print( 64 | f"Fusion Engine {__version__} (FusionGL {gl.__version__}, Pygame-ce {pg.version.ver}, Python {python_version})" 65 | ) 66 | print( 67 | "Welcome to Fusion Engine! Check out our website at https://fusion-engine.tech/" 68 | ) 69 | 70 | if platform.system().lower() == "linux": 71 | warnings.filterwarnings( 72 | "ignore", message="PyGame seems to be running through X11 on top of wayland" 73 | ) 74 | -------------------------------------------------------------------------------- /src/fusionengine/backend/deprecations.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import warnings 3 | from fusionengine import __version__ 4 | 5 | 6 | def compare_versions(version1: str, version2: str): 7 | components1 = list(map(int, version1.split("."))) 8 | components2 = list(map(int, version2.split("."))) 9 | 10 | for c1, c2 in zip(components1, components2): 11 | if c1 < c2: 12 | return -1 13 | elif c1 > c2: 14 | return 1 15 | 16 | return 0 17 | 18 | 19 | def deprecated(version=None, name=None): 20 | """ 21 | This is a decorator which can be used to mark functions 22 | as deprecated. It will result in a warning being emitted 23 | when the function is used. 24 | """ 25 | 26 | def decorator(func): 27 | @functools.wraps(func) 28 | def new_func(*args, **kwargs): 29 | if name is None: 30 | func_name = "function " + func.__name__ 31 | else: 32 | func_name = name 33 | 34 | if version is None or compare_versions(__version__, version) >= 0: 35 | warnings.simplefilter("always", DeprecationWarning) 36 | warnings.warn( 37 | f"Call to deprecated {func_name}.", 38 | category=DeprecationWarning, 39 | stacklevel=2, 40 | ) 41 | warnings.simplefilter("default", DeprecationWarning) 42 | return func(*args, **kwargs) 43 | 44 | return new_func 45 | 46 | return decorator 47 | -------------------------------------------------------------------------------- /src/fusionengine/engine/animation.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.window import Window 2 | from fusionengine.engine.spritesheets import SpriteSheet 3 | 4 | 5 | class Animation: 6 | def __init__( 7 | self, window: Window, images: tuple | SpriteSheet, speed: float 8 | ) -> None: 9 | """ 10 | The class to create an Animation. 11 | 12 | Args: 13 | window: Window 14 | image (Tuple | Spritesheets): Tuple of Images or a SpriteSheet 15 | Speed: Int (FPS) 16 | """ 17 | self.frame = 0 18 | self.prev_frame = 0 19 | self.speed = speed 20 | 21 | if isinstance(images, SpriteSheet): 22 | self.frames = images.frames 23 | elif isinstance(images, tuple): 24 | self.frames = images 25 | else: 26 | raise ValueError("Images must be a tuple of Images or a SpriteSheet") 27 | 28 | self.window = window 29 | 30 | def play(self) -> None: 31 | """ 32 | Draw the animation you made before 33 | """ 34 | if 0 <= int(self.frame) < len(self.frames): 35 | if not ( 36 | isinstance(self.frame, int) 37 | or (isinstance(self.frame, float) and self.frame.is_integer()) 38 | ): 39 | self.frames[int(self.prev_frame)].draw() 40 | else: 41 | self.frames[int(self.frame)].draw() 42 | 43 | self.prev_frame = self.frame 44 | self.frame += self.speed 45 | 46 | if self.frame >= len(self.frames): 47 | self.frame = 0 48 | -------------------------------------------------------------------------------- /src/fusionengine/engine/color.py: -------------------------------------------------------------------------------- 1 | class Color: 2 | def __init__(self, r: int, g: int, b: int, a: int) -> None: 3 | """ 4 | Creates a color object. 5 | 6 | Args: 7 | color (tuple[int, int, int, int]): The color in RGBA format 8 | """ 9 | self.tuple = (r, g, b, a) 10 | self.r = r 11 | self.g = g 12 | self.b = b 13 | self.a = a 14 | 15 | 16 | def hex_to_rgba(hex: str) -> Color: 17 | """ 18 | Converts (#)RRGGBB to Fusion Color. 19 | 20 | Args: 21 | hex (str): Your hex color 22 | 23 | Returns: 24 | Color: The Fusion Color 25 | """ 26 | 27 | hex6 = hex.replace("#", "") 28 | return Color(int(hex6[:2], 16), int(hex6[2:4], 16), int(hex6[4:6], 16), 255) 29 | 30 | 31 | def hsv_to_rgb(hue: float, sat: float, val: float, alpha: int) -> Color: 32 | """ 33 | Takes in HSV values and ouputs a Fusion Color 34 | 35 | Args: 36 | hue (float): Hue is from 0 to 360. 37 | sat (float): Saturation and value are from 0 to 1. 38 | val (float): Value is from 0 to 1. 39 | alpha (int): Alpha is from 0 to 255 (int). 40 | 41 | Returns: 42 | Color: RBGA format, that can be used in the engine 43 | """ 44 | 45 | hue_red = 0 46 | hue_green = 0 47 | hue_blue = 0 48 | 49 | if hue <= 60: 50 | hue_red = 255 51 | 52 | elif 60 <= hue <= 120: 53 | hue_red = 255 * ((-hue / 60) + 2) 54 | 55 | elif 120 <= hue <= 240: 56 | hue_red = 0 57 | 58 | elif 240 <= hue <= 300: 59 | hue_red = (hue / 60) - 4 60 | 61 | elif 300 <= hue <= 360: 62 | hue_red = 255 63 | 64 | if hue <= 60: 65 | hue_green = 255 * (hue / 60) 66 | 67 | elif 60 <= hue <= 180: 68 | hue_green = 255 69 | 70 | elif 180 <= hue <= 240: 71 | hue_green = 255 * ((-hue / 60) + 4) 72 | 73 | elif 240 <= hue <= 360: 74 | hue_green = 0 75 | 76 | if hue <= 120: 77 | hue_blue = 0 78 | 79 | elif 120 <= hue <= 180: 80 | hue_blue = 255 * ((hue / 60) - 2) 81 | 82 | elif 180 <= hue <= 300: 83 | hue_blue = 255 84 | 85 | elif 300 <= hue <= 360: 86 | hue_blue = 255 * ((-hue / 60) + 6) 87 | 88 | red = val * (sat * hue_red + (255 - 255 * sat)) 89 | green = val * (sat * hue_green + (255 - 255 * sat)) 90 | blue = val * (sat * hue_blue + (255 - 255 * sat)) 91 | 92 | return Color(int(red), int(green), int(blue), alpha) 93 | 94 | 95 | ALICEBLUE = Color(240, 248, 255, 255) 96 | ANTIQUEWHITE = Color(250, 235, 215, 255) 97 | AQUA = Color(0, 255, 255, 255) 98 | AQUAMARINE = Color(127, 255, 212, 255) 99 | AZURE = Color(240, 255, 255, 255) 100 | BEIGE = Color(245, 245, 220, 255) 101 | BISQUE = Color(255, 228, 196, 255) 102 | BLACK = Color(0, 0, 0, 255) 103 | BLANCHEDALMOND = Color(255, 235, 205, 255) 104 | BLUE = Color(0, 0, 255, 255) 105 | BLUEVIOLET = Color(138, 43, 226, 255) 106 | BROWN = Color(165, 42, 42, 255) 107 | BURLYWOOD = Color(222, 184, 135, 255) 108 | CADETBLUE = Color(95, 158, 160, 255) 109 | CHARTREUSE = Color(127, 255, 0, 255) 110 | CHOCOLATE = Color(210, 105, 30, 255) 111 | CORAL = Color(255, 127, 80, 255) 112 | CORNFLOWERBLUE = Color(100, 149, 237, 255) 113 | CORNSILK = Color(255, 248, 220, 255) 114 | CRIMSON = Color(220, 20, 60, 255) 115 | CYAN = Color(0, 255, 255, 255) 116 | DARKBLUE = Color(0, 0, 139, 255) 117 | DARKCYAN = Color(0, 139, 139, 255) 118 | DARKGOLDENROD = Color(184, 134, 11, 255) 119 | DARKGRAY = Color(169, 169, 169, 255) 120 | DARKGREEN = Color(0, 100, 0, 255) 121 | DARKKHAKI = Color(189, 183, 107, 255) 122 | DARKMAGENTA = Color(139, 0, 139, 255) 123 | DARKOLIVEGREEN = Color(85, 107, 47, 255) 124 | DARKORANGE = Color(255, 140, 0, 255) 125 | DARKORCHID = Color(153, 50, 204, 255) 126 | DARKRED = Color(139, 0, 0, 255) 127 | DARKSALMON = Color(233, 150, 122, 255) 128 | DARKSEAGREEN = Color(143, 188, 143, 255) 129 | DARKSLATEBLUE = Color(72, 61, 139, 255) 130 | DARKSLATEGRAY = Color(47, 79, 79, 255) 131 | DARKTURQUOISE = Color(0, 206, 209, 255) 132 | DARKVIOLET = Color(148, 0, 211, 255) 133 | DEEPPINK = Color(255, 20, 147, 255) 134 | DEEPSKYBLUE = Color(0, 191, 255, 255) 135 | DIMGRAY = Color(105, 105, 105, 255) 136 | DODGERBLUE = Color(30, 144, 255, 255) 137 | FIREBRICK = Color(178, 34, 34, 255) 138 | FLORALWHITE = Color(255, 250, 240, 255) 139 | FORESTGREEN = Color(34, 139, 34, 255) 140 | FUCHSIA = Color(255, 0, 255, 255) 141 | GAINSBORO = Color(220, 220, 220, 255) 142 | GHOSTWHITE = Color(248, 248, 255, 255) 143 | GOLD = Color(255, 215, 0, 255) 144 | GOLDENROD = Color(218, 165, 32, 255) 145 | GRAY = Color(128, 128, 128, 255) 146 | GREEN = Color(0, 128, 0, 255) 147 | GREENYELLOW = Color(173, 255, 47, 255) 148 | HONEYDEW = Color(240, 255, 240, 255) 149 | HOTPINK = Color(255, 105, 180, 255) 150 | INDIANRED = Color(205, 92, 92, 255) 151 | INDIGO = Color(75, 0, 130, 255) 152 | IVORY = Color(255, 255, 240, 255) 153 | KHAKI = Color(240, 230, 140, 255) 154 | LAVENDER = Color(230, 230, 250, 255) 155 | LAVENDERBLUSH = Color(255, 240, 245, 255) 156 | LAWNGREEN = Color(124, 252, 0, 255) 157 | LEMONCHIFFON = Color(255, 250, 205, 255) 158 | LIGHTBLUE = Color(173, 216, 230, 255) 159 | LIGHTCORAL = Color(240, 128, 128, 255) 160 | LIGHTCYAN = Color(224, 255, 255, 255) 161 | LIGHTGOLDENRODYELLOW = Color(250, 250, 210, 255) 162 | LIGHTGRAY = Color(211, 211, 211, 255) 163 | LIGHTGREEN = Color(144, 238, 144, 255) 164 | LIGHTSALMON = Color(255, 182, 193, 255) 165 | LIGHTSEAGREEN = Color(32, 178, 170, 255) 166 | LIGHTSKYBLUE = Color(135, 206, 250, 255) 167 | LIGHTSLATEGRAY = Color(119, 136, 153, 255) 168 | LIGHTSTEELBLUE = Color(176, 196, 222, 255) 169 | LIGHTYELLOW = Color(255, 255, 224, 255) 170 | LIME = Color(0, 255, 0, 255) 171 | LIMEGREEN = Color(50, 205, 50, 255) 172 | LINEN = Color(250, 240, 230, 255) 173 | MAGENTA = Color(255, 0, 255, 255) 174 | MAROON = Color(128, 0, 0, 255) 175 | MEDIUMAQUAMARINE = Color(102, 205, 170, 255) 176 | MEDIUMBLUE = Color(0, 0, 205, 255) 177 | MEDIUMORCHID = Color(186, 85, 211, 255) 178 | MEDIUMPURPLE = Color(147, 112, 219, 255) 179 | MEDIUMSEAGREEN = Color(60, 179, 113, 255) 180 | MEDIUMSLATEBLUE = Color(123, 104, 238, 255) 181 | MEDIUMSPRINGGREEN = Color(0, 250, 154, 255) 182 | MEDIUMTURQUOISE = Color(72, 209, 204, 255) 183 | MEDIUMVIOLETRED = Color(199, 21, 133, 255) 184 | MIDNIGHTBLUE = Color(25, 25, 112, 255) 185 | MINTCREAM = Color(245, 255, 250, 255) 186 | MISTYROSE = Color(255, 228, 225, 255) 187 | MOCCASIN = Color(255, 228, 181, 255) 188 | NAVAJOWHITE = Color(255, 222, 173, 255) 189 | NAVY = Color(0, 0, 128, 255) 190 | OLDLACE = Color(253, 245, 230, 255) 191 | OLIVE = Color(128, 128, 0, 255) 192 | OLIVEDRAB = Color(107, 142, 35, 255) 193 | ORANGE = Color(255, 165, 0, 255) 194 | ORANGERED = Color(255, 69, 0, 255) 195 | ORCHID = Color(218, 112, 214, 255) 196 | PALEGOLDENROD = Color(238, 232, 170, 255) 197 | PALEGREEN = Color(152, 251, 152, 255) 198 | PALETURQUOISE = Color(175, 238, 238, 255) 199 | PALEVIOLETRED = Color(219, 112, 147, 255) 200 | PAPAYAWHIP = Color(255, 239, 213, 255) 201 | PEACHPUFF = Color(255, 218, 185, 255) 202 | PERU = Color(205, 133, 63, 255) 203 | PINK = Color(255, 192, 203, 255) 204 | PLUM = Color(221, 160, 221, 255) 205 | POWDERBLUE = Color(176, 224, 230, 255) 206 | PURPLE = Color(128, 0, 128, 255) 207 | REBECCAPURPLE = Color(102, 51, 153, 255) 208 | RED = Color(255, 0, 0, 255) 209 | ROSYBROWN = Color(188, 143, 143, 255) 210 | ROYALBLUE = Color(65, 105, 225, 255) 211 | SADDLEBROWN = Color(139, 69, 19, 255) 212 | SALMON = Color(250, 128, 114, 255) 213 | SANDYBROWN = Color(244, 164, 96, 255) 214 | SEAGREEN = Color(46, 139, 87, 255) 215 | SEASHELL = Color(255, 245, 238, 255) 216 | SIENNA = Color(160, 82, 45, 255) 217 | SILVER = Color(192, 192, 192, 255) 218 | SKYBLUE = Color(135, 206, 235, 255) 219 | SLATEBLUE = Color(106, 90, 205, 255) 220 | SLATEGRAY = Color(112, 128, 144, 255) 221 | SNOW = Color(255, 250, 250, 255) 222 | SPRINGGREEN = Color(0, 255, 127, 255) 223 | STEELBLUE = Color(70, 130, 180, 255) 224 | TAN = Color(210, 180, 140, 255) 225 | TEAL = Color(0, 128, 128, 255) 226 | THISTLE = Color(216, 191, 216, 255) 227 | TOMATO = Color(255, 99, 71, 255) 228 | TURQUOISE = Color(64, 224, 208, 255) 229 | VIOLET = Color(238, 130, 238, 255) 230 | WHEAT = Color(245, 222, 179, 255) 231 | WHITE = Color(255, 255, 255, 255) 232 | WHITESMOKE = Color(245, 245, 245, 255) 233 | YELLOW = Color(255, 255, 0, 255) 234 | YELLOWGREEN = Color(154, 205, 50, 255) 235 | -------------------------------------------------------------------------------- /src/fusionengine/engine/debug.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | 4 | DEBUGIMAGE = f"{list(fusion.__path__)[0]}/external/fe.png" 5 | DEBUGFONT = f"{list(fusion.__path__)[0]}/external/font.ttf" 6 | -------------------------------------------------------------------------------- /src/fusionengine/engine/draw.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.window import Window 2 | from fusionengine.engine.color import Color 3 | import fusionengine.fusiongl as gl 4 | 5 | import pygame as pg 6 | 7 | 8 | def draw_line(x1: int, y1: int, x2: int, y2: int, color: Color) -> None: 9 | """ 10 | Draw a line on the screen 11 | 12 | Args: 13 | x1 (int): The x position of the first point 14 | y1 (int): The y position of the first point 15 | x2 (int): The x position of the second point 16 | y2 (int): The y position of the second point 17 | color (Color): The color of the line 18 | """ 19 | 20 | gl.LineWidth(1) 21 | 22 | gl.Begin(gl.LINES) 23 | 24 | gl.Color4f(color.r, color.g, color.b, color.a) 25 | gl.Vertex2f(x1, y1) 26 | gl.Vertex2f(x2, y2) 27 | 28 | gl.End() 29 | 30 | 31 | def draw_line_rect( 32 | x: int, 33 | y: int, 34 | width: int, 35 | height: int, 36 | color: Color, 37 | ) -> None: 38 | """ 39 | Draws a rectangle that exists of lines on the screen. 40 | 41 | Args: 42 | x (int): x coordinate of the rectangle 43 | y (int): Y coordinate of the rectangle 44 | width (int): Width of the rectangle 45 | height (int): Height of the rectangle 46 | color (Color): Color of the rectangle 47 | """ 48 | draw_line(x, y, x + width, y, color) 49 | draw_line(x, y + height, x + width, y + height, color) 50 | draw_line(x, y, x, y + height, color) 51 | draw_line(x + width, y, x + width, y + height, color) 52 | 53 | 54 | def draw_rect( 55 | x: int, 56 | y: int, 57 | width: int, 58 | height: int, 59 | color: Color, 60 | ) -> None: 61 | """ 62 | Draws a rectangle on the screen. 63 | 64 | Args: 65 | x (int): x coordinate of the rectangle 66 | y (int): Y coordinate of the rectangle 67 | width (int): Width of the rectangle 68 | height (int): Height of the rectangle 69 | color (Color): Color of the rectangle 70 | """ 71 | 72 | gl.Begin(gl.QUADS) 73 | 74 | gl.Color4f(color.r, color.g, color.b, color.a) 75 | gl.Vertex2f(x, y) 76 | gl.Vertex2f(x + width, y) 77 | gl.Vertex2f(x + width, y + height) 78 | gl.Vertex2f(x, y + height) 79 | 80 | gl.End() 81 | 82 | 83 | def set_background_color(color: Color) -> None: 84 | """ 85 | Sets the background color of the screen. 86 | 87 | Args: 88 | color (Color): The color of the background 89 | """ 90 | gl.ClearColor(color.r, color.g, color.b, color.a) 91 | 92 | 93 | def draw_arbitrary_polygon_outline( 94 | corners: tuple[tuple[int, int]], color: Color 95 | ) -> None: 96 | """ 97 | Draw an arbitrary polygon outline. 98 | WARNING: This will lag the game more and more as the number of corners increase, as this is an O(n)/call function. 99 | 100 | Args: 101 | corners (tuple[tuple[int, int]]): The corners of the polygon 102 | color (Color): The color of the polygon 103 | """ 104 | 105 | for i, (x1, y1) in enumerate(corners[:-1]): 106 | x2, y2 = corners[i + 1] 107 | draw_line(x1, y1, x2, y2, color) 108 | 109 | 110 | def set_pixel(x: int, y: int, color: Color) -> None: 111 | """ 112 | Set a specific pixel on the window 113 | 114 | Args: 115 | x (int): The x coordinate of the pixel 116 | y (int): The y coordinate of the pixel 117 | color (Color): The color of the pixel 118 | """ 119 | gl.Begin(gl.POINTS) 120 | 121 | gl.Color4f(color.r, color.g, color.b, color.a) 122 | gl.Vertex2f(x, y) 123 | 124 | gl.End() 125 | -------------------------------------------------------------------------------- /src/fusionengine/engine/entity.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.window import Window 2 | from fusionengine.engine.image import Image 3 | from fusionengine.engine.shape import Rect 4 | from fusionengine.engine.color import Color 5 | from fusionengine.backend.deprecations import deprecated 6 | 7 | 8 | class Entity: 9 | @deprecated("5.0.0", "Entity class") 10 | def __init__( 11 | self, 12 | window: Window, 13 | x: int, 14 | y: int, 15 | width: int, 16 | height: int, 17 | ) -> None: 18 | """ 19 | A class that creates a new entity. If set_body isn't called, it will automatically become a StaticBody 20 | 21 | Args: 22 | window (Window): Your window 23 | x (int): X position of the entity 24 | y (int): Y position of the entity 25 | width (int): Width of the entity 26 | height (int): Height of the entity 27 | """ 28 | self.x = x 29 | self.y = y 30 | self.width = width 31 | self.height = height 32 | self.window = window 33 | self.gravity = 0 34 | self.frame = 0 35 | self.body = None 36 | 37 | def load_image( 38 | self, 39 | image_path: str, 40 | ) -> None: 41 | """ 42 | Gives the entity an image and laters draws it on the screen. 43 | 44 | Args: 45 | image_path (str): The path to the image 46 | """ 47 | self.main_image = Image(image_path, self.x, self.y, self.width, self.height) 48 | 49 | def load_animation(self, images: tuple) -> None: 50 | """ 51 | Loads images that can be later used as a animation. 52 | 53 | Args: 54 | images (tuple): A tuple of images 55 | """ 56 | self.images = images 57 | 58 | def draw_animation(self) -> None: 59 | """ 60 | Draws the previus loaded images with the current frame that was given. 61 | """ 62 | self.images[self.frame].draw() 63 | 64 | def draw_image(self) -> None: 65 | """ 66 | Draws the image previously loaded. 67 | """ 68 | self.main_image.draw() 69 | 70 | def set_frame(self, frame: int) -> None: 71 | """ 72 | Sets the frame of the previously loaded images (as a animation). 73 | 74 | Args: 75 | frame (int): The frame of the animation 76 | """ 77 | self.frame = frame 78 | 79 | def get_frame(self) -> int: 80 | """ 81 | Gets the frame of the previously loaded images (as a animation). 82 | 83 | Returns: 84 | int: The frame of the animation 85 | """ 86 | return self.frame 87 | 88 | def load_rect(self, color: Color) -> None: 89 | """ 90 | Gives the entity a rectangle and later draws it on the screen. 91 | 92 | Args: 93 | color (tuple): The color of the rectangle 94 | """ 95 | self.main_rect = Rect(self.x, self.y, self.width, self.height, color) 96 | 97 | def draw_rect(self) -> None: 98 | """ 99 | Draws the rectangle previously loaded. 100 | """ 101 | self.main_rect.draw() 102 | -------------------------------------------------------------------------------- /src/fusionengine/engine/enums.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class BodyType(Enum): 5 | RIGID_BODY = "rigid body" 6 | STATIC_BODY = "static body" 7 | -------------------------------------------------------------------------------- /src/fusionengine/engine/event.py: -------------------------------------------------------------------------------- 1 | import pygame as pg 2 | 3 | 4 | class Key: 5 | key_states = {} 6 | 7 | def __init__(self, key) -> None: 8 | """ 9 | The key class that handles key presses and key states. 10 | 11 | Args: 12 | key: The key you want to handle 13 | """ 14 | self.key = key 15 | self.clicked = False 16 | 17 | if key not in Key.key_states: 18 | Key.key_states[key] = False 19 | 20 | def key_down(self) -> bool: 21 | """ 22 | Checks if the key is pressed down. 23 | 24 | Returns: 25 | bool: True if the key is pressed down, False if not. 26 | """ 27 | keys = pg.key.get_pressed() 28 | return keys[self.key] 29 | 30 | def key_down_once(self) -> bool: 31 | """ 32 | Checks if the key is pressed down once. 33 | 34 | Returns: 35 | bool: Returns True once if the key is pressed down, Returns False if not. 36 | """ 37 | if self.key_down() and not Key.key_states[self.key]: 38 | Key.key_states[self.key] = True 39 | return True 40 | elif not self.key_down() and Key.key_states[self.key]: 41 | Key.key_states[self.key] = False 42 | return False 43 | 44 | 45 | def key_down(key) -> bool: 46 | """ 47 | Checks if the key is pressed down. 48 | 49 | Returns: 50 | bool: True if the key is pressed down, False if not. 51 | """ 52 | return Key(key).key_down() 53 | 54 | 55 | def key_down_once(key) -> bool: 56 | """ 57 | Checks if the key is pressed down once. 58 | 59 | Returns: 60 | bool: Returns True once if the key is pressed down, Returns False if not. 61 | """ 62 | return Key(key).key_down_once() 63 | 64 | 65 | def get_mouse_pos(self) -> tuple[int, int]: 66 | """ 67 | Gets the mouse position. 68 | 69 | Returns: 70 | tuple: The mouse position 71 | """ 72 | return pg.mouse.get_pos() 73 | -------------------------------------------------------------------------------- /src/fusionengine/engine/exceptions.py: -------------------------------------------------------------------------------- 1 | class InvalidType(Exception): 2 | """ 3 | A class that stores all exemptions for invalid types. (JsonStorage) 4 | """ 5 | 6 | pass 7 | 8 | 9 | class JsonStorageInvalidIndex(Exception): 10 | """ 11 | A class that stores all exemptions for invalid indexes. (JsonStorage) 12 | """ 13 | 14 | pass 15 | -------------------------------------------------------------------------------- /src/fusionengine/engine/image.py: -------------------------------------------------------------------------------- 1 | import fusionengine.fusiongl as gl 2 | 3 | import pygame as pg 4 | 5 | 6 | class Image: 7 | def __init__( 8 | self, 9 | image_path: str | pg.Surface, 10 | x: int, 11 | y: int, 12 | width: int, 13 | height: int, 14 | ) -> None: 15 | """ 16 | Opens an image. Can be later rendered with draw method. 17 | 18 | Args: 19 | image_path (str or Pygame Surface): The path to the image | Pygame Surface 20 | x (int): X coordinate of the image 21 | y (int): Y coordinate of the image 22 | width (int): Width of the image (scaling allowed) 23 | height (int): Height of the image (scaling allowed) 24 | """ 25 | 26 | self.x = x 27 | self.y = y 28 | self.width = width 29 | self.height = height 30 | 31 | if isinstance(image_path, str): 32 | self.image = pg.image.load(image_path) 33 | elif isinstance(image_path, pg.Surface): 34 | self.image = image_path 35 | else: 36 | raise ValueError("Invalid image_path type") 37 | 38 | self.texture = gl.GenTextures(1) 39 | gl.BindTexture(gl.TEXTURE_2D, self.texture) 40 | gl.TexImage2D( 41 | gl.TEXTURE_2D, 42 | 0, 43 | gl.RGBA, 44 | self.image.get_width(), 45 | self.image.get_height(), 46 | 0, 47 | gl.RGBA, 48 | gl.UNSIGNED_BYTE, 49 | pg.image.tostring(self.image, "RGBA"), 50 | ) 51 | 52 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) 53 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) 54 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) 55 | gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) 56 | 57 | def get_image_size(self): 58 | """ 59 | Returns the size of the image itself (not the set size). 60 | 61 | Returns: 62 | tuple: (width, height) 63 | """ 64 | return self.image.get_width(), self.image.get_height() 65 | 66 | def crop(self, x: int, y: int, width: int, height: int) -> "Image": 67 | """ 68 | Crop the image based on the specified boundaries. 69 | 70 | Args: 71 | left (int): The left boundary of the crop area. 72 | right (int): The right boundary of the crop area. 73 | top (int): The top boundary of the crop area. 74 | bottom (int): The bottom boundary of the crop area. 75 | 76 | Returns: 77 | Image: A new Image object representing the cropped image. 78 | """ 79 | cropped_surface = self.image.subsurface((x, y, width, height)) 80 | return Image(cropped_surface, self.x, self.y, self.width, self.height) 81 | 82 | def draw(self) -> None: 83 | """ 84 | Draws your image on the screen. 85 | """ 86 | gl.BindTexture(gl.TEXTURE_2D, self.texture) 87 | gl.Begin(gl.QUADS) 88 | 89 | gl.TexCoord2f(0, 0) 90 | gl.Vertex2f(self.x, self.y) 91 | 92 | gl.TexCoord2f(1, 0) 93 | gl.Vertex2f(self.x + self.width, self.y) 94 | 95 | gl.TexCoord2f(1, 1) 96 | gl.Vertex2f(self.x + self.width, self.y + self.height) 97 | 98 | gl.TexCoord2f(0, 1) 99 | gl.Vertex2f(self.x, self.y + self.height) 100 | 101 | gl.End() 102 | gl.BindTexture(gl.TEXTURE_2D, 0) 103 | 104 | 105 | def draw_image(path: str, x: int, y: int, width: int, height: int): 106 | """ 107 | Draws a image directly from provided path. 108 | 109 | Args: 110 | image_path (str): The path to the image 111 | x (int): X coordinate of the image 112 | y (int): Y coordinate of the image 113 | width (int): Width of the image (scaling allowed) 114 | height (int): Height of the image (scaling allowed) 115 | """ 116 | Image(path, x, y, width, height).draw() 117 | -------------------------------------------------------------------------------- /src/fusionengine/engine/keys.py: -------------------------------------------------------------------------------- 1 | import pygame as pg 2 | 3 | KEY_UNKNOWN = pg.K_UNKNOWN 4 | KEY_RETURN = pg.K_RETURN 5 | KEY_ESCAPE = pg.K_ESCAPE 6 | KEY_BACKSPACE = pg.K_BACKSPACE 7 | KEY_TAB = pg.K_TAB 8 | KEY_SPACE = pg.K_SPACE 9 | KEY_EXCLAIM = pg.K_EXCLAIM 10 | KEY_QUOTEDBL = pg.K_QUOTEDBL 11 | KEY_HASH = pg.K_HASH 12 | KEY_PERCENT = pg.K_PERCENT 13 | KEY_DOLLAR = pg.K_DOLLAR 14 | KEY_AMPERSAND = pg.K_AMPERSAND 15 | KEY_QUOTE = pg.K_QUOTE 16 | KEY_LEFTPAREN = pg.K_LEFTPAREN 17 | KEY_RIGHTPAREN = pg.K_RIGHTPAREN 18 | KEY_ASTERISK = pg.K_ASTERISK 19 | KEY_PLUS = pg.K_PLUS 20 | KEY_COMMA = pg.K_COMMA 21 | KEY_MINUS = pg.K_MINUS 22 | KEY_PERIOD = pg.K_PERIOD 23 | KEY_SLASH = pg.K_SLASH 24 | 25 | KEY_0 = pg.K_0 26 | KEY_1 = pg.K_1 27 | KEY_2 = pg.K_2 28 | KEY_3 = pg.K_3 29 | KEY_4 = pg.K_4 30 | KEY_5 = pg.K_5 31 | KEY_6 = pg.K_6 32 | KEY_7 = pg.K_7 33 | KEY_8 = pg.K_8 34 | KEY_9 = pg.K_9 35 | 36 | KEY_COLON = pg.K_COLON 37 | KEY_SEMICOLON = pg.K_SEMICOLON 38 | KEY_LESS = pg.K_LESS 39 | KEY_EQUALS = pg.K_EQUALS 40 | KEY_GREATER = pg.K_GREATER 41 | KEY_QUESTION = pg.K_QUESTION 42 | KEY_AT = pg.K_AT 43 | KEY_LEFTBRACKET = pg.K_LEFTBRACKET 44 | KEY_BACKSLASH = pg.K_BACKSLASH 45 | KEY_RIGHTBRACKET = pg.K_RIGHTBRACKET 46 | KEY_CARET = pg.K_CARET 47 | KEY_UNDERSCORE = pg.K_UNDERSCORE 48 | KEY_BACKQUOTE = pg.K_BACKQUOTE 49 | 50 | KEY_a = pg.K_a 51 | KEY_b = pg.K_b 52 | KEY_c = pg.K_c 53 | KEY_d = pg.K_d 54 | KEY_e = pg.K_e 55 | KEY_f = pg.K_f 56 | KEY_g = pg.K_g 57 | KEY_h = pg.K_h 58 | KEY_i = pg.K_i 59 | KEY_j = pg.K_j 60 | KEY_k = pg.K_k 61 | KEY_l = pg.K_l 62 | KEY_m = pg.K_m 63 | KEY_n = pg.K_n 64 | KEY_o = pg.K_o 65 | KEY_p = pg.K_p 66 | KEY_q = pg.K_q 67 | KEY_r = pg.K_r 68 | KEY_s = pg.K_s 69 | KEY_t = pg.K_t 70 | KEY_u = pg.K_u 71 | KEY_v = pg.K_v 72 | KEY_w = pg.K_w 73 | KEY_x = pg.K_x 74 | KEY_y = pg.K_y 75 | KEY_z = pg.K_z 76 | 77 | KEY_A = pg.K_a 78 | KEY_B = pg.K_b 79 | KEY_C = pg.K_c 80 | KEY_D = pg.K_d 81 | KEY_E = pg.K_e 82 | KEY_F = pg.K_f 83 | KEY_G = pg.K_g 84 | KEY_H = pg.K_h 85 | KEY_I = pg.K_i 86 | KEY_J = pg.K_j 87 | KEY_K = pg.K_k 88 | KEY_L = pg.K_l 89 | KEY_M = pg.K_m 90 | KEY_N = pg.K_n 91 | KEY_O = pg.K_o 92 | KEY_P = pg.K_p 93 | KEY_Q = pg.K_q 94 | KEY_R = pg.K_r 95 | KEY_S = pg.K_s 96 | KEY_T = pg.K_t 97 | KEY_U = pg.K_u 98 | KEY_V = pg.K_v 99 | KEY_W = pg.K_w 100 | KEY_X = pg.K_x 101 | KEY_Y = pg.K_y 102 | KEY_Z = pg.K_z 103 | 104 | KEY_CAPSLOCK = pg.K_CAPSLOCK 105 | 106 | KEY_F1 = pg.K_F1 107 | KEY_F2 = pg.K_F2 108 | KEY_F3 = pg.K_F3 109 | KEY_F4 = pg.K_F4 110 | KEY_F5 = pg.K_F5 111 | KEY_F6 = pg.K_F6 112 | KEY_F7 = pg.K_F7 113 | KEY_F8 = pg.K_F8 114 | KEY_F9 = pg.K_F9 115 | KEY_F10 = pg.K_F10 116 | KEY_F11 = pg.K_F11 117 | KEY_F12 = pg.K_F12 118 | KEY_F13 = pg.K_F13 119 | KEY_F14 = pg.K_F14 120 | KEY_F15 = pg.K_F15 121 | 122 | KEY_PRINTSCREEN = pg.K_PRINT 123 | KEY_SCROLLLOCK = pg.K_SCROLLLOCK 124 | KEY_PAUSE = pg.K_PAUSE 125 | KEY_INSERT = pg.K_INSERT 126 | KEY_HOME = pg.K_HOME 127 | KEY_PAGEUP = pg.K_PAGEUP 128 | KEY_DELETE = pg.K_DELETE 129 | KEY_END = pg.K_END 130 | KEY_PAGEDOWN = pg.K_PAGEDOWN 131 | KEY_RIGHT = pg.K_RIGHT 132 | KEY_LEFT = pg.K_LEFT 133 | KEY_DOWN = pg.K_DOWN 134 | KEY_UP = pg.K_UP 135 | KEY_NUMLOCKCLEAR = pg.K_NUMLOCK 136 | KEY_KP_DIVIDE = pg.K_KP_DIVIDE 137 | KEY_KP_MULTIPLY = pg.K_KP_MULTIPLY 138 | KEY_KP_MINUS = pg.K_KP_MINUS 139 | KEY_KP_PLUS = pg.K_KP_PLUS 140 | KEY_KP_ENTER = pg.K_KP_ENTER 141 | 142 | KEY_KP_1 = pg.K_KP1 143 | KEY_KP_2 = pg.K_KP2 144 | KEY_KP_3 = pg.K_KP3 145 | KEY_KP_4 = pg.K_KP4 146 | KEY_KP_5 = pg.K_KP5 147 | KEY_KP_6 = pg.K_KP6 148 | KEY_KP_7 = pg.K_KP7 149 | KEY_KP_8 = pg.K_KP8 150 | KEY_KP_9 = pg.K_KP9 151 | KEY_KP_0 = pg.K_KP0 152 | 153 | KEY_KP_PERIOD = pg.K_KP_PERIOD 154 | KEY_POWER = pg.K_POWER 155 | KEY_KP_EQUALS = pg.K_KP_EQUALS 156 | KEY_HELP = pg.K_HELP 157 | KEY_MENU = pg.K_MENU 158 | KEY_SYSREQ = pg.K_SYSREQ 159 | KEY_CLEAR = pg.K_CLEAR 160 | KEY_CURRENCYUNIT = pg.K_CURRENCYUNIT 161 | KEY_CURRENCYSUBUNIT = pg.K_CURRENCYSUBUNIT 162 | KEY_LCTRL = pg.K_LCTRL 163 | KEY_LSHIFT = pg.K_LSHIFT 164 | KEY_LALT = pg.K_LALT 165 | KEY_LGUI = pg.K_LMETA 166 | KEY_RCTRL = pg.K_RCTRL 167 | KEY_RSHIFT = pg.K_RSHIFT 168 | KEY_RALT = pg.K_RALT 169 | KEY_RGUI = pg.K_RMETA 170 | KEY_MODE = pg.K_MODE 171 | KEY_AC_BACK = pg.K_AC_BACK 172 | -------------------------------------------------------------------------------- /src/fusionengine/engine/manager.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.window import Window 2 | from fusionengine.engine.scene import Scene 3 | 4 | 5 | class SceneManager: 6 | def init(self, window: Window) -> None: 7 | """ 8 | Creates a new SceneManager 9 | 10 | Args: 11 | window (Window): Your window 12 | """ 13 | self.window = window 14 | self.scenes = {} 15 | 16 | def add_scene(self, scene: Scene) -> None: 17 | """ 18 | Adds a scene to the manager 19 | 20 | Args: 21 | scene (Scene): The scene to add 22 | """ 23 | self.scenes[scene.name] = scene 24 | 25 | def remove_scene(self, name: str) -> None: 26 | """ 27 | Removes a scene from the manager 28 | 29 | Args: 30 | name (str): The name of the scene to remove 31 | """ 32 | del self.scenes[name] 33 | 34 | def change_scene(self, name: str, scene: Scene) -> None: 35 | """ 36 | Changes the scene provided with a name to the given scene 37 | 38 | Args: 39 | name (str): The name of the scene to change 40 | scene (Scene): The scene to change to 41 | """ 42 | self.scenes[name] = scene 43 | 44 | def get_scene(self, name: str) -> Scene: 45 | """ 46 | Gets a scene from the manager 47 | 48 | Args: 49 | name (str): The name of the scene to get 50 | 51 | Returns: 52 | Scene: The scene 53 | """ 54 | return self.scenes[name] 55 | 56 | def start(self): 57 | """ 58 | Starts all the scenes one after a other 59 | """ 60 | for scene in list(self.scenes.values()): 61 | scene.run() 62 | 63 | def loop(self, function, window: Window): 64 | """ 65 | A decorator that to wrap the window loop 66 | 67 | Args: 68 | window (Window): The window to wrap 69 | """ 70 | 71 | @window.loop 72 | def wrapper(): 73 | function() 74 | -------------------------------------------------------------------------------- /src/fusionengine/engine/math.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | 4 | PI = 3.141592653589793238462643383279502884197 5 | SMALLERPI = 3.141592653589793 6 | SMALLPI = 3.14 7 | EULERNUMBER = 2.718281828459045 8 | 9 | 10 | def FLOOR(value: float) -> float: 11 | """ 12 | Get the floor value 13 | 14 | Args: 15 | value (float): The value to get the floor of 16 | 17 | Returns: 18 | float: The floor value 19 | """ 20 | return math.floor(value) 21 | -------------------------------------------------------------------------------- /src/fusionengine/engine/node.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.window import Window 2 | from fusionengine.engine.shape import Rect 3 | from fusionengine.engine.image import Image 4 | from fusionengine.engine.vector import Vector2D 5 | from fusionengine.engine.animation import Animation 6 | from fusionengine.engine.color import Color 7 | 8 | 9 | class Node: 10 | def __init__(self, window: Window, x: int, y: int, width: int, height: int): 11 | self.x = x 12 | self.y = y 13 | self.width = width 14 | self.height = height 15 | self.window = window 16 | self.frame = 0 17 | self.to_draw = [] 18 | 19 | def get_coord_tuple(self) -> tuple[int, int]: 20 | """ 21 | Returns the coordinates of the node as a tuple. 22 | 23 | Returns: 24 | A tuple containing the x and y coordinates of the node. 25 | """ 26 | return self.x, self.y 27 | 28 | def get_coord_vec2(self) -> Vector2D: 29 | """ 30 | Returns the coordinates of the node as a Vector2D object. 31 | 32 | Returns: 33 | Vector2D: The coordinates of the node. 34 | """ 35 | return Vector2D(self.x, self.y) 36 | 37 | def set_frame(self, frame: int) -> None: 38 | """ 39 | Sets the frame of the previously loaded images (as a animation). 40 | 41 | Args: 42 | frame (int): The frame of the animation 43 | """ 44 | self.frame = frame 45 | 46 | def get_frame(self) -> int: 47 | """ 48 | Gets the frame of the previously loaded images (as a animation). 49 | 50 | Returns: 51 | int: The frame of the animation 52 | """ 53 | return self.frame 54 | 55 | def load_image(self, image_path: str) -> None: 56 | """ 57 | Gives the entity an image and laters draws it on the screen. 58 | 59 | Args: 60 | image_path (str): The path to the image 61 | """ 62 | self.to_draw.append(Image(image_path, self.x, self.y, self.width, self.height)) 63 | 64 | def load_animation(self, images: tuple | Animation) -> None: 65 | """ 66 | Loads images that can be later used as a animation. 67 | 68 | Args: 69 | images (tuple): A tuple of images 70 | """ 71 | self.to_draw.append(images) 72 | 73 | def load_rect(self, color: Color) -> None: 74 | """ 75 | Gives the entity a rectangle and later draws it on the screen. 76 | 77 | Args: 78 | color (tuple): The color of the rectangle 79 | """ 80 | self.to_draw.append(Rect(self.x, self.y, self.width, self.height, color)) 81 | 82 | def update(self): 83 | """ 84 | Update method for the node. 85 | This method is called to update the state of the node and to draw everything. 86 | """ 87 | for draw in self.to_draw: 88 | if isinstance(draw, tuple): 89 | draw[self.frame].draw() 90 | elif isinstance(draw, Animation): 91 | draw.play() 92 | else: 93 | draw.draw() 94 | 95 | self.to_draw = [] 96 | -------------------------------------------------------------------------------- /src/fusionengine/engine/scene.py: -------------------------------------------------------------------------------- 1 | class Scene: 2 | def __init__(self, name: str, function): 3 | """ 4 | Create a new Scene object. Can be later used with SceneManager 5 | 6 | Args: 7 | name (str): The name of the scene 8 | function: The function containing the code to the function 9 | """ 10 | self.name = name 11 | self.function = function 12 | 13 | def run(self): 14 | """ 15 | Run the functions (Do not use youself. This is ment for SceneManager) 16 | """ 17 | self.function() 18 | 19 | def change_function(self, function): 20 | """ 21 | Change the function of the scene 22 | 23 | Args: 24 | function : The function containing the code to the scene 25 | """ 26 | self.function = function 27 | -------------------------------------------------------------------------------- /src/fusionengine/engine/shape.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.color import Color, BLUE 2 | from fusionengine.engine.draw import draw_rect 3 | 4 | import pygame as pg 5 | 6 | 7 | class Rect: 8 | def __init__( 9 | self, 10 | x: int, 11 | y: int, 12 | width: int, 13 | height: int, 14 | color: Color = BLUE, 15 | ) -> None: 16 | """ 17 | A class that creates a new rect shape. 18 | 19 | Args: 20 | x (int): X coordinate of the rect 21 | y (int): Y coordinate of the rect 22 | width (int): Width of the rect 23 | height (int): Height of the rect 24 | color (Color): Color of the rect 25 | """ 26 | self.x = x 27 | self.y = y 28 | self.width = width 29 | self.height = height 30 | self.color = color 31 | 32 | self.pg_rect = pg.Rect(self.x, self.y, self.width, self.height) 33 | 34 | def draw(self) -> None: 35 | """ 36 | Draw the rectangle 37 | """ 38 | draw_rect(self.x, self.y, self.width, self.height, self.color) 39 | -------------------------------------------------------------------------------- /src/fusionengine/engine/sound.py: -------------------------------------------------------------------------------- 1 | import pygame as pg 2 | 3 | 4 | class Sound: 5 | def __init__(self, sound_path: str) -> None: 6 | """ 7 | A class that creates a new sound. 8 | 9 | Args: 10 | sound_path (str): The path to the sound file 11 | """ 12 | self.sound = pg.mixer.Sound(sound_path) 13 | 14 | def play(self) -> None: 15 | """ 16 | Plays the sound 17 | """ 18 | pg.mixer.Sound.play(self.sound) 19 | 20 | def stop(self) -> None: 21 | """ 22 | Stops the sound 23 | """ 24 | self.sound.stop() 25 | 26 | def get_volume(self) -> float: 27 | """ 28 | Returns the volume of the sound 29 | 30 | Returns: 31 | float: The volume of the sound 32 | """ 33 | return self.sound.get_volume() 34 | 35 | def set_volume(self, volume: int) -> None: 36 | """ 37 | Send the volume of the sound 38 | 39 | Args: 40 | volume (int): The volume of the sound 41 | """ 42 | self.sound.set_volume(volume) 43 | 44 | def fadeout(self, time: int) -> None: 45 | """ 46 | Fadeout the sound 47 | 48 | Args: 49 | time (int): The time it takes to fadeout the sound 50 | """ 51 | self.sound.fadeout(time) 52 | 53 | 54 | class BackgroundMusic: 55 | def __init__(self, sound_path: str) -> None: 56 | """ 57 | The class for background music. 58 | 59 | Args: 60 | sound_path (str): The path to the sound file 61 | """ 62 | pg.mixer.music.load(sound_path) 63 | pg.mixer.music.play(-1) 64 | 65 | def set_volume(self, volume: int) -> None: 66 | """ 67 | Sets the volume of the background music. 68 | 69 | Args: 70 | volume (int): The volume of the background music 71 | """ 72 | pg.mixer.music.set_volume(volume) 73 | -------------------------------------------------------------------------------- /src/fusionengine/engine/spritesheets.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.image import Image 2 | 3 | 4 | class SpriteSheet: 5 | def __init__(self, image_path: str, sprite_width: int, sprite_height: int): 6 | """ 7 | Represents a SpriteSheet containing a grid of frames. 8 | 9 | Args: 10 | image_path (str): The path to the sprite sheet image file. 11 | sprite_width (int): Width of each sprite frame. 12 | sprite_height (int): Height of each sprite frame. 13 | """ 14 | self.sprite_sheet = Image(image_path, 0, 0, 0, 0) 15 | self.sprite_width = sprite_width 16 | self.sprite_height = sprite_height 17 | self.frames = self.get_frames() 18 | self.width = 0 19 | self.height = 0 20 | 21 | def get_frames(self) -> list: 22 | """ 23 | Extract frames from the sprite sheet. 24 | 25 | Returns: 26 | list: List of Image objects representing individual frames. 27 | """ 28 | frames = [] 29 | columns = self.sprite_sheet.get_image_size()[0] // self.sprite_width 30 | rows = self.sprite_sheet.get_image_size()[1] // self.sprite_height 31 | 32 | for row in range(rows): 33 | for col in range(columns): 34 | frame = self.extract_frame(col, row) 35 | frames.append(frame) 36 | 37 | return frames 38 | 39 | def extract_frame(self, col: int, row: int) -> Image: 40 | """ 41 | Extract a single frame from the sprite sheet. 42 | 43 | Args: 44 | col (int): Column index of the sprite. 45 | row (int): Row index of the sprite. 46 | 47 | Returns: 48 | Image: Image object representing the extracted frame. 49 | """ 50 | x = col * self.sprite_width 51 | y = row * self.sprite_height 52 | 53 | frame_surface = self.sprite_sheet.crop( 54 | x, y, self.sprite_width, self.sprite_height 55 | ) 56 | frame = Image(frame_surface.image, 0, 0, self.sprite_width, self.sprite_height) 57 | return frame 58 | 59 | def frame_size(self, width: int, height: int) -> None: 60 | """ 61 | Set the size of each frame in the sprite sheet. 62 | 63 | Args: 64 | width (int): Width to set for each frame. 65 | height (int): Height to set for each frame. 66 | """ 67 | for frame in self.frames: 68 | frame.width = width 69 | frame.height = height 70 | 71 | def frame_pos(self, x: int, y: int) -> None: 72 | """ 73 | Set the position of each frame in the sprite sheet. 74 | 75 | Args: 76 | x (int): X position to set for each frame. 77 | y (int): Y position to set for each frame. 78 | """ 79 | for frame in self.frames: 80 | frame.x = x 81 | frame.y = y 82 | -------------------------------------------------------------------------------- /src/fusionengine/engine/storage.py: -------------------------------------------------------------------------------- 1 | import json 2 | import typing 3 | from pathlib import Path 4 | 5 | from fusionengine.engine.exceptions import InvalidType, JsonStorageInvalidIndex 6 | 7 | 8 | class JsonStorage: 9 | """JsonStorage is a storage class for saving json databases, currently all data is loaded from 10 | disk and saved to memory when you done with the storage you can just save it to the disk file 11 | using save method 12 | 13 | Attributes: 14 | file_path (str): The path to the storage file on disk 15 | storage (list): The storage variable saved to memory 16 | """ 17 | 18 | def __init__(self, file_path: str): 19 | self.storage = [] 20 | self.file_path = Path(file_path) 21 | 22 | if self.file_path.exists(): 23 | with open(self.file_path, mode="r", encoding="utf8") as file: 24 | self.storage = json.load(file) 25 | 26 | def insert(self, _dict: dict[typing.Any, typing.Any]) -> bool: 27 | try: 28 | if not isinstance(_dict, dict): 29 | raise InvalidType(f"_dict excepted to be dict not {type(_dict)}") 30 | 31 | self.storage.append(_dict) 32 | return True 33 | except Exception: 34 | return False 35 | 36 | def search( 37 | self, 38 | search_dict: dict[typing.Any, typing.Any], 39 | first: bool = False, 40 | get_index: bool = False, 41 | ) -> typing.Union[dict, list, tuple, None]: 42 | """Search for a entry based on the search_dict 43 | 44 | Args: 45 | search_dict (dict): search_dict is a dictionary describing keys:values to search for 46 | in the entries 47 | first (bool, optional): only return the first result that found 48 | nested_search (bool, optional): if its true if will search for keys and values 49 | based on search_dict in nested data structures (like another dictionary in the 50 | parent main dict entry) 51 | 52 | Returns: 53 | typing.Union[dict, list, tuple, None]: The entries that found if 54 | first is False otherwise the first entry that found 55 | if get_index is true then it will return a tuple 56 | containing two values which being the index of the entry 57 | aside the value of it(returns None if nothing found) 58 | """ 59 | if first: 60 | # Only search for the first entry 61 | for index, entry in enumerate(self.storage): 62 | passed_every_search = True 63 | for sk, sv in search_dict.items(): 64 | if entry.get(sk) != sv: 65 | passed_every_search = False 66 | if passed_every_search: 67 | if get_index: 68 | return (entry, index) 69 | else: 70 | return entry 71 | else: 72 | # Search for all entries 73 | founded_entries = [] 74 | for index, entry in enumerate(self.storage): 75 | passed_every_search = True 76 | for sk, sv in search_dict.items(): 77 | if entry.get(sk) != sv: 78 | passed_every_search = False 79 | if passed_every_search: 80 | if get_index: 81 | founded_entries.append((entry, index)) 82 | else: 83 | founded_entries.append(entry) 84 | return founded_entries 85 | 86 | def update(self, index: int, new_entry: dict[typing.Any, typing.Any]) -> bool: 87 | """Update the entry based on the index to new_dict 88 | 89 | Args: 90 | index (int): The index of the entry you want to update 91 | new_entry (dict): The new updated entry 92 | 93 | Returns: 94 | bool: Wether the action was successful or not 95 | 96 | Raises: 97 | InvalidType: In case the index parameter is not an integer or new_entry 98 | is not a dict 99 | JsonStorageInvalidIndex: In case the index is out of range and couldn't be find 100 | in the entries 101 | """ 102 | if not isinstance(index, int): 103 | raise InvalidType(f"index excepted to be integer not {type(index)}") 104 | if not isinstance(new_entry, dict): 105 | raise InvalidType(f"new_entry excepted to be dict not {type(new_entry)}") 106 | try: 107 | self.storage[index] = new_entry 108 | return True 109 | except IndexError: 110 | raise JsonStorageInvalidIndex( 111 | "Invalid index, couldn't find the index in entries" 112 | ) 113 | except: 114 | return False 115 | 116 | def delete(self, index: int) -> bool: 117 | """Delete an entry based on the index given 118 | 119 | Args: 120 | index (int): The index of the entry you want to delete 121 | 122 | Returns: 123 | bool: Wether the action was successful or not 124 | 125 | Raises: 126 | InvalidType: In case the index parameter is not an integer 127 | JsonStorageInvalidIndex: In case the index is out of range and couldn't be find 128 | in the entries 129 | """ 130 | if not isinstance(index, int): 131 | raise InvalidType(f"index excepted to be integer not {type(index)}") 132 | try: 133 | del self.storage[index] 134 | return True 135 | except IndexError: 136 | raise JsonStorageInvalidIndex( 137 | "Invalid index, couldn't find the index in entries" 138 | ) 139 | except: 140 | return False 141 | 142 | def save(self) -> bool: 143 | """Saves the storage variable into disk 144 | 145 | Returns: 146 | bool: Wether the action was successful or not 147 | """ 148 | try: 149 | with open(self.file_path, mode="w", encoding="utf8") as file: 150 | json.dump(self.storage, file) 151 | return True 152 | except: 153 | return False 154 | -------------------------------------------------------------------------------- /src/fusionengine/engine/ui.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.shape import Rect 2 | from fusionengine.engine.color import Color, WHITE, GRAY 3 | import fusionengine.fusiongl as gl 4 | from fusionengine.engine.debug import DEBUGFONT 5 | 6 | import pygame as pg 7 | import os 8 | 9 | 10 | class Button: 11 | def __init__( 12 | self, 13 | x: int, 14 | y: int, 15 | width: int, 16 | height: int, 17 | font_size: int, 18 | text: str, 19 | font: str = DEBUGFONT, 20 | ) -> None: 21 | """ 22 | Creates a button. You can get its events using is_pressed() function or you can draw it using draw() function. 23 | 24 | Args: 25 | x (int): X pos 26 | y (int): Y pos 27 | width (int): Width 28 | height (int): Height 29 | font_size (int): Font size 30 | text (str): Text 31 | font (str, optional): Your Font. Defaults to the default font (DEBUGFONT). 32 | """ 33 | self.rect_color = GRAY 34 | self.rect = Rect(x, y, 500, 500, self.rect_color) 35 | self.x = x 36 | self.y = y 37 | self.width = width 38 | self.height = height 39 | self.input_text = text 40 | self.font = font 41 | self.font_size = font_size 42 | 43 | self.text = Text(text, x, y, font, font_size, WHITE) 44 | 45 | def is_pressed(self) -> bool: 46 | """ 47 | Returns true if the button is pressed. 48 | 49 | Returns: 50 | bool: If the button is pressed, returns True 51 | """ 52 | mouse_x, mouse_y = pg.mouse.get_pos() 53 | mouse_click = pg.mouse.get_pressed() 54 | 55 | if self.rect.pg_rect.collidepoint(mouse_x, mouse_y) and mouse_click[0] == 1: 56 | return True 57 | else: 58 | return False 59 | 60 | def draw(self) -> None: 61 | """ 62 | Draws the button. 63 | """ 64 | self.rect.draw() 65 | self.text.draw() 66 | 67 | def set_button_color(self, color: Color) -> None: 68 | """ 69 | Sets the color of the button. 70 | 71 | Args: 72 | color (Color): The color of the button 73 | """ 74 | self.rect_color = color 75 | self.rect.color = color 76 | 77 | def set_text_color(self, color: Color) -> None: 78 | """ 79 | Sets the color of the button text. 80 | 81 | Args: 82 | color (Color): The color of the button text 83 | """ 84 | self.text.set_color(color) 85 | 86 | 87 | class Text: 88 | def __init__( 89 | self, 90 | text: str, 91 | x: int, 92 | y: int, 93 | font_path: str, 94 | font_size: int, 95 | color: Color, 96 | ) -> None: 97 | """ 98 | Prints text on the screen. 99 | 100 | Args: 101 | text (str): The text you want to print 102 | x (int): X coordinate of the text 103 | y (int): Y coordinate of the text 104 | font_path (str): The path to the font file 105 | font_size (int): The size of the font 106 | color (tuple): The color of the text 107 | """ 108 | 109 | self.text = text 110 | self.color = color 111 | self.x = x 112 | self.y = y 113 | 114 | if os.path.exists(font_path): 115 | self.font = pg.font.Font(font_path, font_size) 116 | else: 117 | self.font = pg.font.SysFont(font_path, font_size) 118 | 119 | render = self.font.render(self.text, True, self.color.tuple) 120 | text_surface = pg.image.tostring(render, "RGBA", False) 121 | self.width, self.height = render.get_size() 122 | 123 | self.texture_id = gl.GenTextures(1) 124 | 125 | gl.BindTexture(gl.TEXTURE_2D, self.texture_id) 126 | 127 | gl.TexImage2D( 128 | gl.TEXTURE_2D, 129 | 0, 130 | gl.RGBA, 131 | self.width, 132 | self.height, 133 | 0, 134 | gl.RGBA, 135 | gl.UNSIGNED_BYTE, 136 | text_surface, 137 | ) 138 | gl.TexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) 139 | gl.TexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) 140 | gl.TexParameter(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST) 141 | gl.TexParameter(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST) 142 | 143 | gl.BindTexture(gl.TEXTURE_2D, 0) 144 | 145 | def set_color(self, color: Color): 146 | """ 147 | Sets the color of the text. 148 | 149 | Args: 150 | color (tuple): The color of the text 151 | """ 152 | self.color = color 153 | 154 | def draw(self) -> None: 155 | """ 156 | Draws the loaded font using texture mapping 157 | """ 158 | gl.BindTexture(gl.TEXTURE_2D, self.texture_id) 159 | 160 | gl.Begin(gl.QUADS) 161 | 162 | gl.Color4f(self.color.r, self.color.g, self.color.b, self.color.a) 163 | 164 | gl.TexCoord2f(0, 0) 165 | gl.Vertex2f(self.x, self.y) 166 | gl.TexCoord2f(1, 0) 167 | gl.Vertex2f(self.x + self.width, self.y) 168 | gl.TexCoord2f(1, 1) 169 | gl.Vertex2f(self.x + self.width, self.y + self.height) 170 | gl.TexCoord2f(0, 1) 171 | gl.Vertex2f(self.x, self.y + self.height) 172 | gl.End() 173 | 174 | gl.BindTexture(gl.TEXTURE_2D, 0) 175 | -------------------------------------------------------------------------------- /src/fusionengine/engine/vector.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | 4 | class Vector2D: 5 | """ 6 | 2-element structure that can be used to represent positions in 2d. 7 | If there are no arguments, a zero vector will be created 8 | """ 9 | 10 | def __init__(self, x: int | float = 0, y: int | float = 0): 11 | self.x = x 12 | self.y = y 13 | 14 | def __add__(self, other): 15 | if isinstance(other, tuple): 16 | return Vector2D(self.x + other[0], self.y + other[1]) 17 | elif isinstance(other, Vector2D): 18 | return Vector2D(self.x + other.x, self.y + other.y) 19 | else: 20 | return NotImplemented 21 | 22 | def __radd__(self, other): 23 | return self.__add__(other) 24 | 25 | def __iadd__(self, other): 26 | if isinstance(other, tuple): 27 | self.x += other[0] 28 | self.y += other[1] 29 | elif isinstance(other, Vector2D): 30 | self.x += other.x 31 | self.y += other.y 32 | else: 33 | return NotImplemented 34 | 35 | return self 36 | 37 | def __sub__(self, other): 38 | if isinstance(other, tuple): 39 | return Vector2D(self.x - other[0], self.y - other[1]) 40 | elif isinstance(other, Vector2D): 41 | return Vector2D(self.x - other.x, self.y - other.y) 42 | else: 43 | return NotImplemented 44 | 45 | def __rsub__(self, other): 46 | return self.__sub__(other) 47 | 48 | def __isub__(self, other): 49 | if isinstance(other, tuple): 50 | self.x -= other[0] 51 | self.y -= other[1] 52 | elif isinstance(other, Vector2D): 53 | self.x -= other.x 54 | self.y -= other.y 55 | else: 56 | return NotImplemented 57 | 58 | return self 59 | 60 | def __mul__(self, other): 61 | if isinstance(other, (int, float)): 62 | return Vector2D(self.x * other, self.y * other) 63 | else: 64 | return NotImplemented 65 | 66 | def __rmul__(self, other): 67 | return self.__mul__(other) 68 | 69 | def __imul__(self, other): 70 | if isinstance(other, (int, float)): 71 | self.x *= other 72 | self.y *= other 73 | else: 74 | return NotImplemented 75 | 76 | return self 77 | 78 | def __truediv__(self, other): 79 | if isinstance(other, (int, float)): 80 | return Vector2D(self.x / other, self.y / other) 81 | else: 82 | return NotImplemented 83 | 84 | def __rtruediv__(self, other): 85 | return self.__truediv__(other) 86 | 87 | def __itruediv__(self, other): 88 | if isinstance(other, (int, float)): 89 | self.x /= other 90 | self.y /= other 91 | else: 92 | return NotImplemented 93 | 94 | return self 95 | 96 | def normalize(self) -> None: 97 | """ 98 | The method normalizes this vector and displays the unit vector. 99 | """ 100 | magnitude = math.sqrt(self.x**2 + self.y**2) 101 | self.x = self.x / abs(magnitude) 102 | self.y = self.y / abs(magnitude) 103 | 104 | def from_tuple(self, value: tuple[int, int] | tuple[float, float]) -> None: 105 | """ 106 | Setting vector values from tuple 107 | Args: 108 | value (tuple): A value that allows you to get values for a vector 109 | """ 110 | 111 | self.x, self.y = value 112 | 113 | def get_tuple(self) -> tuple[int, int]: 114 | """ 115 | Get vector values (int) 116 | Returns: 117 | tuple[int, int]: x and y values 118 | """ 119 | 120 | return int(self.x), int(self.y) 121 | 122 | def get_tuplef(self) -> tuple[float, float]: 123 | """ 124 | Get vector values (float) 125 | Returns: 126 | tuple[float, float]: x and y values 127 | """ 128 | 129 | return float(self.x), float(self.y) 130 | 131 | 132 | class Vector3D: 133 | """ 134 | 3-element structure that can be used to represent positions in 3d. 135 | If there are no arguments, a zero vector will be created 136 | """ 137 | 138 | def __init__(self, x: int | float = 0, y: int | float = 0, z: int | float = 0): 139 | self.x = x 140 | self.y = y 141 | self.z = z 142 | 143 | def __add__(self, other): 144 | if isinstance(other, tuple): 145 | return Vector3D(self.x + other[0], self.y + other[1], self.z + other[2]) 146 | elif isinstance(other, Vector3D): 147 | return Vector3D(self.x + other.x, self.y + other.y, self.z + other.z) 148 | else: 149 | return NotImplemented 150 | 151 | def __radd__(self, other): 152 | return self.__add__(other) 153 | 154 | def __iadd__(self, other): 155 | if isinstance(other, tuple): 156 | self.x += other[0] 157 | self.y += other[1] 158 | self.z += other[2] 159 | elif isinstance(other, Vector3D): 160 | self.x += other.x 161 | self.y += other.y 162 | self.z += other.z 163 | else: 164 | return NotImplemented 165 | 166 | return self 167 | 168 | def __sub__(self, other): 169 | if isinstance(other, tuple): 170 | return Vector3D(self.x - other[0], self.y - other[1], self.z - other[2]) 171 | elif isinstance(other, Vector3D): 172 | return Vector3D(self.x - other.x, self.y - other.y, self.z - other.z) 173 | else: 174 | return NotImplemented 175 | 176 | def __rsub__(self, other): 177 | return self.__sub__(other) 178 | 179 | def __isub__(self, other): 180 | if isinstance(other, tuple): 181 | self.x -= other[0] 182 | self.y -= other[1] 183 | self.z -= other[2] 184 | elif isinstance(other, Vector3D): 185 | self.x -= other.x 186 | self.y -= other.y 187 | self.z -= other.z 188 | else: 189 | return NotImplemented 190 | 191 | return self 192 | 193 | def __mul__(self, other): 194 | if isinstance(other, (int, float)): 195 | return Vector3D(self.x * other, self.y * other, self.z * other) 196 | else: 197 | return NotImplemented 198 | 199 | def __rmul__(self, other): 200 | return self.__mul__(other) 201 | 202 | def __imul__(self, other): 203 | if isinstance(other, (int, float)): 204 | self.x *= other 205 | self.y *= other 206 | self.z *= other 207 | else: 208 | return NotImplemented 209 | 210 | return self 211 | 212 | def __truediv__(self, other): 213 | if isinstance(other, (int, float)): 214 | return Vector3D(self.x / other, self.y / other, self.z / other) 215 | else: 216 | return NotImplemented 217 | 218 | def __rtruediv__(self, other): 219 | return self.__truediv__(other) 220 | 221 | def __itruediv__(self, other): 222 | if isinstance(other, (int, float)): 223 | self.x /= other 224 | self.y /= other 225 | self.z /= other 226 | else: 227 | return NotImplemented 228 | 229 | return self 230 | 231 | def normalize(self) -> None: 232 | """ 233 | The method normalizes this vector and displays the unit vector. 234 | """ 235 | 236 | magnitude = math.sqrt(self.x**2 + self.y**2 + self.z**2) 237 | self.x = self.x / abs(magnitude) 238 | self.y = self.y / abs(magnitude) 239 | self.z = self.z / abs(magnitude) 240 | 241 | def from_tuple( 242 | self, value: tuple[int, int, int] | tuple[float, float, float] 243 | ) -> None: 244 | """ 245 | Setting vector values from tuple 246 | Args: 247 | value (tuple): A value that allows you to get values for a vector 248 | """ 249 | 250 | self.x, self.y, self.z = value 251 | 252 | def get_tuple(self) -> tuple[int, int, int]: 253 | """ 254 | Get vector values (int) 255 | Returns: 256 | tuple[int, int, int]: x, y and z values 257 | """ 258 | 259 | return int(self.x), int(self.y), int(self.z) 260 | 261 | def get_tuplef(self) -> tuple[float, float, float]: 262 | """ 263 | Get vector values (float) 264 | Returns: 265 | tuple[float, float, float]: x, y and z values 266 | """ 267 | 268 | return float(self.x), float(self.y), float(self.z) 269 | -------------------------------------------------------------------------------- /src/fusionengine/engine/window.py: -------------------------------------------------------------------------------- 1 | from fusionengine.engine.debug import DEBUGIMAGE 2 | import fusionengine.fusiongl as gl 3 | 4 | import pygame as pg 5 | from pygame.locals import DOUBLEBUF, OPENGL 6 | 7 | 8 | class Window: 9 | def __init__(self, title: str, width: int, height: int) -> None: 10 | """ 11 | Creates a a base window for your game. This is the main window you will use for your application. 12 | 13 | Args: 14 | title (str): The title of your window 15 | width (int): The width of your window 16 | height (int): The height of your window 17 | """ 18 | try: 19 | pg.init() 20 | 21 | except Exception: 22 | print("Error: Can't initialize pygame.") 23 | 24 | self._running = False 25 | self._fps = 60 26 | self._quittable = True 27 | self._clock = pg.time.Clock() 28 | 29 | self._fullscreen = False 30 | self._screensafer = False 31 | 32 | self.title = title 33 | self.width = width 34 | self.height = height 35 | 36 | try: 37 | self.window = pg.display.set_mode((width, height), DOUBLEBUF | OPENGL) 38 | pg.display.set_caption(title) 39 | 40 | program_icon = pg.image.load(DEBUGIMAGE) 41 | pg.display.set_icon(program_icon) 42 | 43 | self._running = True 44 | 45 | except Exception: 46 | print("Error: Can't create a window.") 47 | 48 | try: 49 | gl.Ortho(0, width, height, 0, -1, 1) 50 | 51 | gl.Enable(gl.BLEND) 52 | gl.Enable(gl.TEXTURE_2D) 53 | 54 | gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA) 55 | 56 | except Exception: 57 | print("Error: Can't setup OpenGL.") 58 | 59 | def change_icon(self, image_path: str) -> None: 60 | """ 61 | Changes icon of the window. 62 | 63 | Args: 64 | Icon_Path (str): Path to your icon 65 | 66 | """ 67 | 68 | programIcon = pg.image.load(image_path) 69 | pg.display.set_icon(programIcon) 70 | 71 | def loop(self, your_loop) -> None: 72 | """ 73 | A while loop decorator function. The main way to start a main loop. 74 | 75 | Args: 76 | your_loop (function): Your main loop function 77 | """ 78 | while self.running(): 79 | your_loop() 80 | 81 | def running(self) -> bool: 82 | """ 83 | Returns if the window is running. Used for the main loop. 84 | 85 | Returns: 86 | bool: returns true if the window is running else false 87 | """ 88 | self._refresh() 89 | return self._running 90 | 91 | def set_fps(self, fps: int) -> None: 92 | """ 93 | Sets the desired frames per second for the game loop. 94 | 95 | Args: 96 | fps (int): The desired frames per second 97 | """ 98 | self._fps = fps 99 | 100 | def get_fps(self) -> int: 101 | """ 102 | Returns the current desired frames per second for the game 103 | 104 | Returns: 105 | int: The current desired FPS 106 | """ 107 | 108 | return self._fps 109 | 110 | def toggle_fullscreen(self) -> None: 111 | """ 112 | Toggles fullscreen mode. 113 | """ 114 | self._fullscreen = not self._fullscreen 115 | 116 | pg.display.toggle_fullscreen() 117 | 118 | def is_fullscreen(self) -> bool: 119 | """ 120 | Returns if the window is in fullscreen mode. 121 | 122 | Returns: 123 | bool: True if fullscreen else false 124 | """ 125 | return self._fullscreen 126 | 127 | def get_screensafer_allowed(self) -> bool: 128 | """ 129 | Returns if the window is in screensafer mode. 130 | 131 | Returns: 132 | bool: True if screensafer else false 133 | """ 134 | return pg.display.get_allow_screensaver() 135 | 136 | def toggle_screensafer_allowed(self) -> None: 137 | """ 138 | Toggles screensafer mode. 139 | """ 140 | self._screensafer = not self._screensafer 141 | 142 | pg.display.set_allow_screensaver(self._screensafer) 143 | 144 | def get_vsync_enabled(self) -> bool: 145 | """ 146 | Returns if the window is in vsync mode. 147 | 148 | Returns: 149 | bool: True if vsync else false 150 | """ 151 | return pg.display.is_vsync() 152 | 153 | def get_screen_refresh_rate(self) -> int: 154 | """ 155 | Returns the screen refresh rate. 156 | 157 | Returns: 158 | int: The screen refresh rate 159 | """ 160 | return pg.display.get_current_refresh_rate() 161 | 162 | def get_display_amount(self) -> int: 163 | """ 164 | Returns the amount of displays. 165 | 166 | Returns: 167 | int: The amount of displays 168 | """ 169 | return pg.display.get_num_displays() 170 | 171 | def get_active(self) -> bool: 172 | """ 173 | Returns if the window is active. 174 | 175 | Returns: 176 | bool: True if active else false 177 | """ 178 | return pg.display.get_active() 179 | 180 | def quit(self) -> None: 181 | """ 182 | Quits the window. Specifically, stops and deletes window. 183 | """ 184 | self._running = False 185 | 186 | def toggle_quittable(self) -> None: 187 | """ 188 | Toggles whether the window is quittable. 189 | """ 190 | self._quittable = not self._quittable 191 | 192 | def _refresh(self) -> None: 193 | """ 194 | Does all things for refreshing window. (Do not use!) 195 | """ 196 | 197 | self.DELTATIME = self._clock.tick(self._fps) 198 | 199 | for event in pg.event.get(): 200 | if event.type == pg.QUIT and self._quittable: 201 | self.quit() 202 | 203 | pg.display.flip() 204 | pg.time.wait(10) 205 | 206 | gl.Clear(gl.DEPTH_BUFFER_BIT) 207 | gl.Clear(gl.COLOR_BUFFER_BIT) 208 | -------------------------------------------------------------------------------- /src/fusionengine/examples/example1.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("Example: 1", 600, 600) 4 | image = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600) 5 | 6 | 7 | @window.loop 8 | def loop(): 9 | image.draw() 10 | -------------------------------------------------------------------------------- /src/fusionengine/examples/example2.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("Example: 2", 800, 600) 4 | 5 | 6 | @window.loop 7 | def loop(): 8 | fusion.set_background_color(fusion.VIOLET) 9 | fusion.draw_rect(100, 100, 400, 400, fusion.BLUE) 10 | 11 | if fusion.Key(fusion.KEY_a).key_down(): 12 | print("Key A pressed") 13 | -------------------------------------------------------------------------------- /src/fusionengine/examples/example3.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("Example: 3", 800, 600) 4 | 5 | player = fusion.Node(window, 50, 50, 50, 50) 6 | 7 | SPEED = 10 8 | 9 | 10 | @window.loop 11 | def loop(): 12 | fusion.set_background_color(fusion.WHITE) 13 | 14 | player.load_rect(fusion.AQUA) 15 | 16 | if fusion.Key(fusion.KEY_UP).key_down() or fusion.Key(fusion.KEY_W).key_down(): 17 | player.y = player.y - SPEED 18 | 19 | elif fusion.Key(fusion.KEY_DOWN).key_down() or fusion.Key(fusion.KEY_S).key_down(): 20 | player.y = player.y + SPEED 21 | 22 | elif fusion.Key(fusion.KEY_RIGHT).key_down() or fusion.Key(fusion.KEY_D).key_down(): 23 | player.x = player.x + SPEED 24 | 25 | elif fusion.Key(fusion.KEY_LEFT).key_down() or fusion.Key(fusion.KEY_A).key_down(): 26 | player.x = player.x - SPEED 27 | 28 | player.update() 29 | -------------------------------------------------------------------------------- /src/fusionengine/examples/example4.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("Example: 4", 800, 600) 4 | 5 | 6 | @window.loop 7 | def loop(): 8 | pass 9 | -------------------------------------------------------------------------------- /src/fusionengine/examples/example5.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | 4 | class Example(fusion.SceneManager): 5 | def __init__(self): 6 | self.window = fusion.Window("Example: 1", 600, 600) 7 | self.init(self.window) 8 | 9 | self.image = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600) 10 | 11 | self.add_scene(fusion.Scene("image", self.draw_i)) 12 | self.add_scene(fusion.Scene("rect", self.draw_r)) 13 | 14 | self.loop() 15 | 16 | def draw_i(self): 17 | self.image.draw() 18 | 19 | def draw_r(self): 20 | fusion.draw_rect(0, 0, 50, 50, fusion.RED) 21 | 22 | def loop(self): 23 | while self.window.running(): 24 | self.window.set_fps(60) 25 | self.start() 26 | 27 | 28 | Example() 29 | -------------------------------------------------------------------------------- /src/fusionengine/external/fe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/src/fusionengine/external/fe.png -------------------------------------------------------------------------------- /src/fusionengine/external/font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fusionengine-org/fusion/9c30a1ffa1cd9e63dc32dd332a7f27c8d032f5a4/src/fusionengine/external/font.ttf -------------------------------------------------------------------------------- /src/fusionengine/fusiongl/__init__.py: -------------------------------------------------------------------------------- 1 | __author__ = "Fusion Engine Team" 2 | __version__ = "1.0.1" 3 | 4 | from fusionengine.fusiongl.binding import * 5 | -------------------------------------------------------------------------------- /src/fusionengine/fusiongl/libgl.py: -------------------------------------------------------------------------------- 1 | import ctypes 2 | import platform 3 | import os 4 | 5 | from ctypes.util import find_library 6 | from warnings import warn 7 | 8 | system_platform = platform.system().lower() 9 | if system_platform == "windows": 10 | library_name = "opengl32" 11 | elif system_platform == "darwin": 12 | library_name = "OpenGL" 13 | elif system_platform == "linux": 14 | library_name = "GL" 15 | else: 16 | if os.environ.get("FUSION_HIDE_GL_PROMPT") is None: 17 | warn( 18 | "Your platform could not be resolved. Defaulting to OpenGL as GL. Rever to the documentation to learn about how to remove this warning.", 19 | category=None, 20 | stacklevel=1, 21 | ) 22 | library_name = "GL" 23 | 24 | opengl_lib_path = find_library(library_name) 25 | if opengl_lib_path is None: 26 | raise OSError(f"Could not find the OpenGL library for platform {system_platform}") 27 | 28 | gl = ctypes.CDLL(opengl_lib_path) 29 | -------------------------------------------------------------------------------- /tests/anim.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("Example: 1", 600, 600) 4 | image1 = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600) 5 | image2 = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 400, 400) 6 | 7 | anim = fusion.Animation(window, (image1, image2), 3) 8 | 9 | 10 | @window.loop 11 | def loop(): 12 | anim.play() 13 | -------------------------------------------------------------------------------- /tests/codon_test.py: -------------------------------------------------------------------------------- 1 | from python import fusionengine as fusion 2 | 3 | window = fusion.window.Window("Example: 1", 600, 600) 4 | image = fusion.image.Image(fusion.debug.DEBUGIMAGE, 0, 0, 600, 600) 5 | 6 | while window.running(): 7 | image.draw() 8 | -------------------------------------------------------------------------------- /tests/encode.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import fusionengine 3 | 4 | 5 | def image_to_base64(image_path): 6 | with open(image_path, "rb") as image_file: 7 | encoded_image = base64.b64encode(image_file.read()) 8 | return encoded_image.decode("utf-8") 9 | 10 | 11 | base64_image = image_to_base64(fusionengine.DEBUGIMAGE) 12 | 13 | print(base64_image) 14 | -------------------------------------------------------------------------------- /tests/gltest.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("GL-Test", 800, 600) 4 | # my_rect = fusion.Rect(10, 10, 100, 100, fusion.BLACK) 5 | # my_rect1 = fusion.Rect(200, 10, 100, 100, fusion.LIME) 6 | # my_rect2 = fusion.Rect(10, 200, 100, 100, fusion.VIOLET) 7 | 8 | 9 | # my_text = fusion.Text("Hello World!", 40, 40, fusion.DEBUGFONT, 40, fusion.WHITE) 10 | 11 | my_button = fusion.Button(15, 15, 200, 200, 20, "Test") 12 | 13 | 14 | @window.loop 15 | def loop(): 16 | fusion.set_background_color(fusion.BLUE) 17 | # my_rect.draw() 18 | # my_rect1.draw() 19 | # my_rect2.draw() 20 | # fusion.draw_rect(40, 40, 500, 500, fusion.BLUE) 21 | my_button.draw() 22 | 23 | if my_button.is_pressed(): 24 | print("Test pressed") 25 | # my_text.draw() 26 | -------------------------------------------------------------------------------- /tests/opengl.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | from pygame.locals import * 3 | from OpenGL.GL import * 4 | from OpenGL.GLUT import * 5 | from OpenGL.GLU import * 6 | from fusionengine import DEBUGIMAGE 7 | 8 | 9 | def draw_image(texture): 10 | glBindTexture(GL_TEXTURE_2D, texture) 11 | 12 | glBegin(GL_QUADS) 13 | glTexCoord2f(0, 0) 14 | glVertex2f(-0.5, -0.5) 15 | 16 | glTexCoord2f(1, 0) 17 | glVertex2f(0.5, -0.5) 18 | 19 | glTexCoord2f(1, 1) 20 | glVertex2f(0.5, 0.5) 21 | 22 | glTexCoord2f(0, 1) 23 | glVertex2f(-0.5, 0.5) 24 | glEnd() 25 | 26 | 27 | def load_texture(filename): 28 | image_surface = pygame.image.load(filename) 29 | image_data = pygame.image.tostring(image_surface, "RGB", 1) 30 | width, height = image_surface.get_width(), image_surface.get_height() 31 | 32 | texture = glGenTextures(1) 33 | glBindTexture(GL_TEXTURE_2D, texture) 34 | glTexImage2D( 35 | GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image_data 36 | ) 37 | 38 | # Set texture parameters (optional) 39 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) 40 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) 41 | 42 | return texture 43 | 44 | 45 | def main(): 46 | pygame.init() 47 | display = (800, 600) 48 | pygame.display.set_mode(display, DOUBLEBUF | OPENGL) 49 | 50 | gluOrtho2D(-1, 1, -1, 1) 51 | 52 | image_texture = load_texture(DEBUGIMAGE) 53 | 54 | while True: 55 | for event in pygame.event.get(): 56 | if event.type == pygame.QUIT: 57 | pygame.quit() 58 | quit() 59 | 60 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) 61 | 62 | glColor3f(1.0, 1.0, 1.0) 63 | draw_image(image_texture) 64 | 65 | pygame.display.flip() 66 | pygame.time.wait(10) 67 | 68 | 69 | if __name__ == "__main__": 70 | main() 71 | -------------------------------------------------------------------------------- /tests/performance.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | import time 3 | 4 | checked_time = False 5 | start_time = time.time() 6 | 7 | window = fusion.Window("test", 600, 600) 8 | 9 | 10 | if fusion.__version__ == "5.1.0" or fusion.__version__ == "5.0.0": 11 | image = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600) 12 | 13 | else: 14 | image = fusion.Image(window, fusion.DEBUGIMAGE, 0, 0, 600, 600) 15 | 16 | 17 | @window.loop 18 | def loop(): 19 | global checked_time 20 | image.draw() 21 | 22 | if not checked_time: 23 | end_time = time.time() 24 | elapsed_time = end_time - start_time 25 | 26 | print(elapsed_time) 27 | checked_time = True 28 | -------------------------------------------------------------------------------- /tests/pygame_test.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | 3 | pygame.init() 4 | 5 | screen = pygame.display.set_mode((500, 500)) 6 | 7 | clock = pygame.time.Clock() 8 | 9 | running = True 10 | while running: 11 | for event in pygame.event.get(): 12 | if event.type == pygame.QUIT: 13 | running = False 14 | 15 | clock.tick(60) 16 | pygame.display.flip() 17 | 18 | pygame.quit() 19 | -------------------------------------------------------------------------------- /tests/spritesheet.py: -------------------------------------------------------------------------------- 1 | import fusionengine as fusion 2 | 3 | window = fusion.Window("Spritesheet test", 200, 200) 4 | window.set_fps(30) 5 | main_image = fusion.Image(fusion.DEBUGIMAGE, 200, 200, 50, 50) 6 | 7 | spr = fusion.SpriteSheet(fusion.DEBUGIMAGE, 100, 100) 8 | spr.frame_size(100, 100) 9 | spr.frame_pos(50, 50) 10 | 11 | anim = fusion.Animation(window, spr, 0.1) 12 | 13 | 14 | @window.loop 15 | def loop(): 16 | anim.play() 17 | -------------------------------------------------------------------------------- /tests/storage_test.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from fusionengine import JsonStorage 4 | 5 | 6 | def test_jsonstorage(cleanup): 7 | my_db = JsonStorage("my_db.json") 8 | 9 | # Insert 10 | print("------------------- INSERT -------------------") 11 | my_db.insert({"first_name": "john", "last_name": "wick", "gold": 50}) 12 | my_db.insert({"first_name": "alexander", "last_name": "wick", "gold": 20}) 13 | 14 | print(my_db.storage) 15 | print("------------------- INSERT/ -------------------") 16 | 17 | # Read 18 | print("------------------- READ -------------------") 19 | print(my_db.search({"last_name": "wick"})) 20 | print(my_db.search({"last_name": "wick"}, get_index=True)) 21 | 22 | if ( 23 | search_result := my_db.search( 24 | {"first_name": "alexander", "last_name": "wick"}, True, True 25 | ) 26 | ) != None: 27 | alex, alex_index = search_result 28 | if search_result := my_db.search({"first_name": "john"}, True, True): 29 | _, john_index = search_result 30 | print("------------------- READ/ -------------------") 31 | 32 | # Update 33 | print("------------------- UPDATE -------------------") 34 | alex["gold"] += 20 35 | my_db.update(alex_index, alex) 36 | print(my_db.storage) 37 | print("------------------- UPDATE/ -------------------") 38 | 39 | # Delete 40 | print("------------------- DELETE -------------------") 41 | my_db.delete(john_index) 42 | print(my_db.storage) 43 | print("------------------- DELETE/ -------------------") 44 | 45 | # Saving to disk 46 | print("------------------- SAVE -------------------") 47 | print(my_db.save()) 48 | print("------------------- SAVE/ -------------------") 49 | if cleanup: 50 | os.remove(my_db.file_path) 51 | 52 | 53 | if __name__ == "__main__": 54 | test_jsonstorage(cleanup=True) 55 | --------------------------------------------------------------------------------