Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
V5.1
Browse files Browse the repository at this point in the history
V5.1 done. Spritesheets, new animation system and more window features
  • Loading branch information
dimkauzh authored Jan 30, 2024
2 parents d216256 + c7c5e0c commit 4c55dea
Show file tree
Hide file tree
Showing 34 changed files with 454 additions and 136 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
34 changes: 31 additions & 3 deletions docs/changelog/v5.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
# Version 5 Todo/Changelog

## V5
- [ ] Docs cleanup
- [ ] New color system
- [ ] Optimised font drawing
- [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

4 changes: 2 additions & 2 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- [Tutorials](tutorials/setup.md)
- [Wiki](wiki/window.md)
12 changes: 7 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


File renamed without changes.
File renamed without changes.
File renamed without changes.
65 changes: 0 additions & 65 deletions docs/v5/wiki/window.md

This file was deleted.

38 changes: 38 additions & 0 deletions docs/wiki/animation.md
Original file line number Diff line number Diff line change
@@ -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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/v5/wiki/rendering.md → docs/wiki/rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 1 addition & 15 deletions docs/v5/wiki/scene.md → docs/wiki/scene.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
112 changes: 112 additions & 0 deletions docs/wiki/window.md
Original file line number Diff line number Diff line change
@@ -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()
```
45 changes: 23 additions & 22 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 4c55dea

Please sign in to comment.