Re: Introducing surgescript [released!]

Timeout

One of the most useful commands of the old API was on_timeout. Basically, it allowed to change the state of an object after a number of seconds passed. The same functionality can be achieved today in SurgeScript using timeout(): smile

object "Application"
{
    state "main"
    {
        Console.print("Now on the main state. Please wait 4 seconds...");
        state = "wait1";
    }

    state "wait1"
    {
        if(timeout(4.0)) // will wait 4 seconds to change the state
            state = "cool";
    }

    state "cool"
    {
        Console.print("Cool! Now wait for more 8 seconds...");
        state = "wait2";
    }

    state "wait2"
    {
        if(timeout(8.0))
            state = "done";
    }

    state "done"
    {
        Console.print("You're done!");
        Application.exit();
    }
}

Link: https://github.com/alemart/surgescript/ … timeout.ss

Re: Introducing surgescript [released!]

Sorting in SurgeScript

One of the most important themes in computer science is sorting. In games, you may use sorting, for example, to create a high scores table and display the highest scores first. SurgeScript allows you to sort arrays using the sort() method: smile

Original array:
3 7 1 5 9 2 4 6 8 0
Sorting in ascending order...
0 1 2 3 4 5 6 7 8 9
Sorting in descending order...
9 8 7 6 5 4 3 2 1 0
Sorting in custom order (odds first)...
1 3 5 7 9 0 2 4 6 8

You can sort anything: numbers, strings and even more complex data.

Code link: sort_array.ss

Re: Introducing surgescript [released!]

I can see that the development of SurgeScript does not stop. The progress is awesome. Having such tool as the scripting engine inside Open Surge is going to make it really powerful.

When will be integrated?

Piece of cake...!

Re: Introducing surgescript [released!]

TheSeventhEmerald wrote:

When will be integrated?

It's about to be integrated. One or two details to do, and the first build of SurgeScript will be done. Then comes the integration.

Re: Introducing surgescript [released!]

Can't wait to see this program released smile

It will be awesome to make games of all genres on an easy way!

Re: Introducing surgescript [released!]

Advanced features

A very nice feature of object-oriented programming languages is called a functor (or function object). It allows you to have objects that behave like functions.

In SurgeScript, you can do really powerful programming using functors. In the example below, we have an object called Benchmark that can measure the performance of any code/object that you provide:

// We'll measure the performance of the computation of the Fibonacci sequence using an exponential method
object "Application"
{
    benchmark = spawn("Benchmark");
    fib = spawn("Fibonacci");

    state "main"
    {
        t  = benchmark(fib(1));
        t += benchmark(fib(5));
        t += benchmark(fib(10));
        t += benchmark(fib(25));
        t += benchmark(fib(32));
        Console.print("Total time: " + t + " seconds.");
        Application.exit();
    }
}

In my computer, the output of this program is as follows:

Computing ExpFib(1) = 1          done in 0.000018 seconds.
Computing ExpFib(5) = 5          done in 0.000052 seconds.
Computing ExpFib(10) = 55          done in 0.000478 seconds.
Computing ExpFib(25) = 75025          done in 0.203170 seconds.
Computing ExpFib(32) = 2178309          done in 5.642050 seconds.
Total time: 5.845768 seconds.

Check out the full example!

Granted, it's an advanced feature. smile

Re: Introducing surgescript [released!]

Advanced features

Is this script necessary for levels with a large map and a large number of objects?
I think It can be tested in a virtual machine with Windows 98 or 2000.

Re: Introducing surgescript [released!]

G.E.R. wrote:

Is this script necessary for levels with a large map and a large number of objects?
I think It can be tested in a virtual machine with Windows 98 or 2000.

I don't think so. Open Surge runs well even in old computers, and once the map is loaded you should have no problem. It is more useful to test algorithms inside the new SurgeScript.

Alexandre wrote:

Advanced features
A very nice feature of object-oriented programming languages is called a functor (or function object). It allows you to have objects that behave like functions.

In SurgeScript, you can do really powerful programming using functors. In the example below, we have an object called Benchmark that can measure the performance of any code/object that you provide

Granted, it's an advanced feature.

