Main Wiki¶
Create window¶
To create a window were thing are draw, then you need to use this:
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:
Choice 2:
There is basically no difference, they all are doing the same thing, you use what you prefer. In our examples we use choice 1.
Default message¶
If you tried using our engine you may have encountered this message being printed to terminal:
Fusion Engine 1.0.2 (Pygame-ce 2.3.0, Python 3.11.4)
Welcome to Fusion Engine! https://github.com/dimkauzh/fusion-engine
To disable this behavior, you just give the main class when initting this argument: message=False
, like this:
Set Background color¶
If you want to set a background color, you use this function before all draw functions:
DeltaTime¶
if you want to access delta time, you use this:
Predefined shapes¶
We have some predefined shapes that can be used and be drew on the screen. Here are some:
Rectangle:
- More shapes will be coming soon
Window icon¶
So you want to change the icon of your window? Well, its easy:
Set FPS¶
To set the framerate of your window, you use this:
Vectors¶
Vector2d¶
If you want to create a 2d vector that stores x and y, then you do this:
Draw a line¶
To draw a line, you use this:
Draw rectangle¶
If you just want to draw a rectangle to test or to use it for your game/app, then you have 3 options:
Option one: just draw a rectangle
Second option: draw predefined rectangle:
Third option: Draw a rectangle of lines
Draw image¶
You first need to create a variable with your image and image data:
main.DEBUGIMAGE is an image that is included with the engine, so you can use it freely. Then you need to render it (In the best situation this will happen in your loop):
Create entity WARNING: PRE ALPHA (It's in really early stages)¶
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:
Draw rect with entity¶
If you want to draw a rectangle that is basically in your entity, then you do it like this:
Draw image with entity¶
If you want to draw a image on your entity, then you do this:
Sound¶
Load sound¶
To load a sound you do this:
Play sound¶
To play your loaded sound you use this:
Stop sound¶
To stop your playing sound you use this:
Backround music¶
To start playing background music you use this:
Storage system¶
Init¶
This how you initialize your json storage systemInsertion¶
my_db.insert({"first_name": "john", "last_name": "wick", "gold": 50})
my_db.insert({"first_name": "alexander", "last_name": "wick", "gold": 20})
Reading¶
The code demonstrates reading operations. It searches for entries with the last name "wick" and retrieves results with and without index information.Updating¶
The code showcases how to update data in the storage. In this case, it increases the "gold" value for an entry with the first name "alexander" by 20.Deleting¶
The code demonstrates deletion of data by removing an entry with the first name "john" from the storage.Saving to Disk¶
The code shows how to save the modified data back to the storage file on disk.Keyboard input¶
Keydown¶
if you need keyboard input, then use this if statement with your own key (see key tab for all key names):
Keydown once¶
If you need keydown to be only once, then you use this:
User Interface (UI)¶
Creating a small ui for your application/game is easy with our following tools:
Buttons¶
To create a simple button we do the following:
# Create the button outside the loop
button = main.ui.button.new_button(
window,
main.shape.new_rect_button(200, 200, 200, 200),
"Hello World"
)
Button clicked¶
If you want to check if your button was pressed or is being pressed, then you do that this way:
Rendering text¶
If you want to render some fonts, then you can do it like this:
-
Option 1: Render text with build into fusion or your own font
-
Option 2: Render text with system font Its the same option 1, but you change the font to name of the font, like this:
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: