diff --git a/docs/v5/assets/gifs/example.gif b/docs/assets/gifs/example.gif similarity index 100% rename from docs/v5/assets/gifs/example.gif rename to docs/assets/gifs/example.gif diff --git a/docs/v5/assets/logo/fe.png b/docs/assets/logo/fe.png similarity index 100% rename from docs/v5/assets/logo/fe.png rename to docs/assets/logo/fe.png diff --git a/docs/v5/assets/logo/fusion-banner.png b/docs/assets/logo/fusion-banner.png similarity index 100% rename from docs/v5/assets/logo/fusion-banner.png rename to docs/assets/logo/fusion-banner.png diff --git a/docs/v5/assets/tutorials/result.png b/docs/assets/tutorials/result.png similarity index 100% rename from docs/v5/assets/tutorials/result.png rename to docs/assets/tutorials/result.png diff --git a/docs/changelog/v5.md b/docs/changelog/v5.md index 9c8b402d..98e894e5 100644 --- a/docs/changelog/v5.md +++ b/docs/changelog/v5.md @@ -1,6 +1,34 @@ # Version 5 Todo/Changelog ## V5 -- [ ] Docs cleanup -- [ ] New color system -- [ ] Optimised font drawing \ No newline at end of file +- [x] Docs cleanup +- [x] New color system +- [x] Optimised font drawing +- [x] OpenGL rendering + +## V5.1 +- [x] New Window features + - [x] Full Screen + - [x] is_fullscreen + - [x] toggle_fullscreen + - [x] Screen Safer + - [x] get_screensafer_allowed + - [x] toggle_screensafer_allowed + - [x] get_vsync_enabled + - [x] get_screen_refresh_rate + - [x] get_display_amount + - [x] get_active + +- [x] SpriteSheet class + - [x] __init__(Image, width, height) + - [x] frames (variable with all your extracted frames) + +- [x] Image system updates + - [x] Added crop() function + - [x] Support for Pillow (PIL) images + +- [x] Animation system + - [x] Fixing Animation system + - [x] Added support for SpriteSheets + - [x] Draw function gets frames argument + diff --git a/docs/get-started.md b/docs/get-started.md index 34032418..07ee8e27 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -25,5 +25,5 @@ And your done! ## Next step After this, you can head into the section tutorials or wiki, to learn more about fusion engine. Have fun! - - [Tutorials](v5/tutorials/setup.md) - - [Wiki](v5/wiki/window.md) \ No newline at end of file + - [Tutorials](tutorials/setup.md) + - [Wiki](wiki/window.md) \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 039ca641..2d0582d3 100644 --- a/docs/index.md +++ b/docs/index.md @@ -23,16 +23,18 @@ hide: 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, rendering graphics, and handling user input. It is and engine to create games fast and easy! +## 🔨Table of contents + + - [Get started](get-started.md) + - [Tutorials](tutorials/setup.md) + - [Wiki](wiki/window.md) + - [Legacy docs](legacy/index.md) + ## 👋 Welcome Welcome to fusion engine documentation! We have seperated the documentation in two parts: wiki and tutorial. 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! 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 -## Quick links - - [Get started](get-started.md) - - [Tutorials](v5/tutorials/setup.md) - - [Wiki](v5/wiki/window.md) - - [Legacy docs](legacy/index.md) diff --git a/docs/v5/tutorials/basics.md b/docs/tutorials/basics.md similarity index 100% rename from docs/v5/tutorials/basics.md rename to docs/tutorials/basics.md diff --git a/docs/v5/tutorials/character.md b/docs/tutorials/character.md similarity index 100% rename from docs/v5/tutorials/character.md rename to docs/tutorials/character.md diff --git a/docs/v5/tutorials/setup.md b/docs/tutorials/setup.md similarity index 100% rename from docs/v5/tutorials/setup.md rename to docs/tutorials/setup.md diff --git a/docs/v5/wiki/window.md b/docs/v5/wiki/window.md deleted file mode 100644 index c52a49e8..00000000 --- a/docs/v5/wiki/window.md +++ /dev/null @@ -1,65 +0,0 @@ -# Windowing - -## Create window - -To create a window were thing are draw, then you need to use this: - -```python -your_window = fusion.Window("Example", 800, 600) -``` - -## Start loop - -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: - -Choice 1: - -```python -@your_window.loop -def loop(): - ... # Your own loop things -``` - -Choice 2: - -```python -while your_window.running(): - ... # Your own loop thing - -``` - -There is basically no difference, they all are doing the same thing, you use what you prefer. In our examples we use choice 1. - - -## Set FPS -To set the framerate of your window, you use this: - -```python -your_window.set_fps(60) - -``` - -## Window icon -So you want to change the icon of your window? Well, its easy: - -```python -your_window.change_icon("path_to_icon.png") -``` - -## DeltaTime - -if you want to access delta time, you use this: - -```python -your_window.DELTATIME -``` - -## Quit - -The quitting of the engine is done automaticly for you, so you dont have to worry about it. - -### Force to quit -If you want to force quit due to some reason, its pretty easy: -```python -your_window.force_quit() -``` diff --git a/docs/wiki/animation.md b/docs/wiki/animation.md new file mode 100644 index 00000000..800ea0d4 --- /dev/null +++ b/docs/wiki/animation.md @@ -0,0 +1,38 @@ +# Animations and Spritesheets + +## Animation system (Early stages) +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) +``` + +### Drawing animation +To draw it then, run: +```python +my_anim.draw(frames: int) +``` +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. + +## Spritesheets +### Creating spritesheets +First, create your spritesheet. You can do it this way: +```python +spr = fusion.SpriteSheet(fusion.DEBUGIMAGE, 100, 100) +``` +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 down-left to down-right. Then it goes a row higher and cuts futher. + +Then, set the size of each image and then set the coordinates. (This is required or else they will be automatically set to 0) +Set the size: +```python +spr.frame_size(60, 60) +``` + +This will set the size of each image 60x60 pixels. +Then, set the coordinates: +```python +spr.frame_pos(50, 50) +``` +This will set the X-axis and Y-axis to 50. \ No newline at end of file diff --git a/docs/v5/wiki/color.md b/docs/wiki/color.md similarity index 100% rename from docs/v5/wiki/color.md rename to docs/wiki/color.md diff --git a/docs/v5/wiki/events-keys.md b/docs/wiki/events-keys.md similarity index 100% rename from docs/v5/wiki/events-keys.md rename to docs/wiki/events-keys.md diff --git a/docs/v5/wiki/external.md b/docs/wiki/external.md similarity index 100% rename from docs/v5/wiki/external.md rename to docs/wiki/external.md diff --git a/docs/v5/wiki/extra.md b/docs/wiki/extra.md similarity index 100% rename from docs/v5/wiki/extra.md rename to docs/wiki/extra.md diff --git a/docs/v5/wiki/math.md b/docs/wiki/math.md similarity index 100% rename from docs/v5/wiki/math.md rename to docs/wiki/math.md diff --git a/docs/v5/wiki/music.md b/docs/wiki/music.md similarity index 100% rename from docs/v5/wiki/music.md rename to docs/wiki/music.md diff --git a/docs/v5/wiki/rendering.md b/docs/wiki/rendering.md similarity index 90% rename from docs/v5/wiki/rendering.md rename to docs/wiki/rendering.md index bd1a0e19..ebc0dc46 100644 --- a/docs/v5/wiki/rendering.md +++ b/docs/wiki/rendering.md @@ -62,7 +62,7 @@ You first need to create a variable with your image and image data: your_image = fusion.Image(window, fusion.DEBUGIMAGE, 100, 100, 400, 400) ``` -main.DEBUGIMAGE is an image that is included with the engine, so you can use it freely. +`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 Pillow (PIL) image. Then you need to render it (In the best situation this will happen in your loop): ```python diff --git a/docs/v5/wiki/scene.md b/docs/wiki/scene.md similarity index 81% rename from docs/v5/wiki/scene.md rename to docs/wiki/scene.md index 60d44e6e..2b32abb3 100644 --- a/docs/v5/wiki/scene.md +++ b/docs/wiki/scene.md @@ -1,4 +1,4 @@ -# Scenes, Entities and animations +# Scenes and Entities ## Scene manager See in [this example](https://github.com/dimkauzh/fusion-engine/blob/main/examples/example5.py) how to use the scene manager. @@ -67,17 +67,3 @@ To draw current frame, use this function your_entity.draw_animation() ``` -## Animation system (Early stages) -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, your_images: tuple, fps: int) -``` - -### Drawing animation -To draw it then, run: -```python -my_anim.draw() -``` diff --git a/docs/v5/wiki/storage.md b/docs/wiki/storage.md similarity index 100% rename from docs/v5/wiki/storage.md rename to docs/wiki/storage.md diff --git a/docs/v5/wiki/ui.md b/docs/wiki/ui.md similarity index 100% rename from docs/v5/wiki/ui.md rename to docs/wiki/ui.md diff --git a/docs/v5/wiki/v5-moving.md b/docs/wiki/v5-moving.md similarity index 100% rename from docs/v5/wiki/v5-moving.md rename to docs/wiki/v5-moving.md diff --git a/docs/wiki/window.md b/docs/wiki/window.md new file mode 100644 index 00000000..ea3f7ec9 --- /dev/null +++ b/docs/wiki/window.md @@ -0,0 +1,112 @@ +# Windowing + +## Create window + +To create a window were thing are draw, then you need to use this: + +```python +your_window = fusion.Window("Example", 800, 600) +``` + +## Start loop + +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: + +Choice 1: + +```python +@your_window.loop +def loop(): + ... # Your own loop things +``` + +Choice 2: + +```python +while your_window.running(): + ... # Your own loop thing + +``` + +There is basically no difference, they all are doing the same thing, you use what you prefer. In our examples we use choice 1. + + +## Set FPS +To set the framerate of your window, you use this: + +```python +your_window.set_fps(60) + +``` + +## Window icon +So you want to change the icon of your window? Well, its easy: + +```python +your_window.change_icon("path_to_icon.png") +``` + +## DeltaTime + +if you want to access delta time, you use this: + +```python +your_window.DELTATIME +``` + +## Quit + +The quitting of the engine is done automaticly for you, so you dont have to worry about it. + +### Force to quit +If you want to force quit due to some reason, its pretty easy: +```python +your_window.force_quit() +``` + +## Full Screen +If you want to know if the window is full screen then run the following command: +```python +your_var = your_window.is_fullscreen() +``` + +If you want to toggle the fullscreen on your window then run the following command: +```python +your_window.toggle_fullscreen() +``` + +## Screen Safer +If you want to know if screen safer is allowed on the current machine then run the following command: +```python +your_var = your_window.get_screensafer_allowed() +``` + +If you want to toggle the screen safer allowed on the current machine then run the following command: +```python +your_window.toggle_screensafer_allowed() +``` + +## Vsync +If you want to know if VSync in enabled on the current machine then run the following command: +```python +my_var = your_window.get_vsync_enabled() +``` + +## Displays +### Refresh rate +If you want to get the display refresh rate on the current machine then run the following command: +```python +my_var = your_window.get_screen_refresh_rate() +``` + +## Display amount +If you want to get the display amount on the current machine then run the following command: +```python +my_var = your_window.get_display_amount() +``` + +## Active +If you want to get the active state on the current machine then run the following command: +```python +my_var = your_window.get_active() +``` \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 9ad13845..7497e96d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -10,33 +10,34 @@ nav: - Getting Started: 'get-started.md' - Wiki: - - Window with fusion: 'v5/wiki/window.md' - - Rendering with fusion: 'v5/wiki/rendering.md' - - Events and Keys: 'v5/wiki/events-keys.md' - - Color and colortools: 'v5/wiki/color.md' - - Managing sounds and music: 'v5/wiki/music.md' - - Scenes, entities and animations: 'v5/wiki/scene.md' - - Storage system: 'v5/wiki/storage.md' - - UI module: 'v5/wiki/ui.md' - - Math and Vectors: 'v5/wiki/math.md' - - Extra stuff: 'v5/wiki/extra.md' - - External tools: 'v5/wiki/external.md' - - Moving from v4 to v5: 'v5/wiki/v5-moving.md' + - Window with fusion: 'wiki/window.md' + - Rendering with fusion: 'wiki/rendering.md' + - Events and Keys: 'wiki/events-keys.md' + - Color and colortools: 'wiki/color.md' + - Managing sounds and music: 'wiki/music.md' + - Scenes and entities: 'wiki/scene.md' + - Storage system: 'wiki/storage.md' + - Animations and Spritesheets: 'wiki/animation.md' + - UI module: 'wiki/ui.md' + - Math and Vectors: 'wiki/math.md' + - Extra stuff: 'wiki/extra.md' + - External tools: 'wiki/external.md' + - Moving from v4 to v5: 'wiki/v5-moving.md' - Tutorials: - - Setting up Fusion Engine: 'v5/tutorials/setup.md' - - Basics of Fusion Engine: 'v5/tutorials/basics.md' - - Small moving character: 'v5/tutorials/character.md' + - Setting up Fusion Engine: 'tutorials/setup.md' + - Basics of Fusion Engine: 'tutorials/basics.md' + - Small moving character: 'tutorials/character.md' - Changelog: - - v5: 'changelog/v5.md' - - v4: 'changelog/v4.md' - - v3: 'changelog/v3.md' + - V5: 'changelog/v5.md' + - V4: 'changelog/v4.md' + - V3: 'changelog/v3.md' - Legacy: - Start: 'legacy/index.md' - - v3: + - V3: - Wiki: - Main page: 'legacy/v3/wiki/wiki.md' - Keys page: 'legacy/v3/wiki/keys.md' @@ -59,7 +60,7 @@ nav: - Setup: 'legacy/v3/tutorials/setup.md' - Basics: 'legacy/v3/tutorials/basics.md' - - v4: + - V4: - Wiki: - Window with fusion: 'legacy/v4/wiki/window.md' - Rendering with fusion: 'legacy/v4/wiki/rendering.md' @@ -90,8 +91,8 @@ nav: theme: name: material - logo: v5/assets/logo/fe.png - favicon: v5/assets/logo/fe.png + logo: assets/logo/fe.png + favicon: assets/logo/fe.png features: - navigation.path diff --git a/src/fusionengine/__init__.py b/src/fusionengine/__init__.py index f9419f49..c3b3e668 100644 --- a/src/fusionengine/__init__.py +++ b/src/fusionengine/__init__.py @@ -1,5 +1,5 @@ __author__ = "Dimkauzh" -__version__ = "5.0.0" +__version__ = "5.1.0" import sys import os @@ -44,6 +44,7 @@ # Animation from fusionengine.engine.animation import * +from fusionengine.engine.spritesheets import * import pygame as pg diff --git a/src/fusionengine/backend/deprecations.py b/src/fusionengine/backend/deprecations.py index 89eb1621..f9310330 100644 --- a/src/fusionengine/backend/deprecations.py +++ b/src/fusionengine/backend/deprecations.py @@ -16,7 +16,7 @@ def compare_versions(version1: str, version2: str): return 0 -def deprecated(version=None): +def deprecated(version=None, name=None): """ This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted @@ -26,10 +26,15 @@ def deprecated(version=None): def decorator(func): @functools.wraps(func) def new_func(*args, **kwargs): + if name is None: + func_name = "function " + func.__name__ + else: + func_name = name + if version is None or compare_versions(__version__, version) >= 0: warnings.simplefilter("always", DeprecationWarning) warnings.warn( - f"Call to deprecated function {func.__name__}.", + f"Call to deprecated {func_name}.", category=DeprecationWarning, stacklevel=2, ) diff --git a/src/fusionengine/engine/animation.py b/src/fusionengine/engine/animation.py index 37fb64c3..1e747bac 100644 --- a/src/fusionengine/engine/animation.py +++ b/src/fusionengine/engine/animation.py @@ -1,33 +1,44 @@ from fusionengine.engine.window import Window +from fusionengine.engine.spritesheets import SpriteSheet class Animation: - def __init__(self, window: Window, images: tuple, speed: int) -> None: + def __init__(self, window: Window, images: tuple | SpriteSheet) -> None: """ - The class to create a Animation. + The class to create an Animation. Args: window: Window - image: tuple of Images + image (Tuple | Spritesheets): Tuple of Images or a SpriteSheet Speed: Int (FPS) """ self.frame = 0 - self.anim = images + self.prev_frame = 0 + + if isinstance(images, SpriteSheet): + self.frames = images.frames + elif isinstance(images, tuple): + self.frames = images + else: + raise ValueError("Images must be a tuple of Images or a SpriteSheet") - self.speed = speed self.window = window - def draw(self) -> None: + def play(self, speed: float) -> None: """ Draw the animation you made before """ - self.window.set_fps(self.speed) - - if self.frame >= len(self.anim): + if 0 <= int(self.frame) < len(self.frames): + if not ( + isinstance(self.frame, int) + or (isinstance(self.frame, float) and self.frame.is_integer()) + ): + self.frames[int(self.prev_frame)].draw() + else: + self.frames[int(self.frame)].draw() + + self.prev_frame = self.frame + self.frame += speed + + if self.frame >= len(self.frames): self.frame = 0 - - image = self.anim[self.frame] - - image.draw() - - self.frame += 1 diff --git a/src/fusionengine/engine/entity.py b/src/fusionengine/engine/entity.py index 0a5d46ef..1a264eb6 100644 --- a/src/fusionengine/engine/entity.py +++ b/src/fusionengine/engine/entity.py @@ -2,9 +2,11 @@ from fusionengine.engine.image import Image from fusionengine.engine.shape import Rect from fusionengine.engine.color import Color +from fusionengine.backend.deprecations import deprecated class Entity: + @deprecated("5.0.0", "Entity class") def __init__( self, window: Window, diff --git a/src/fusionengine/engine/image.py b/src/fusionengine/engine/image.py index 3b3d2ccc..dc7b662e 100644 --- a/src/fusionengine/engine/image.py +++ b/src/fusionengine/engine/image.py @@ -9,17 +9,17 @@ class Image: def __init__( self, - image_path: str, + image_path: str | Imager.Image, x: int, y: int, width: int, height: int, ) -> None: """ - Opens an image. Can be later rendered with draw_image. + Opens an image. Can be later rendered with draw method. Args: - image_path (str): The path to the image + image_path (str or Pillow Image): The path to the image | Pillow Image x (int): X coordinate of the image y (int): Y coordinate of the image width (int): Width of the image (scaling allowed) @@ -31,7 +31,13 @@ def __init__( self.width = width self.height = height - self.image = Imager.open(image_path) + if isinstance(image_path, str): + self.image = Imager.open(str(image_path)) + elif isinstance(image_path, Imager.Image): + self.image = image_path + else: + raise ValueError("Invalid image_path type") + image_data = self.image.tobytes("raw", "RGBA", 0, -1) self.texture = gl.GenTextures(1) @@ -53,6 +59,27 @@ def __init__( gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) + def crop(self, left: int, right: int, top: int, bottom: int) -> "Image": + """ + Crop the image based on the specified boundaries. + + Args: + left (int): The left boundary of the crop area. + right (int): The right boundary of the crop area. + top (int): The top boundary of the crop area. + bottom (int): The bottom boundary of the crop area. + + Returns: + Image: A new Image object representing the cropped image. + """ + return Image( + self.image.crop((left, right, top, bottom)), + self.x, + self.y, + self.width, + self.height, + ) + def draw(self) -> None: """ Draws your image on the screen. diff --git a/src/fusionengine/engine/spritesheets.py b/src/fusionengine/engine/spritesheets.py new file mode 100644 index 00000000..60e5d12f --- /dev/null +++ b/src/fusionengine/engine/spritesheets.py @@ -0,0 +1,81 @@ +from fusionengine.engine.image import Image +from PIL import Image as Imager + + +class SpriteSheet: + def __init__(self, image_path: str, sprite_width: int, sprite_height: int): + """ + Represents a SpriteSheet containing a grid of frames. + + Args: + image_path (str): The path to the sprite sheet image file. + sprite_width (int): Width of each sprite frame. + sprite_height (int): Height of each sprite frame. + """ + self.sprite_sheet = Imager.open(image_path).convert("RGBA") + self.sprite_width = sprite_width + self.sprite_height = sprite_height + self.frames = self.get_frames() + self.width = 0 + self.height = 0 + + def get_frames(self) -> list: + """ + Extract frames from the sprite sheet. + + Returns: + list: List of Image objects representing individual frames. + """ + frames = [] + columns = self.sprite_sheet.width // self.sprite_width + rows = self.sprite_sheet.height // self.sprite_height + + for row in range(rows): + for col in range(columns): + frame = Image(self.extract_frame(col, row), 0, 0, 0, 0) + frames.append(frame) + + return frames + + def extract_frame(self, col: int, row: int) -> Imager.Image: + """ + Extract a single frame from the sprite sheet. + + Args: + col (int): Column index of the sprite. + row (int): Row index of the sprite. + + Returns: + Imager.Image: Image object representing the extracted frame. + """ + x = col * self.sprite_width + y = row * self.sprite_height + + frame = self.sprite_sheet.crop( + (x, y, x + self.sprite_width, y + self.sprite_height) + ) + return frame + + def frame_size(self, width: int, height: int) -> None: + """ + Set the size of each frame in the sprite sheet. + + Args: + width (int): Width to set for each frame. + height (int): Height to set for each frame. + """ + for frame in self.frames: + frame.width = width + frame.height = height + + def frame_pos(self, x: int, y: int) -> None: + """ + Set the position of each frame in the sprite sheet. + + Args: + x (int): X position to set for each frame. + y (int): Y position to set for each frame. + """ + for frame in self.frames: + frame.x = x + frame.y = y diff --git a/src/fusionengine/engine/window.py b/src/fusionengine/engine/window.py index a9d1f0ea..57dfc968 100644 --- a/src/fusionengine/engine/window.py +++ b/src/fusionengine/engine/window.py @@ -23,6 +23,9 @@ def __init__(self, title: str, width: int, height: int) -> None: self._quittable = True self._clock = pg.time.Clock() + self._fullscreen = False + self._screensafer = False + self.title = title self.width = width self.height = height @@ -101,6 +104,76 @@ def get_fps(self) -> int: return self._fps + def toggle_fullscreen(self) -> None: + """ + Toggles fullscreen mode. + """ + self._fullscreen = not self._fullscreen + + pg.display.toggle_fullscreen() + + def is_fullscreen(self) -> bool: + """ + Returns if the window is in fullscreen mode. + + Returns: + bool: True if fullscreen else false + """ + return self._fullscreen + + def get_screensafer_allowed(self) -> bool: + """ + Returns if the window is in screensafer mode. + + Returns: + bool: True if screensafer else false + """ + return pg.display.get_allow_screensaver() + + def toggle_screensafer_allowed(self) -> None: + """ + Toggles screensafer mode. + """ + self._screensafer = not self._screensafer + + pg.display.set_allow_screensaver(self._screensafer) + + def get_vsync_enabled(self) -> bool: + """ + Returns if the window is in vsync mode. + + Returns: + bool: True if vsync else false + """ + return pg.display.is_vsync() + + def get_screen_refresh_rate(self) -> int: + """ + Returns the screen refresh rate. + + Returns: + int: The screen refresh rate + """ + return pg.display.get_current_refresh_rate() + + def get_display_amount(self) -> int: + """ + Returns the amount of displays. + + Returns: + int: The amount of displays + """ + return pg.display.get_num_displays() + + def get_active(self) -> bool: + """ + Returns if the window is active. + + Returns: + bool: True if active else false + """ + return pg.display.get_active() + def quit(self) -> None: """ Quits the window. Specifically, stops and deletes window. diff --git a/tests/spritesheet.py b/tests/spritesheet.py new file mode 100644 index 00000000..f2f6bac3 --- /dev/null +++ b/tests/spritesheet.py @@ -0,0 +1,16 @@ +import fusionengine as fusion + +window = fusion.Window("Spritesheet test", 200, 200) +window.set_fps(30) +main_image = fusion.Image(fusion.DEBUGIMAGE, 200, 200, 50, 50) + +spr = fusion.SpriteSheet(fusion.DEBUGIMAGE, 100, 100) +spr.frame_size(100, 100) +spr.frame_pos(50, 50) + +anim = fusion.Animation(window, spr) + + +@window.loop +def loop(): + anim.play(0.1) diff --git a/tests/storage_test.py b/tests/storage_test.py index ef765796..ccb09ff6 100644 --- a/tests/storage_test.py +++ b/tests/storage_test.py @@ -1,6 +1,6 @@ import os -from fusionengine.files.storage import JsonStorage +from fusionengine import JsonStorage def test_jsonstorage(cleanup):