@Hans
Thank you for the kind words!
I think I'm the only one, or at least me and the few supporters on Patreon where I'm sharing the soruces.
About easyness, I think it's quite easy if the coder is used to OOP, if you have looked at the demo video of the library (https://www.youtube.com/watch?v=uMPc9Jiwh-c), at 00:11, here is the code used :
; Create a new GLFX instance Local fw = GLFX:New( { Display = 1, Width = prefs.Width, Height = Prefs.Height, FlipSync = Prefs.FlipSync, FPS = Prefs.FPS, Title = "GLFX DEMO", }) ; Clean up things fw:Init()
... ... ...
; Define the scene Local scene03 = fw.Scene:New() scene03:Setup( { ; SCENE NAME Name = "03 Sprite / Clone", ; SCENE INITIALIZATION CALLBACK ; Load and setup the background and a single sprite that will be ; initially cloned 49 times. Init = Function(scene) ; Message for the stats screen fw.UserMessage = "Hit + to add clones." ; Define resources Local bgFile = "glfx_test/BG_800x600.jpg" Local spriteFile = "glfx_test/small_planet.png" ; Define a new sprite engine scene.SpriteEngine = fw.SpriteEngine:Create(fw) scene.SpriteEngine:YSort_Set(False, False) ; Load and setup a static background scene.Background = fw.Sprite:Load(bgFile, scene.SpriteEngine, { AnchorX = 0, AnchorY = 0 }) scene.Background:Resize(prefs.width, Nil, True) ; Create one sprite that will be cloned scene.Sprites = {} scene.Sprites[0] = fw.Sprite:Load(spriteFile, scene.SpriteEngine, { x = 512, y = 300, blendEnabled = True }) scene.Sprites[0]._Speed = RndF() For Local i = 1 To 49 scene.Sprites[i] = scene.Sprites[0]:Clone({ x = Rnd(prefs.width-64), y = Rnd(prefs.height-64)}) scene.Sprites[i]._Speed = RndF() Next scene.clonesCount = 49 EndFunction, ; SCENE UNINITIALIZATION CALLBACK ; Simply destroy the sprite engine and all its resources UnInit = Function(scene) scene.SpriteEngine:Destroy() EndFunction, ; CLEAR SCENE CUSTOM CODE Clear = Function() EndFunction, ; SCENE RENDER CODE ; Draw all sprite engine's items Render = Function(scene) scene.SpriteEngine:All_DrawUnorderedLayered() EndFunction, ; SCENE UPDATE CODE ; Called before every render, here we update all our sprites manually ; and we check for keypresses. ; Updating the coordinates here, in this way, it's not a good idea because on ; slow systems the target FPS could be violated resulting in a wrong movement. ; A good way could be to use the :MoveTo() method or use directly a tween ; to move the objects. But this is just a simple example to show how GLFX works. Update = Function(scene) ; Check for th e + key If IsKeyDown("+") Local i = scene.clonesCount + 1 scene.Sprites[i] = scene.Sprites[0]:Clone({ x = Rnd(prefs.width-64), y = Rnd(prefs.height-64)}) scene.Sprites[i]._Speed = RndF() scene.clonesCount = i EndIf ; Updates all planet sprites For _, s In IPairs(scene.Sprites) Do s:MoveRel(s._Speed, 0, True)
; Check for the ESCAPE key checkESC()
EndFunction } )
; ADD THE SCENE TO THE FRAMEWORK fw:AddScene(scene03)
... ... ... ; Switch to the starting scene fw:ChangeScene("03 Sprite / Clone") ; Initialize the framework fw:Init() ; Let's Rock! fw:Start()
Once you have defined the scene it's all up to GLFX to keep updated, no OpenGL required from the coder.
An empty scene setup looks like this:
Local scene01 = fw.Scene:New() scene01:Setup( { Name = "01 Scene Setup", Init = Function() EndFunction, UnInit = Function() EndFunction, Clear = Function() EndFunction, Render = Function() EndFunction, Update = Function() checkESC() EndFunction }) fw:AddScene(scene01)
A simple game probably would require 3 scenes, one for the title screen, one for the gameplay and one for the game over screen. GLFX supports transitions between scenes as you may have seen in the Hasteroids video, right now it supports two effects, one crossfade and one slide fx.
Basically you have to fill the empty functions with your code and game logics. If you need more details just ask!
_________________ ----- [Allanon] Fabio Falcucci AMC Website // Docs Site // Support Forum // => Patreon <= |