diff --git a/Manual/contents/Additional_Information/Guide_To_Using_Shaders.htm b/Manual/contents/Additional_Information/Guide_To_Using_Shaders.htm index 49e0a88c..788b6a36 100644 --- a/Manual/contents/Additional_Information/Guide_To_Using_Shaders.htm +++ b/Manual/contents/Additional_Information/Guide_To_Using_Shaders.htm @@ -54,8 +54,8 @@

Variables de sombreado

vec2 fourthVec = thirdVec.zx;

Cuando accedemos a los componentes del vector en GLSL, tenemos algunas opciones. La más básica es tratar el vector como un array y acceder a los componentes usando corchetes, así:

vec4 myVec;
- myVec[0] = 1.0;
- myVec[1] = 0.0;
+ myVec[0] = 0.0;
+ myVec[1] = 1.0;
myVec[2] = 2.0;
myVec[3] = 1.0;

Sin embargo, hay otra forma de acceder a los componentes con la siguiente sintaxis:

diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/all.htm b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/all.htm new file mode 100644 index 00000000..52f1fd10 --- /dev/null +++ b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/all.htm @@ -0,0 +1,52 @@ + + + + + + all + + + + + + + + + + +

all

+

This keyword is used to tell GameMaker that a function is to be applied, or to check, all active instances within a room (deactivated instances will not be checked or accessed). You cannot use all to access or set variables in other instances using the point method (see here), but you can use it when using with, for example:

+

with (all)
+ {
+     speed = 0;
+ }

+

The above code will set the speed of all instances in the room to 0. You can also use all within functions to target or check all instances in the room for example:

+

// Check a point for any active instance in the room
+ inst = instance_position(mouse_x, mouse_y, all);
+
+ // Check all instances for a collision along a line
+ if collision_line(x, y, mouse_x, mouse_y, all, false, true) {}
+
+ // Add all instances in the room into a motion planning grid
+ mp_grid_add_instances(grid, all, false); +

+

all is a very useful keyword and can be used in numerous situations within your code and actions, often cutting down on the amount of code you need to write to achieve a desired effect.

+

 

+

 

+ + + + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/noone.htm b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/noone.htm new file mode 100644 index 00000000..52f28f9c --- /dev/null +++ b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/noone.htm @@ -0,0 +1,53 @@ + + + + + + noone + + + + + + + + + + +

noone

+

It may seem odd, but many times while programming your games will you find the need to check if there are no instances found at a location, in a collision, etc. In those cases you would use this keyword to check for nothing, something like this:

+

if (instance_nearest(x, y, obj_enemy) != noone)
+ {
+     //do something as there is an enemy instance near
+ }

+

In this example, the function instance_nearest will return either noone or the nearest found instance. Basically, any time that you need to check for an instance, you can expect to get either noone or an instance returned.

+

This can also be useful in combination with a with statement: 

+

with (instance_nearest(x, y, obj_enemy))
+ {
+     //do something as there is an enemy instance near
+ }

+

If the function returns an instance, the code between the curly braces { } will run once. If the function returns noone, the code won't be executed.

+

You can also assign noone as a value to a variable to store the result of such a function: 

+

Create Event

+

ins_last_collided_with = noone;

+

Collision Event

+

ins_last_collided_with = other.id;

+

 

+

 

+ + + + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm new file mode 100644 index 00000000..fc8953f3 --- /dev/null +++ b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/other.htm @@ -0,0 +1,143 @@ + + + + + + other + + + + + + + + + + +

other

+

other has two definitions:

+ +

other has multiple ways that it can be used to reference a specific instance or struct: it can be used in a with statement, in a collision event, or in a function. This page is going to explain the last two use cases.

+

Collision Event

+

A collision event can only happen between two instances. You can have multiple collisions between multiple instances, but they are all resolved by GameMaker on a 1-on-1 basis, with the "self" instance that has the collision event and the "other" instance that is colliding with it.

+

Imagine you have a player instance, multiple enemy instances and multiple bullet instances that the enemy can fire at you. You can assign each enemy a single bullet instance but with a different damage variable randomly assigned to it when created, for example:

+

