-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from fusionengine-org/dev
V5.2
- Loading branch information
Showing
40 changed files
with
820 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,31 @@ | ||
--- | ||
hide: | ||
- navigation | ||
--- | ||
# Basic Moving Character Tutorial | ||
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. | ||
We are going to make a small moving character. The character is gonna be a node with the fusion icon as image. | ||
|
||
## Setting up | ||
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. | ||
If you want have fusion yet setup, then go back to [the setup tutorial](setup.md) | ||
|
||
## Basic things | ||
First, lets get the basic things setup, like a window and a loop. | ||
|
||
First, we import `fusionengine` as `fusion`: | ||
```python | ||
import fusionengine as fusion | ||
``` | ||
|
||
Then we create a window where all drawing will take place: | ||
```python | ||
window = fusion.Window("Basic Character - Fusion Engine", 800, 600) | ||
``` | ||
|
||
After the window is done, we can create the loop: | ||
```python | ||
@window.loop | ||
def loop(): | ||
... # Our code is gonna go here | ||
``` | ||
Thats it! We have a basic window and loop setup! | ||
|
||
## Getting the Node setup | ||
|
||
# Platformer tutorial | ||
This is a tutorial how to build a basic platformer using fusion-engine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Node and Scenes | ||
|
||
## Node | ||
If you want a player or an enemy or some moving object in your game, you can use an Node, thats an object that | ||
helps you manage things in your game: | ||
|
||
```python | ||
# x y w h | ||
your_node = fusion.Node(window, 100, 100, 50, 50) | ||
``` | ||
|
||
### Get Cordinates | ||
If you want to get the cordinates, then there are a few ways to do it. | ||
|
||
#### As a tuple | ||
If you want to get the Cordinates as a tuple, then do the following: | ||
```python | ||
my_cor = your_node.get_coord_tuple() | ||
``` | ||
|
||
#### As a Vector2D | ||
If you want to get the Cordinates as a Vector2D, then do the following: | ||
```python | ||
my_cor = your_node.get_coord_vec2() | ||
``` | ||
|
||
### Loading a Rect | ||
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, | ||
then you can load the rect using this way: | ||
```python | ||
your_node.load_rect(fusion.BLACK) | ||
``` | ||
|
||
### Loading an Image | ||
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. | ||
|
||
```python | ||
your_node.load_image("image_path") | ||
``` | ||
|
||
### Animations with a Node | ||
Fusion has some build-in features into Node system to make animations more easy, here are some ways to use it. | ||
|
||
#### Animation object | ||
If you want to load a object of Animation, then you can do it like this: | ||
```python | ||
your_node.load_animation(animation: Animation) | ||
``` | ||
#### Load frames | ||
First of all, you need to load frames, and you can do this using this way: | ||
```python | ||
your_node.load_animation(images: tuple) | ||
``` | ||
|
||
#### Setting current frame | ||
You can set the current frame with this function | ||
```python | ||
your_node.set_frame(frame: int) | ||
``` | ||
|
||
#### Getting current frame | ||
To get the current frame, run: | ||
```python | ||
my_frame_var = your_node.get_frame() | ||
``` | ||
|
||
### Drawing everything | ||
If you want to draw everything, in the same order as you loaded it, you can do that this way: | ||
```python | ||
my_node.update() | ||
``` | ||
|
||
## Scene manager | ||
See in [this example](https://github.com/dimkauzh/fusion-engine/blob/main/examples/example4.py) how to use the scene manager. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.