Skip to content

Scenes, Entities and animations

Scene manager

See in this example how to use the scene manager.

Entities

If you want a player or an enemy or some moving object in your game, you can use an entity, thats an object that helps you manage things in your game:

#                                    x    y    w   h
your_entity = fusion.Entity(window, 100, 100, 50, 50)

Draw rect with entity

If you want to draw a rectangle that is basically in your entity, then you do it like this:

your_entity.load_rect(fusion.BLACK)
Then you can draw it with:

your_entity.draw_rect()

Draw image with entity

If you want to draw a image on your entity, then you do this:

your_entity.load_image("image_path")

Then you can draw it with:

your_entity.draw_image()

Custom animations with entities

Fusion has some build-in features into entity system to make animations more easy, here are some ways to use it

Load frames

First of all, you need to load frames, and you can do this using this way:

your_entity.load_animation(images: tuple)

Setting current frame

You can set the current frame with this function

your_entity.set_frame(frame: int)

Getting current frame

To get the current frame, run:

my_frame_var = your_entity.get_frame()

Drawing current frame

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

my_anim = fusion.Animation(your_window, your_images: tuple, fps: int)

Drawing animation

To draw it then, run:

my_anim.draw()