var bullet;
+ bullet = instance_create_layer(x, y, "Bullets", obj_Bullet);
+ bullet.damage = 5 + irandom(5);
+ bullet.speed = 8;
+ bullet.direction = point_direction(x, y, obj_Player.x, obj_Player.y);

+

You can see how we set its variables using the dot notation as outlined in the section on Addressing Variables In Other Instances. This will give each bullet instance a different damage value, but how will the player detect the damage that it has to take when it's hit by a bullet?

+

For this, the player will need to have a collision event with obj_Bullet, and within that event use other to read variables from the colliding bullet instance:

+

hp -= other.damage;
+ if (hp <= 0) instance_destroy();

+

The above code will deduct the amount stored in the other instance's damage variable from the player's hp variable, then it will check to see if the hp is lower than or equal to 0. If it is then it will destroy the player instance. Please note that the other instance must have the variable being checked or else an error will be thrown.

+

 The Collision event is the only event that has a special meaning for the other keyword. In all other events and scripts, the behaviour of other will be defined by the context it is being used in (such as a with() block, a function, struct declaration, etc.).

+

You can assign values to variables, or even create new ones, using other in the collision event, like this:

+

// add ten to the other instance's "mana" variable
+ other.mana += 10;
+ // set the other instance variable "hit" to true, creating the variable if it doesn't already exist
+ other.hit = true;

+

When 'other' changes

+

The page on self contains a section on When 'self' changes.

+

This section will describe those cases in relation to how other changes:

+ +

Struct Declaration

+

Scope doesn't change inside a struct declaration, so other refers to the same scope as self (the current scope), meaning the struct or instance that's initialising the struct:

+

var _struct =
+ {
+     parent_instance : other
+ }
+
+ show_debug_message(_struct.parent_instance == self);
+ // This prints '1' (true) meaning that both sides refer to the same instance +

+

However, you do not need to use other to read variables from the instance as any variables you reference directly will be read from that instance's scope, as described in this section of the manual. You would only need to use this if you wanted to store a reference to that instance's struct.

+

'other' as a reference

+

The page on self contains a section on 'self' as a reference with an example, which you should read before this section. This will cover that same example and how it would affect the other reference.

+

Both rules covered on the aforementioned page regarding storing self as a reference also apply to storing other as a reference. However other would be the previous self as it would be if self was stored.

+

Let's take that same example and replace self with other:

+

name = "instance";
+
+ struct = {
+     name : "struct",
+     other_ref : other,
+     other_name : other.name
+ }
+
+ show_debug_message( struct.other_ref.name );
+ show_debug_message( struct.other_name ); +

+

This prints:

+

instance
+ instance

+

The base scope in the code example is an instance, so with self changing in other_ref it stays as the instance scope (which was the "previous" scope) and for other_name it also remains the instance scope as the self there is unchanged and there is no previous scope before the instance (as it is the base scope).

+

However, what would happen in the second case if there were another scope before the instance scope?

+

We can answer that question by placing this code inside a with() block:

+

name = "other_instance";
+
+ with (inst)
+ {
+     name = "instance";
+
+     struct = {
+         name : "struct",
+         other_ref : other,
+         other_name : other.name
+     }
+     
+     show_debug_message( struct.other_ref.name );
+     show_debug_message( struct.other_name );
+ } +

+

This prints:

+

instance
+ other_instance

+

In the first case, as self changes to be the struct, the instance that is inside the with() block becomes the previous scope and is stored in other.

+

However in the second case, as self remains the with() instance, other retains the scope before that, which is the base scope ("other_instance"). You can visualise the hierarchy of scopes as such:

+

other_instance
+  > instance
+    > struct

+

 

+

Instance Method

+

Using other within another instance's method refers to the instance that called that method.

+

For example, let's say Object2 has a method that references self and other. This method is then called in Object1. Since the method was created in Object2, it is bound to it and will always use the Object2 instance as the "self", no matter which instance calls it. In such a case, the calling instance becomes other.

+

// In Object2
+ my_method = function()
+ {
+     show_debug_message(object_get_name(self.object_index));
+     show_debug_message(object_get_name(other.object_index));
+ }
+
+ // In Object1
+ Object2.my_method(); +

+

This would cause the instance to first print its own object name ("Object2") and then the object name of the calling instance ("Object1").

