Wednesday, August 21, 2019

sfgml - HelloWorld - example: https://github.com/Gavolot/HaxeToGML_HelloWorld

This example does not contain an ecc system, but briefly explains how to work with haxe through the target of a game-maker studio.

Friday, August 9, 2019

Fork - Entity Component System for sfgml compiler!

Now you can use the cool programming pattern of your game to compile in gml!
Enjoy it!

The difference is insignificant, but it exists, for example, a gml can only use links to static functions, because in a gml there are no non-static in nature.

Also, you cannot create functions with the name "create", because this function is reserved gml.

https://github.com/Gavolot/clay_ecs


Wednesday, August 7, 2019

An example of a simple data structure that I use in a project.

The trick of all this is that you can use data structures inside the hax code, while getting only the variables in the output. So far, variables are quickly processed by any engine)
So you do not have to worry about whether it is slow. You should only describe them and use:

/**

 * ...

 * @author Gavolot

 */

@:forward abstract Vec2f(Vec2f_impl) {

    public inline function new(x:Float, y:Float) this = { x:x, y:y };

 public inline function SqrtMagnitude() {

  return Math.sqrt((this.x * this.x) + (this.y * this.y));

 }

 public inline function SqrMagnitude() {

  return (this.x * this.x) + (this.y * this.y);

 }



    @:op(A + B) public inline function add(v:Vec2f) return new Vec2f(this.x + v.x, this.y + v.y);

 @:op(A + B) public inline function addInt(v:Int) return new Vec2f(this.x + v, this.y + v);

 @:op(A + B) public inline function addFloat(v:Float) return new Vec2f(this.x + v, this.y + v);

 

 @:op(A - B) public inline function minus(v:Vec2f) return new Vec2f(this.x - v.x, this.y - v.y);

 @:op(A - B) public inline function minusInt(v:Int) return new Vec2f(this.x - v, this.y - v);

 @:op(A - B) public inline function minusFloat(v:Float) return new Vec2f(this.x - v, this.y - v);

 

 @:op(A * B) public inline function multiply(v:Vec2f) return new Vec2f(this.x * v.x, this.y * v.y);

 @:op(A * B) public inline function multiplyInt(v:Int) return new Vec2f(this.x * v, this.y * v);

 @:op(A * B) public inline function multiplyFloat(v:Float) return new Vec2f(this.x * v, this.y * v);

 

 @:op(A / B) public inline function divide(v:Vec2f) return new Vec2f(Std.int(this.x / v.x), this.y / v.y);

 @:op(A / B) public inline function divideInt(v:Int) return new Vec2f(Std.int(this.x / v), this.y / v);

 @:op(A / B) public inline function divideFloat(v:Float) return new Vec2f(this.x / v, this.y / v);

 

 @:op(A == B) public inline function equally(v:Vec2f) : Bool return (this.x == v.x && this.y == v.y);

 @:op(A != B) public inline function notEqually(v:Vec2f) : Bool return (this.x != v.x || this.y != v.y);

}

@:nativeGen typedef Vec2f_impl = { x:Float, y:Float }



What's going on here? Yes, just a data structure is created, which you can then use in the code as an object, v1 = new Vec2f (5.0, 10.0);
and inside in the generated code it will look like:

First of all, it is worth warning. English is not my native language. Therefore, so far, most of the text is Google translate, plus some manual edits.

But I try, really.  (Do not believe him)

What is this blog about? About the wonderful Haxe programming language, as well as the wonderful engine / framework game-maker studio. I think everyone can use Google to find out what I’m talking about, but I’ll still give some links for the starting point:

https://haxe.org/

https://www.yoyogames.com/get

Many rightly ask what is happening here, why, why?

But the fact is that I will use the programming language Haxe in order to later translate it into a high-performance GML.

Of course, I did not write the compiler myself: https://yal.cc/r/18/sfgml/

This magic tool turns your Haxe code into a scripting language.

There are a couple of limitations, small details that you should know before you go ahead. I am also trying to describe how it really works.

I am also an adherent of the entity-component-system pattern when developing game logic.

I started by making my own version of the clay library. Which provides the work with the ecs pattern.

I hope you will like it!

What information can be useful for you here?
1) You want to really speed up your projects, as well as get a language with more control, but at the same time you don’t want to lose such a cool tool as a gms.
2) You would like to get an easier scaling of the project (this is mostly about the project, but it also refers to the first option)
3) You would like to learn how to write extensions for gms, but using gml for this is painful.
4) You would probably like to familiarize yourself with the Haxe language, learn about macros and anything else.