Scripts / My Behavior 'rgba_converter.lua' (tested with Alpha Build 2022-05-20)

Author
Message
mikeven
12
Years of Service
User Offline
Joined: 31st Dec 2011
Location:
Posted: 1st Jun 2022 14:13
Hello,

Those last weeks I trained a lot with LUA scripting in GameGuru MAX.
Thanks to my research on the available parameters explained in the 'global.lua' script and a better understanding of the Behaviour's structure and functioning I may now create useful scripts for a game's project that I am developing since a few months.

I already created a dozen of scripts especially to control imported animations or other ones created with GameGuru MAX instructions.

My purpose with that game will be to demonstrate that what Mister Lee Bamber declared in his interview recorded by Avenging Eagle in this video https://www.youtube.com/watch?v=7tgKTroAk3s ( see this thread https://forum.game-guru.com/thread/223411 ) is the truth.

Indeed this is the related part excerpted from that interview starting on elapsed time of 26 minutes and 58 seconds and concluded by a laugh of Mister Lee Bamber : " ... and I am hoping that GameGuru Max is finally the gamemaker where you can make a game and you can sell it in the shops and no one know it's GameGuru Max. That's the ambition...".

I am glad to show this script 'rgba_converter.lua' that could be defined as a utility tool for GameGuru Max.

It offers two functionalities :
- the first one is the conversion of a color defined by its four parameters (r,g,b and a) into its decimal value as found in the .FPE files relative to the assets properties in conjuction with the .DBO files and with the assigned textures.
- the second one is the conversion of that unique decimal rgba value of a color into its four distinctive r,g,b and a values.

For each of those two functionalities, the script shows five sprites respectively colored with the r,g,b,a and rgba values.

I show herewith a screen capture of the script where I inserted as many comments as possible.



For the complete newbies who would be interested in the usage of behaviors in GameGuru MAX I also recorded a video with my audio comments showing how that behaviour works in an empty project.

Here is the link to that video published on my Vimeo Gallery : https://vimeo.com/715954518 ( size : 131 MBytes ; duration : 4 minutes and 55 seconds . HD + audio ).

To conclude this comment I want to say this : Creating a video game is a GAME in itself and that is especially true (no irony in my words) when your project is evolving through the successive builds that you'are testing with many trials and errors. A big thank you to Mister Lee Bamber and to the members of the small team dedicated to that superb game engine.






Attachments

Login to view attachments
PM
=VX=Doggy
14
Years of Service
User Offline
Joined: 29th Nov 2009
Location: USA NC
Posted: 2nd Jun 2022 04:49
Very nice work !
PM
mikeven
12
Years of Service
User Offline
Joined: 31st Dec 2011
Location:
Posted: 2nd Jun 2022 20:07
=VX=Doggy, thank you for your kind comment.

Unfortunately I must admit that my basic knowledge of LUA script combined with a lack of common sense led me to a solution that is not efficient at all in that behavior.

And I explain why with this picture :



I discovered today that in LUA script there is an available pattern with which it is possible to convert a decimal value into its equivalent in hexadecimal format.

Then (and it is there that I had a lack of common sense) I thought : "if GameGuru MAX is able to read the decimal format of a ARGB color stored in a .FPE file, it means that there is surely a faster solution than those loops coded in my behaviour".

Anyway I'm progressing and that's the most important for me.

PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 3rd Jun 2022 22:30
@ mikeven
Nice try!
A first glance, you might use just 1 loop for everything, something such:

for i = 0,255,1 do
RGBA_test_a = (a-b) /256 -- using some values here, but you get the point
RGBA_test_r = (a-b) /256 -- using some values here, but you get the point
RGBA_test_g = (a-b) /256 -- using some values here, but you get the point
RGBA_test_ b= (a-b) /256 -- using some values here, but you get the point

if RGB_test_r == math.flor(RGB_test_r) then
--you code goes here
elseif RGB_test_a == math.flor(RGB_test_a) then
--you code goes here
and so on.
else
-- WRONG INPUT
end
end

The goal here is to avoid running as many loops as possible, just for performance sake.
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM
mikeven
12
Years of Service
User Offline
Joined: 31st Dec 2011
Location:
Posted: 4th Jun 2022 07:39 Edited at: 4th Jun 2022 07:53
Hello 3com,

Thank you for your interest in this thread and for sharing your method to optimize the performance of the code.

I will be sincere with you.
Behind the lines of code in a program there is the way the programmer analysed the goal and how (s)he could obtain the desired result.
That part of the job is not visible in the code.
Therefore, personally, when I read a program/script written by some advanced programmer in the majority of the cases I am unable to understand its coding.
I can see the algorithms and the formulas in the code but I cannot think deep enough to understand the logic that the programmer had in mind when (s)he wrote them.

In matter of programming I work very slow and I perform as many tests as possible to clean any possible bug.

I could compare that problem of understanding of the code written wy someone else with this story :
When I was a teenager, my father learned me to play Checkers. He was a very good player. When he moved a piece on the checkerboard I naively thought that I understood his strategy. But I was always wrong.

Out of curiosity I sometimes examine the scripts written by the gurus of this community and I often come to the same conclusion : "it is too difficult for me to understand their scripts".

With the required modesty I may say that my best skill is the visualisation of the steps to reach the desired result in my programs.

3com I take the opportunity of your message to say this : I enjoyed watching your famous thread https://forum.game-guru.com/thread/222207 where you published a lot of videos.

PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 4th Jun 2022 10:26
@ mikeven
I've noticed you are careful and organized when coding, for that reason I told you about compacting code to be friendly with performance.
You are clean and your code is well-commented, this is so important when coding; it helps a lot when to understand what some chunk of code does when you revisit the code.

ar.gy = wj+ht+kk

might simplify your code, but I myself have to go up and down a lot of times to remember what ar, gy, hh, etc, do, this is many times consuming; when you are writing a script you have all the data fresh in your brain, but after like 6 months it is not the same.

Quote: "Out of curiosity I sometimes examine the scripts written by the gurus of this community and I often come to the same conclusion : "it is too difficult for me to understand their scripts"."

Advanced coders usually use libs to improve code and make life easier, so, perhaps you have to get familiar with them; Amen has done a lot about it, Smallg is writing useful scripts to help everybody (that guy introduce me to LUA with their scripts in GG )
It is worth visiting their threads on this forum, small explain to you really nice about Visual Dynamic LUA.

Note: I know you already have so clear all that, anyway, it might help a newcomer visiting your thread.
Great work, keep up!

And I'm glad you like my thread, thank you very much.

Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM

Login to post a reply

Server time is: 2024-11-21 12:00:13
Your offset time is: 2024-11-21 12:00:13