-
Notifications
You must be signed in to change notification settings - Fork 0
Initializing, updating & drawing
Nick Jordan edited this page Oct 20, 2023
·
2 revisions
- Init, Update and Draw
- Setting up the screen
- Loading assets
- Using assets
- Initializing & using UI components
The three core functions for your game are setup
, update
, and draw
. Here's a basic template:
from slitherzenith import *
def setup() -> None:
pass
def update() -> None:
pass
def draw() -> None:
pass
Modify screen properties using helper methods in the setup
function:
def setup() -> None:
screen(800, 600)
title("My wonderful game")
backdrop((50, 50, 255))
Load assets from using provided functions:
heart_image = load_image("sprites/symbols/heart.png")
point_sound = load_sound("audio/point.wav")
Incorporate assets into your game's logic and rendering:
def update() -> None:
point_sound.play()
def draw() -> None:
image(heart_image,
get_screen_width() / 2,
get_screen_height() / 2,
10)
Initialize UI components in the Init
method. Update and draw them in the Update
and Draw
methods, respectively:
from slitherzenith import *
from Components.UI.button import Button
button = Button((get_screen_width() / 2, get_screen_height() / 2),
100,
50,
"Hello",
20,
(255, 255, 255),
(1, 1, 1),
(100, 100, 100),
True,
5,
(255, 255, 255))
def setup() -> None:
screen(800, 600)
title("My wonderful game")
backdrop((50, 50, 255))
def update() -> None:
button.update()
if button.clicked():
print("Clicked!")
def draw() -> None:
button.draw()