+

The same will apply to a method that is bound to a struct.

+

 

+

 

+

 

+ + + + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/self.htm b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/self.htm new file mode 100644 index 00000000..c5924765 --- /dev/null +++ b/Manual/contents/GameMaker_Language/GML_Overview/Instance Keywords/self.htm @@ -0,0 +1,86 @@ + + + + + + self + + + + + + + + + + +

self

+

self is the struct or instance that is the current scope of the code being executed. For object instances this will be a struct as well, containing the variables for that instance.

+

The current scope can be changed within an event or function using a with block, in which case self can be used to target the new struct or instance that is now in scope. For example:

+

var val = 100;
+ with (instance_create_layer(x, y, "Instances", obj_Fire))
+ {
+     self.val = val;
+ }

+

In this example you can see that we have a local variable called val and we want it to set the instance variable with the same name in the newly created object instance. To identify the instance variable correctly and tell GameMaker to set it in the instance calling the code block, we use the self keyword.

+

self is used in the same way with structs to reference member variables of the struct. It can also be used within constructor functions to reference the struct being generated from the constructor.

+

When 'self' changes

+

Within an event, the current self will change in the following situations:

+ +

In all of these cases, when self changes to a new scope, other will be set to be the previous scope. The only exception is when a bound constructor method is called. This is described more in When 'other' changes.

+

Notes

+

 You can also use the id built-in instance variable instead of self, but self offers certain benefits. To start with, it is faster for the compiler to identify the instance (or struct) using self rather than id, as the id value goes through the instance lookup table while self does not. Secondly, for those people making extensions, it is very useful to ensure the correct scoping of variables, since it is possible that a project which uses an extension may have a global scope variable or something with the same name as a variable in the extension.

+

 The self keyword is not a shortcut for the actual handle of an instance and should only be used in the context explained above. If you require the ID handle for an instance then you need to use id

+

 The self struct of an instance will be destroyed when its instance is destroyed (either manually or as a result of a room ending), however it will be kept alive if there are any references to the self struct itself or any resources within the self struct (e.g. arrays, methods, structs). This may cause unintended issues in addition to a possible memory leak. To avoid this in case of a struct reference, you can create a weak reference.

+

'self' as a reference

+

When self is used in a struct literal, there are two rules that define its scope:

+
    +
  1. When stored as a reference (just self) to be read later, it stores the scope of the struct being created
  2. +
  3. When a value from it is accessed, it is read from the scope that is creating the struct, not the struct itself
  4. +
+

Consider the following code that is run in an instance:

+

name = "instance";
+
+ struct = {
+     name : "struct",
+     self_ref : self,
+     self_name : self.name
+ }
+
+ show_debug_message( struct.self_ref.name );
+ show_debug_message( struct.self_name ); +

+

This sets a name variable in the instance, then defines a struct with a name variable as well.

+

In the struct, it creates two more variables: one that stores self (rule 1 above) and one that reads name from the current self (rule 2 above).

+

In such a struct declaration, the scope does not change, so in both of these cases you would normally expect them to point to the instance that is defining the struct.

+

However when you execute this code, you get the following output:

+

struct
+ instance

+

The argument for the first call, struct.self_ref.name, where self_ref stores self, resolves to the scope of the struct, instead of the scope of the instance, which was the active scope when self was stored into the variable.

+

This happens as a result of self being stored as a reference in the struct literal which follows rule 1 defined above - with it pointing at the struct.

+

The argument for the second call, struct.self_name, correctly refers to the name of the instance, as self was accessed at the time the instance was the current scope. This follows rule 2 defined above.

+

 These rules also apply when storing other as a reference, see 'other' as a reference.

+

 

+

 

+ + + + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Cameras_And_Display/The_Game_Window/window_minimise.htm b/Manual/contents/GameMaker_Language/GML_Reference/Cameras_And_Display/The_Game_Window/window_minimise.htm new file mode 100644 index 00000000..8274b1ae --- /dev/null +++ b/Manual/contents/GameMaker_Language/GML_Reference/Cameras_And_Display/The_Game_Window/window_minimise.htm @@ -0,0 +1,54 @@ + + + + + + window_minimise + + + + + + + + + + +

window_minimise