Nice addition. My only criticism is that the functor has not a very clear syntax. At least for me it is diffiicult to understand, only reading the code, what is exactly the black magic behind it. In C++ for example the functor is done overloading (), which is way easier to understand. However, it may be matter to get used to it.

I see that the scripting is getting really complete. I think it is time to integrate it with the Open Surge engine to test it in the wild. I really want to get my hands dirty with it.

Happy new year to everybody, BTW.

Last edited by TheSeventhEmerald (2018-01-05 10:01:58)

Piece of cake...!

Re: Introducing surgescript [released!]

I'm sorry for butting in on the conversation (this should be in another section but...), Is it possible to set a custom fps for a Sprite via objects?

If it's not, that's ok, but I want to know if it's possible to do so. I want to play around with certain time variables and I want it to include sprite fps.

(I sped read the whole thing because I'm on time constraints right now, so if it's already an asked question I understand.)

www.facebook.com/24XFSAL  Hasn't been updated anytime recently, don't bother.
I'm on SoundCloud: https://soundcloud.com/rain-new-holy - I plan to upload one soon.
Name change from 24XFSAL coming soon. Currently studying for Information Technology and Game development. (Also studying game theory in spare time.)

Re: Introducing surgescript [released!]

aronthehedgehog wrote:

I'm sorry for butting in on the conversation (this should be in another section but...), Is it possible to set a custom fps for a Sprite via objects?

If it's not, that's ok, but I want to know if it's possible to do so. I want to play around with certain time variables and I want it to include sprite fps.

(I sped read the whole thing because I'm on time constraints right now, so if it's already an asked question I understand.)

Hi aronthehedgehog, welcome back. smile

set_animation_speed_factor

Re: Introducing surgescript [released!]

Alexandre wrote:
aronthehedgehog wrote:

I'm sorry for butting in on the conversation (this should be in another section but...), Is it possible to set a custom fps for a Sprite via objects?

If it's not, that's ok, but I want to know if it's possible to do so. I want to play around with certain time variables and I want it to include sprite fps.

(I sped read the whole thing because I'm on time constraints right now, so if it's already an asked question I understand.)

Hi aronthehedgehog, welcome back. smile

set_animation_speed_factor

Ok, thanks!
This'll greatly help me.

www.facebook.com/24XFSAL  Hasn't been updated anytime recently, don't bother.
I'm on SoundCloud: https://soundcloud.com/rain-new-holy - I plan to upload one soon.
Name change from 24XFSAL coming soon. Currently studying for Information Technology and Game development. (Also studying game theory in spare time.)

62

Re: Introducing surgescript [released!]

I can add to that. If you use a global variable like $_gamespeed and multiply every object/player speed including gravity and jump power, and animation speed factor by it, you can do two things:

modify the speed of the whole game to your taste without doing it per object and per player

simulate slow-motion and fast forward

in fact for this to completely work for players you have to create an actor object, which is no more than a mimic of the player's animations, while the player itself is invisible

hopefully setting game speed will be easier in the future (set_game_speed N)

Last edited by KZR (2018-01-16 22:41:57)

https://image.ibb.co/kuSYrm/SD_sml.pnghttps://image.ibb.co/kHq8P6/SeD_sml.pnghttps://image.ibb.co/cJf8P6/LTot_W_sml.png

Re: Introducing surgescript [released!]

The SurgeScript documentation will be available at:

https://alemart.github.io/surgescript/ cool

In the next few days I'll add some more content, and then proceed to the engine integration. There are no more language features I plan to develop for the time being.

Re: Introducing surgescript [released!]

SurgeScript v0.5.0 is released!

https://github.com/alemart/surgescript/raw/master/docs/img/opensurge.png

I'm glad to announce that SurgeScript v0.5.0 has just been released! big_smile

Official website: https://alemart.github.io/surgescript (contains full documentation)

Download link: https://github.com/alemart/surgescript/releases

This beta version has not been integrated into the Open Surge Engine yet. However, it supports text mode and the core of the language is fully operational! You can try it out playing with scripts. You need to compile it at this time.

This is a total evolution from the previous scripting system embedded in Open Surge. It retains the easy things of the state machines, but adds extraordinary power to you. With SurgeScript, you will be able to unleash your unlimited creativity! smile

