Skip to content

Commit

Permalink
Giant updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkauzh committed Feb 7, 2024
1 parent 2949592 commit 6aa793e
Show file tree
Hide file tree
Showing 23 changed files with 57 additions and 245 deletions.
6 changes: 3 additions & 3 deletions docs/wiki/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ If you want to draw a animation, then you can do it this way
### Loading the animations
To load the animation, run
```python
my_anim = fusion.Animation(your_window: Window, your_images: tuple | Spritesheet)
my_anim = fusion.Animation(your_window: Window, your_images: tuple | Spritesheet, frames: int)
```

### Drawing animation
To draw it then, run:
```python
my_anim.draw(frames: int)
my_anim.draw()
```
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.

Expand All @@ -35,4 +35,4 @@ Then, set the coordinates:
```python
spr.frame_pos(50, 50)
```
This will set the X-axis and Y-axis to 50.
This will set the X-axis and Y-axis to 50.
4 changes: 2 additions & 2 deletions docs/wiki/external.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# External tools

## Using OpenGL
Fusion is build on its own custom OpenGL binding using CTypes (fusionengine.backend.gl). 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.gl`
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`

If you want to use PyOpenGL, you should be able to do that without any problems.

Expand All @@ -25,4 +25,4 @@ You need to modify our loop to support codon, so you need to change it to this:
while your_window.running():
... # Your own loop thing
```
You may reconise this type of while loop from the main wiki as your second option.
You may reconise this type of while loop from the main wiki as your second option.
10 changes: 7 additions & 3 deletions src/fusionengine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
__author__ = "Dimkauzh"
__author__ = "Fusion Engine Org"
__version__ = "5.2.0"

import sys
import os
import warnings
import platform

os.environ["PYGAME_HIDE_SUPPORT_PROMPT"] = "hide"

Expand All @@ -24,7 +26,6 @@

# Node
from fusionengine.engine.node import *
from fusionengine.engine.physics import *

# Storage
from fusionengine.engine.storage import *
Expand All @@ -51,7 +52,7 @@
from fusionengine.engine.spritesheets import *

# GL
import fusionengine.backend.gl as gl
import fusionengine.fusiongl as gl

import pygame as pg

Expand All @@ -65,3 +66,6 @@
print(
"Welcome to Fusion Engine! Check out our website at https://fusion-engine.tech/"
)

if platform.system().lower() == "linux":
warnings.filterwarnings("ignore", message="PyGame seems to be running through X11 on top of wayland")
2 changes: 1 addition & 1 deletion src/fusionengine/engine/draw.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fusionengine.engine.window import Window
from fusionengine.engine.color import Color
import fusionengine.backend.gl as gl
import fusionengine.fusiongl as gl

import pygame as pg

Expand Down
2 changes: 1 addition & 1 deletion src/fusionengine/engine/image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fusionengine.backend.gl as gl
import fusionengine.fusiongl as gl

import pygame as pg

Expand Down
1 change: 0 additions & 1 deletion src/fusionengine/engine/node.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing_extensions import Doc
from fusionengine.engine.window import Window
from fusionengine.engine.shape import Rect
from fusionengine.engine.image import Image
Expand Down
1 change: 0 additions & 1 deletion src/fusionengine/engine/spritesheets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from fusionengine.engine.image import Image
import pygame as pg


class SpriteSheet:
Expand Down
2 changes: 1 addition & 1 deletion src/fusionengine/engine/ui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from fusionengine.engine.shape import Rect
from fusionengine.engine.color import Color, WHITE, GRAY
import fusionengine.backend.gl as gl
import fusionengine.fusiongl as gl
from fusionengine.engine.debug import DEBUGFONT

import pygame as pg
Expand Down
2 changes: 1 addition & 1 deletion src/fusionengine/engine/window.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from fusionengine.engine.debug import DEBUGIMAGE
import fusionengine.backend.gl as gl
import fusionengine.fusiongl as gl

import pygame as pg
from pygame.locals import DOUBLEBUF, OPENGL
Expand Down
4 changes: 4 additions & 0 deletions src/fusionengine/fusiongl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__author__ = "Fusion Engine Org"
__version__ = "1.0.1"

from fusionengine.fusiongl.binding import *
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
__author__ = "Fusion Engine Team"
__version__ = "1.0.1"

import ctypes
import platform
import os

from ctypes.util import find_library
from warnings import warn

system_platform = platform.system().lower()
if system_platform == "windows":
library_name = "opengl32"
elif system_platform == "darwin":
library_name = "OpenGL"
elif system_platform == "linux":
library_name = "GL"
else:
if os.environ.get("FUSION_HIDE_GL_PROMPT") is None:
warn(
"Your platform could not be resolved. Defaulting to OpenGL as GL. Rever to the documentation to learn about how to remove this warning.",
category=None,
stacklevel=1,
)
library_name = "GL"

opengl_lib_path = find_library(library_name)
if opengl_lib_path is None:
raise OSError(f"Could not find the OpenGL library for platform {system_platform}")

gl = ctypes.CDLL(opengl_lib_path)
from fusionengine.fusiongl.libgl import gl

LINES = 0x0001
QUADS = 0x0007
Expand Down
28 changes: 28 additions & 0 deletions src/fusionengine/fusiongl/libgl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import ctypes
import platform
import os

from ctypes.util import find_library
from warnings import warn

system_platform = platform.system().lower()
if system_platform == "windows":
library_name = "opengl32"
elif system_platform == "darwin":
library_name = "OpenGL"
elif system_platform == "linux":
library_name = "GL"
else:
if os.environ.get("FUSION_HIDE_GL_PROMPT") is None:
warn(
"Your platform could not be resolved. Defaulting to OpenGL as GL. Rever to the documentation to learn about how to remove this warning.",
category=None,
stacklevel=1,
)
library_name = "GL"

opengl_lib_path = find_library(library_name)
if opengl_lib_path is None:
raise OSError(f"Could not find the OpenGL library for platform {system_platform}")

gl = ctypes.CDLL(opengl_lib_path)
6 changes: 3 additions & 3 deletions tests/anim.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fusionengine as fusion

window = fusion.Window("Example: 1", 600, 600)
image1 = fusion.Image(window, fusion.DEBUGIMAGE, 0, 0, 600, 600)
image2 = fusion.Image(window, fusion.DEBUGIMAGE, 0, 0, 400, 400)
image1 = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 600, 600)
image2 = fusion.Image(fusion.DEBUGIMAGE, 0, 0, 400, 400)

anim = fusion.Animation(window, [image1, image2], 3)
anim = fusion.Animation(window, (image1, image2), 3)


@window.loop
Expand Down
2 changes: 1 addition & 1 deletion tests/codon_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from python import fusionengine as fusion

window = fusion.window.Window("Example: 1", 600, 600)
image = fusion.image.Image(window, fusion.debug.DEBUGIMAGE, 0, 0, 600, 600)
image = fusion.image.Image(fusion.debug.DEBUGIMAGE, 0, 0, 600, 600)

while window.running():
image.draw()
13 changes: 0 additions & 13 deletions tests/drawing_test.py

This file was deleted.

5 changes: 2 additions & 3 deletions tests/encode.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import base64

import fusionengine

def image_to_base64(image_path):
with open(image_path, "rb") as image_file:
encoded_image = base64.b64encode(image_file.read())
return encoded_image.decode("utf-8")


image_path = "src/fusionengine/debugfiles/fe.png"
base64_image = image_to_base64(image_path)
base64_image = image_to_base64(fusionengine.DEBUGIMAGE)

print(base64_image)
Empty file removed tests/oop_check.py
Empty file.
30 changes: 0 additions & 30 deletions tests/py_gui_test.py

This file was deleted.

73 changes: 0 additions & 73 deletions tests/pygame_opengl.py

This file was deleted.

Loading

0 comments on commit 6aa793e

Please sign in to comment.