Rayframe is a raylib
framework for Go.
Instantiate a *rayframe.RayFrame
:
frame := &rayframe.RayFrame{}
The fields you can set are:
Camera *raylib.Camera
: for 3D renderingFPS int
: how many frames per secondInFront3D bool
: whether 3D must be rendered in front of 2D renderingOnResize func(int, int, boot)
: a callback called whenever the window is resized, passing the new size (width and height) and whether it’s fullscreen.
The fields you can read:
Tick time.Time
: last tick timeWindowSize struct{ X, Y int }
: current window size
Initialise the framework by calling:
frame.Init(1280, 720, "My Application")
The parameters are:
width int
: window initial widthheight int
: window initial heighttitle string
: window title
Then start the main loop by calling:
frame.Mainloop(scene)
scene
can be any structure pointer.
Scene
is an alias to interface{}
.
Each scene may implement any of the following methods:
Init(*rayframe.RayFrame)
: called when the framework shifts to the scene.Background() color.RBGA
: inform the framework which colour to use when painting the background. If not implemented, the framework won’t callraylib.ClearBackground()
.ExitKey() int32
: which key is used to exit, default toraylib.KeyEscape
. Only works associated withOnKeyEscape()
. Use zero (0
) to disable the exit key.OnKeyEscape() Scene
: what to do when the escape key is pressed. Only works associated withExitKey()
. Returnnil
or the scene itself to do nothing.Update(time.Duration) Scene
: called each tick and receives the time delta since the last tick.Render2D() Scene
: used to render 2D assets.Render3D() Scene
: used to render 3D assets under 3D mode, if the framework’sCamera
is set.
If any Scene
-returning method returns anything but the calling scene
itself, the framework will change the scene by the return value and will call
Init()
(if it’s implemented).
- Copyright ©2022 Arĥimedeς Montegasppα Cacilhας
- 3-Clause BSD License
- COPYING