If you find any bugs, please let me know. If you want to ask anything about SurgeScript, please feel free to do so!

This has been a lot of work! Soon I'll be announcing details about the engine integration.

Re: Introducing surgescript [released!]

Alexandre wrote:
SurgeScript v0.5.0 is released!

https://github.com/alemart/surgescript/raw/master/docs/img/opensurge.png

I'm glad to announce that SurgeScript v0.5.0 has just been released! big_smile

Official website: https://alemart.github.io/surgescript (contains full documentation)

Download link: https://github.com/alemart/surgescript/releases

This beta version has not been integrated into the Open Surge Engine yet. However, it supports text mode and the core of the language is fully operational! You can try it out playing with scripts. You need to compile it at this time.

This is a total evolution from the previous scripting system embedded in Open Surge. It retains the easy things of the state machines, but adds extraordinary power to you. With SurgeScript, you will be able to unleash your unlimited creativity! smile

If you find any bugs, please let me know. If you want to ask anything about SurgeScript, please feel free to do so!

This has been a lot of work! Soon I'll be announcing details about the engine integration.

Yo, Alex smile

Congratulations in uploading this. wink

I'm going to test it but you said the best way is using the Open Surge Engine. When will we have the link? And more importantly, how can I start using the SurgeScript on it?

Re: Introducing surgescript [released!]

SynfigMaster91 wrote:

I'm going to test it but you said the best way is using the Open Surge Engine. When will we have the link? And more importantly, how can I start using the SurgeScript on it?

In a few days.

Right now, the only way to test it is using the standalone version. I'll be making a video explaining how to use this early version.

You can start using SurgeScript right now if you follow the instructions on the website.

Thanks for the support, Alvaro smile

for everyone: the API Reference on the Open Surge Wiki will be turned obsolete. There's a new Reference for SurgeScript, featuring a more friendly website.

Re: Introducing surgescript [released!]

I have just read the full documentation.

I am absolutely impressed. It is impressive. It can be used as the finite state machine we have always used in Open Surge. New users can employ only the pre-built functions. Experienced users can mess with conditionals, loops, and even overloading and iterators. It is crazy you managed to implement this only by yourself.

My congrats on this project. I hope it gets some attention, because I think that it could be applied for many game projects with ease. Only counter I see is that it requires integration with a C engine -most developers are using more modern stuff, such as Unity, Godot, or LibGDX/SFML.
In any case, for OpenSurge these are big news. This is going to turn the engine in the most complete and powerful Sonic-like engine ever built. I cannot wait to put my hands over it.

I will try as soon as I have time and give you some comments

Please keep up informed about the integration! big_smile:D:D:D:D:D:D:D:D:D:D

Last edited by TheSeventhEmerald (2018-04-17 13:52:41)

Piece of cake...!

Re: Introducing surgescript [released!]

I hope I do not have to rewrite all scripts?

Re: Introducing surgescript [released!]

TheSeventhEmerald wrote:

I am absolutely impressed. It is impressive.

Hey, thanks TheSeventhEmerald! I knew you would like it smile

TheSeventhEmerald wrote:

This is going to turn the engine in the most complete and powerful Sonic-like engine ever built. I cannot wait to put my hands over it.

Yes, I truly believe this is going to be so. cool

TheSeventhEmerald wrote:

Only counter I see is that it requires integration with a C engine -most developers are using more modern stuff, such as Unity, Godot, or LibGDX/SFML.

SurgeScript can be used with other technologies, such as SFML. It just happens that I personally won't be focusing on other engines at the moment; Open Surge is more than enough work for me. Perhaps I should have phrased it differently. SurgeScript is built in C, which is nearly universal. smile

G.E.R. wrote:

I hope I do not have to rewrite all scripts?

The old scripts will continue to work. However, I won't be updating the old system too often.

Re: Introducing surgescript [released!]

All this is very good, you are expanding Open Surge project. I decompiled and was studied game engines Sonic Generations and Sonic Mania on last year and I want to note that Open Sonic/Surge is most optimal engine for creating users games.

When you write API Reference, I can translate it on russian (and, maybe, japanese) language