Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Hello world!

Ethosa edited this page Nov 21, 2021 · 9 revisions

Hello world!

You can write a hello world program with it step by step 👀

So get started!

First, we have to import nodesnim. I hope you don't need help installing the library? 👀
if you still need - https://github.com/Ethosa/nodesnim#install

import nodesnim

Then we create a window with specific params, for example:

Window("Hello, world!", 640, 360)

"Hello, world" - window title.
640, 360 - window size.
👀

Now we can build our scene! 👺
For this, the library uses a specific syntax:

build:
  - Scene my_first_scene:
    - Label hello_world:
      call:
        setText("Hello, world!")
        setTextAlign(0.5, 0.5, 0.5, 0.5)
        setSizeAnchor(1, 1)
        setBackgroundColor(Color(31, 45, 62))

Let's get straights now.
build - is a macro for AST processing with YML-like syntax.
- Scene my_first_scene -here we create a new node with type Scene named my_first_scene.
- Label hello_world - similar to the previous one.
call setText("Hello, world!") - same as hello_world.setText("Hello, world!").

And in the end, to make it work ...

addMainScene(my_first_scene)
windowLaunch()

Full code here: https://github.com/Ethosa/nodesnim/tree/master/examples/hello_world

Clone this wiki locally