+

This function minimises the game window. You can restore it with window_restore.

+

 This is only supported on Windows, macOS and Linux. On macOS the game will not restore with window_restore as execution is paused in minimised state.

+

 

+

Syntax:

+

window_minimise();

+

 

+

Returns:

+

N/A

+

 

+

Example:

+

Key Press - Space event:

+

window_minimise();
+
+ alarm_set(0, 300); +

+

Alarm 0 event:

+

window_restore();

+

On pressing space, this will minimise the game window and set Alarm 0 to 300 steps. When the alarm is called, the game window will be automatically restored.

+

 

+

 

+ + + + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Cameras_And_Display/The_Game_Window/window_restore.htm b/Manual/contents/GameMaker_Language/GML_Reference/Cameras_And_Display/The_Game_Window/window_restore.htm new file mode 100644 index 00000000..e19a839a --- /dev/null +++ b/Manual/contents/GameMaker_Language/GML_Reference/Cameras_And_Display/The_Game_Window/window_restore.htm @@ -0,0 +1,54 @@ + + + + + + window_restore + + + + + + + + + + +

window_restore

+

This function restores the game window which may have been minimised by the user or using the function window_minimise.

+

 This is only supported on Windows and Linux. On macOS the game will not restore as execution is paused in minimised state.

+

 

+

Syntax:

+

window_restore();

+

 

+

Returns:

+

N/A

+

 

+

Example:

+

Key Press - Space event:

+

window_minimise();
+
+ alarm_set(0, 300); +

+

Alarm 0 event:

+

window_restore();

+

On pressing space, this will minimise the game window and set Alarm 0 to 300 steps. When the alarm is called, the game window will be automatically restored.

+

 

+

 

+ + + + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Maths_And_Numbers/Number_Functions/log2.htm b/Manual/contents/GameMaker_Language/GML_Reference/Maths_And_Numbers/Number_Functions/log2.htm index 16cc24f8..b5bdb3fb 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/Maths_And_Numbers/Number_Functions/log2.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/Maths_And_Numbers/Number_Functions/log2.htm @@ -1,5 +1,4 @@ - @@ -13,12 +12,7 @@ - - - - -

log2

Esta función básicamente pregunta "¿cuántos 2's hay que multiplicar para obtener n?". Un ejemplo común de uso en programación sería calcular el número de bits que se necesitan para representar un número. Para ello calculamos el log2(x) del número, lo redondeamos hacia abajo y añadimos 1 - por ejemplo log2(100) devuelve 6,643856, que redondeado hacia abajo es 6, al que añadimos uno y nos da 7. Así que necesitamos 7 bits para representar 100. También se puede utilizar para describir el crecimiento o la decadencia exponencial. @@ -63,5 +57,5 @@

© Copyright - - \ No newline at end of file + + \ No newline at end of file diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Networking/network_create_server_raw.htm b/Manual/contents/GameMaker_Language/GML_Reference/Networking/network_create_server_raw.htm index 3abfa2f8..f9910da6 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/Networking/network_create_server_raw.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/Networking/network_create_server_raw.htm @@ -48,11 +48,11 @@

Devuelve:

Ejemplo:

var port = 6510;
- server = network_create_server_raw(network_socket_tcp, port, 32);
+ server = network_create_server_raw(network_socket_tcp, port, 32);
while (server < 0 && port < 65535)
{
    port++
-     server = network_create_server(network_socket_tcp, port, 32);
+     server = network_create_server_raw(network_socket_tcp, port, 32);
}

El código anterior intentará crear un server usando TCP a través del puerto 6510. Si ese puerto no está disponible, entonces loop a través de los puertos para encontrar uno que sí lo esté.

diff --git a/Manual/contents/GameMaker_Language/GML_Reference/Variable_Functions/array_find_index.htm b/Manual/contents/GameMaker_Language/GML_Reference/Variable_Functions/array_find_index.htm index 44566e57..5e00db3b 100644 --- a/Manual/contents/GameMaker_Language/GML_Reference/Variable_Functions/array_find_index.htm +++ b/Manual/contents/GameMaker_Language/GML_Reference/Variable_Functions/array_find_index.htm @@ -41,7 +41,7 @@

Example: