text:
Do I need a backend engineer for my studio right now?
I am working on a mobile game that requires a well thought-out backend, because it spans across the healthcare/data science space and we need to be compliant in terms of security/regulations in how we approach this. Think something like Fitbit.
My team is nearly finished with the client-side game aspect; but I am wondering whether I need to take on a short-term contract/part-time backend engineer to create our entire backend infrastructure OR someone who would work on this full-time with our team.
Here is what we would need to do:

Setup our entire backend infrastructure and plug this into Unity
This would require knowing how to handle (transmit/receive) data securely, and also perform computation with that data in the cloud
Set-up an API where other developers can query our data
Set-up our dev ops infrastructure (Docker, Jenkins) for the future

The kicker here is that we are not yet live and are just in a testing phase. I don't want this to be 2-3 weeks of work, with no users for 3 more months while we're working on other aspects of the project, with the dude having nothing to do.
Does this sound like a lot of work? Or could it easily take up a devs time for a month or two? Would a short contract be advisable here, or would it be better to hire someone FT and have them grow with us.

I don't think we can answer this question. We don't know how complex your project is and we don't know anything about the qualifications of your team. And if the know-how gap of your team is regarding what you need to do in order to comply with data protection regulations, then the person you need to hire is a lawyer, not a developer.

Oh, and remember Brooks's law: adding people to a late project makes it even later. You might be more successful with training your team to do all this themselves than with getting in an outsider who knows absolutely nothing about your project and needs everything explained before they can work efficiently.


text:
What are the ascii numbers for shift and control?
I is trying to makey makey a program that will detect when certain keys are pushed. My only problem is that I dont know the nombers that corrospond to the shift key and control keys. I am writing this code for a game. Here are teh codes:
switch(event->keyval) {
    case ?:
        printf("Shift key was pressed");
    break;
    case ??:
        printf("Control key waas pressed");
    break;
}

What can replace ""?"" and ""??""
Also, if possible, my answer SHOULD be able to fit in a char type

To get state of the shift and control buttons in GTK, you need to apply bitwise AND to the event state.
if(event->state & GDK_SHIFT_MASK)
{
    printf("Shift key was pressed");
}
else if(event->state & GDK_CONTROL_MASK)
{
    printf("Control key was pressed");
}

Alternatively, you can use macros (or their values, but please don't) defined in gdkkeysyms.h

#define GDK_KEY_Shift_L 0xffe1
#define GDK_KEY_Shift_R 0xffe2
#define GDK_KEY_Control_L 0xffe3
#define GDK_KEY_Control_R 0xffe4

switch(event->keyval) {
    case GDK_KEY_Shift_L:
        printf("Left shift key was pressed");
    break;
    case GDK_KEY_Shift_R:
        printf("Right shift key was pressed");
    break;
    case GDK_KEY_Control_L:
        printf("Left control key was pressed");
    break;
    case GDK_KEY_Control_R:
        printf("Right control key was pressed");
    break;
}

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
How should I store loaded world chunks in RAM (For my game similar to Minecraft)?
I am trying to replicate a chunk loading system, in C, for my own minecraft like game, though I don't know how. Once chunks are loaded, are they placed in an array, or are there a bunch of variables for each loaded chunk?
In my game, once I load chunks using fread, what should I use to store them? My problem for a two dimensional array for storing chunks, is that the loaded chunks might be separate and not start at zero. Are there any suggestions for storing loaded chunks?
I have a code fragment, solely so you guys will not yell at me for not including code:
    char ChunkFilePath[strlen(CurrentWorld)+32];
    sprintf(ChunkFilePath, "%s/ChunkData/%ld %ld", CurrentWorld, X, Z);
    FILE *ChunkFile;
    if ((ChunkFile = fopen(ChunkFilePath, "r"))) {
        //chunk file exists, Read Chunk file to ???
    }
    if ((ChunkFile = fopen(ChunkFilePath, "w")) == NULL) {
        fputs("Error Loading Chunk (File Not Found)", stderr);
        return;
    }
        /*Chunk does not exist, but any other errors would have been caught
        at this point, so Generate chunk, write generated results to ???*/

Note: The game I am trying to make is purely for my personal use, not for any commercial use.

Edit:

The problem is just an array will not work. Suppose there is a player at 1000000 and another one at -1000000 They would only render 6 chunks around them, but if they shared an array, all the 2000000 blocks worth of chunks that aren't loaded would be taking up memory. I would refer to chunks like LoadedChunk[1000]. How can I handle that?

A struct? How is your data structured? What have you tried so far? Did you generate chunks yourself?

@Ocelot What do you mean

There is not enough context provided so question makes no sense to me. Code is irrelevant and there is almost no information related to the structure of chunks and their layout rules. What does "loaded chunks might be seperate and not start at zero" even mean?

@Ocelot Each chunk would be a 3 dimensional array of blocks, and what that means is if I store chunks as a 2 dimensional array of 3 dimentional arrays, I cannot guarantee that all chunks will be together, and of the player is far from chunk 0, 0, the 2 dimensional array would not start at 0.

So your chunk layout is a 2D grid. What stops you from moving chunks around in the array? You know how to use pointers, right? Make an array of pointers of your chunks, so you can move them around in the array. Then you would be able to displace chunks in the grid in a way that the chunk player is standing on will be the chunk in the center of the grid and then you would be able to load additional chunks at the the edges of the grid when needed.

If you don't want a 2d array of chunks indexed by world position because the player might get very far away from the world origin or you might have negative indexes, then it might be worth to look at other data structures.

A hash table with the coordinates as keys
A 2-d tree which you auto-balance so that the root is always at the player (can also be useful for render order determination, collision detection and many other purposes)
A 2d array of pointers to chunks, where the indices are not relative to the world origin but relative to the player position. If the player moves to a different chunk, you need to shift that array so that the center point of the array is again the chunk the player is in (which doesn't mean that you rebuild the chunks, just that you move the pointers to chunks in the 2d array).
A graph where each chunk has pointers to its four neighbors (as suggested by PSquall in the comments).

Another useful strategy is to use a modulo operator (or bitmasking for power-of-two sizes) to convert the chunk's world position into its position in the loaded array. This effectively makes your loaded cache a torus, with a contiguous square of loaded chunks centered on the player roaming & wrapping around that torus.

Also, in C you need to determine the array length. The render distance might vary, so how can I handle that?

@JulianTiemann If you only know the size of an array at runtime, then you can allocate it at runtime using malloc(sizeInBytes). If you want to resize an array at runtime, you can use realloc.

In addition to the 2d-tree, you could go for a modified 4d tree. The root is the current chunk, the leaves are the 4 adjacent chunks and every leaves has the 4 adjacent chunks as his childen leaves. Changing chunks would mean to make one of the 1st level leaves the root and its missing leaf becomes the old root. When N is your view distance in chunks, this tree would have a depht of  N (better N+1 because of the corner chunks).

@psquall that's not a tree and certainly no 4-dimensional one. I would call that a 2d double-linked list or a matrix-shaped graph.

@Philipp Another problem is chunks are loaded as a circle around the player, so I need to know how to make a 2d array where each column has a different number of members. I found out how to do this but the way I found out might only works for if the number of columns is constant

I do not quite understand hash tables

@JulianTiemann I'm sorry, but I can not adequately explain hashtables to you in just a 600 character comment. If you have any questions about hashtables, please ask them on https://stackoverflow.com, because they aren't a gamedev-specific data structure.

I'd bridge to C++ and use a std::map() and abstract away the process of accessing these voxels, so they can be called by C

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Pass data down to components
In the game I have, I'm using an architecture close to what I've seen of Unity components :

Basically, the universe implements the game loop, entities implement and update method, which always delegates to each entity's components.
Components are where the actual data and behaviors sit, quite like a MonoBehavior in Unity I guess.
And I use this architecture to model my whole game.

I use child classes of Entity as prefabs:
class Player extends Entity {
   constructor() {
      this.addComponent(new Transform())
      this.addComponent(new KeyboardControlledMovement(()
      this.addComponent(new PlayerCanvasRender())
      this.addComponent(new Gun())
   }
}

So, I get this kind of Universe - Entity - Component tree :

Question time!
Aside from the entities and the components, there exist Settings, such as ell the key bindings, the reference to the output canvas, the player buffs, ...
They all have to reach various components, and I don't know how to get them there.

So far, I've thought of several possible solutions:

Passing data in parameter of the entities' and components' constructor would be a KISS way of cascading external values. It looks like — if it isn't actually — manual dependency injection. However, in order to — as an example — feed the BulletCanvasRender with a reference on the canvas it has to draw on, it has to be passed through the Gun component, which has nothing to do with rendering; I'm mainly afraid of code cluttering here.
Until now, I've been using the universe as a global crap-bag. This is great since it eliminates the boilerplate associated with manual dependency injection, but it makes the universe initialization function quite large — plus, I have to come up with names for all those new settings properties...
Another option would be to switch to real ECS architecture by completely separating the raw data, which would stay in the components, from the behavior, which would go into external systems, and make use of the external settings from only within the systems. I would still have to perform some kind of manual dependency injection, but it would be limited to a set of non-nested systems. I don't like this solution either since it would cause quite a big change in the code.
Using an DIC, or a service locator to create all the components — or at least those that require injected data.

IMO, the main problem here is you are trying to have engine do what scripts should be doing and mixing game logic with things like physics together. I am afraid you will need at least some degree of separation between low-level things like rendering and game logic like buffs.

Will you have networking?
I understand that you are probably making a single player game engine. However, thinking about how to deal with the network very, very, very early in the desgin will push you a better architecture... even if your game will not be networked anyway.
Think of a server-client architecture. If you were to build that, you would want to be able to send information about the enetities from the server to the client. To do this, it is convinient that components have value semantics. And for that, it is conveninient that they do not have behaviour and do not depend on external systems (eg. canvas).
The server would have systems that handle the behaviour, and the client would deal with IO (keybindings, rendering, etc...), but they need to work on the same data.
Thus, you implement a "real ECS architecture" plus client-server synchronization of components and you are good to go (well, netcode gets more complicated than that, but that is a great start).

Passing data
To answer you question: All of the above.

"using the universe as a global crap-bag" sound like you should use a Blackboard pattern. Your knowledge sources would be the system that handle the configuration files for keybinding and other settings. You can also have knowledge sources for information generated in game, or even for user input. All the knowledge sources post into the blackboard. In the pattern the control is supposed to call the knowledge sources. The game loop will do that.
"Using an DIC, or a service locator", you can have it takes information from the blackboard.
"Passing data in (...) constructor"
You can start your by adding the constructors and passing data down the hierarchy.
You then change the creation of components to a call ot Universe.Create or something like that. Then universe looks at the blackboard, picks the data, passes it in the constructor... but there would still be things that needs to be passed from the parent object.
You can pass a resource locator as parameter in the constructor, so that components can take from it the data it wants, while the parant object can pass other data in other parameters of the contructor.
However, do not pass externals to components. Instead...
"switch to real ECS architecture". Did I say components above? Oh, no. That is how you create systems, not components. Your systems should create the entities and attach the components. Then your game loop calls the systems, the systems query the entities depending on the components, and they run some code.
Your knowledge sources are systems!

Physics
Let us pretend we do not want to use systems.
Currently, you would have entities that has Transform, which I am guessing defines thier position. I suppose you would want to add colliders for physics. So, let us pretend you have those too...
Perhaps you want to add a physics component. Since you do not have systems. Perhaps the physics component has the colliders
Your physics simulation would update the transforms. No problem there. However, you also want to check for collisions. Hmm...
Somehow, you need the physics component to get a list of nearby objects to check collisions against. How?
Besides, that physics component would run per entity. If no information is shared among them, one entity A would find it collides with another entity B, and then entity B finds it collides with entity A. You find the collision twice.
Thus, you need to break encapsulation of the components. They need to know where each other is, and who collided with who. That is not a good design.

Let us pretend we do want to use systems.
The game loop calls the physics system. The physics system queries all the entities with physic components (remember that these physic components are only data). We want a spatial data structure, something where it is easy to get nearby objects.
Two ways to do this:

The Entity Component System allows you to subscribe to changes in components. So your physics system get a notification when a collider is attached, for example. Then the physics system can add the component to the data structure.
The physics system creates and handles all the data it needs, and the components are just references.

Then, the physics system can find candidate collision pairs, check for collisions, and do resolution,

User input and scripted movement.
Pretending there are no systems
Let us say we want to be able to move some objects with user input, or we want them to move in a predefined path, or be handled by AI (path finding et.al.).
However, the physics component wants to handle movement too. That means that these components need to know of each other, and thus would be coupled.
To solve it, you a component for the position, and now the other components only need to know about that one.
Well, if you have components that just store the position, and other components that handle input or do physics simulations, or whatever with that component... you have components and systems, except you are not calling them that.

Make it a system
A system takes the bindings from configuration files, or whatever. There is an input system that needs them. You can choose if you want it to post to a blackboard or you want to pass them directly.
Either way, the input manager system takes external input. It will query for the entities with the control components. Yes, more than one. That way you can handle couch multiplayer.
Now you have a few options:

You are making a game: implement the input manager to directly move the objects.
You are making an engine:

Have the input manager update the control components. Then the game developer can choose to write an input system that takes the control components and moves the position components or whatver.
Just write an input manager and let the game developer call it from their systems and do whatever they want.

I'm sure there are more ways to do this, these are just the ones that I have come up with.

Why entities as just an id
We can implement entities as dictionaries of components. And it works. In fact, somewhere in the ECS there is something equivalent to a dictionary of components per entity.
However, you want to do much more than store components in entities.
You want to query all the entities that have certain components. For example, you want a system that looks for entities that has a position and a model to render them, and another that looks for entities that has a position and a velocity to move them. notice these overlap.
Unless you are ok with each system iterating linearly over all the entities, then those queries means that you want to create some sort of indexes of entities. And you want to make sure that updating the dictionary of components updates the indexes. That means that the dictionay of components cannot be a plain old dictionary, it is a façade to update the internals of the ECS.
Alright, what else does the entity has? Nothing, really. The behaviour should be in the systems, and all the data in the components. If you really want to have multiple kinds of entities, you can add a Tag component. Thus, you do not want entity to be a base class (client code could extend it and use it improperly). Also, composition over inheritance.
Now, the entity needs to point to the indexes to be able to update them, and the indexes point to the entity to be able to return it. We want to decouple that. In order to do so, we move all the logic that handle the indexes and the stored components to another class (called "registry", "scope", something like that). So that the entity only has an id. Now, there is no need for the index to point to the entity, it just stores id.
The design of the "registry" (by any other name) is that of data tables. You can think of the id as the primary key, have a column for each component type and a row for each entity. There are, of course, other optimizations form that idea.

Thanks very much for your answer. I'm currently in the middle of making my own — and probably terrible — ECS architecture.I have the impression I gonna end up with a lot of systems, perhaps one per component, is it a flaw? I also have troubles with the colliders: a circle collider and a polygon collider are both colliders; though they clearly hold different data, thus the inheritance. I've got the impression that the collision system will be a big switch instanceof, or maybe I'm missing a point?

@Odepax a component type per system is not a flaw. In practice it is common to have multiple systems use the same component, or a system that uses multiple components, the ECS architecture will give you that flexibility when you need it. There is a chance your systems are too big, and you need to think about sub systems (composition of systems).

@Odepax I have seen collision handled like that, it works. For an alternative, use the collider type pairs to look up the collision method to handle them in a hashtable or similar. However, depending on the language you are using, that may or may not be a good idea. Edit: if the language does not have delegates or lambda types, you can use an interface an service classes. If it requires late binding or reflection, the switch is probably better.


text:
How can I change the hardness and blast resistance of Minecraft blocks?
I want to make the strength of the iron block and obsidian switch places, along with other changes to block strength and blast resistance. I am not allowed to swap the textures or anything like that. I need to actually change the values of each block.
To do this, I need to know where Minecraft stores the blast resistance and hardness.
Is decompilation required? If so, which class file do I need to look into?

Is it not easier to just retexture the two blocks?

@Bálint there are other changes to blast resistance and hardness I want to make, so retexturing them won't do the trick

Please do not make vacuous edits to bump questions. The Community user will auto-bump questions periodically, so there's no need to vandalize posts to get that effect. If you want to make a quality edit that will actually help attract answers, try adding new information to the question, like some background about what you're trying to do, or samples of how you've tried implementing it thus far.

@DMGregory I really need a fruitful answer, how else will I get one

Once again, bump edits do not help you get answers. Neither does cursing. Making improvements, as described in the comment above, does help attract answers. I won't repeat this again - if you want answers, I recommend following the advice you've been given.

Info: You  gave no information how you are making your mod so I assume you are
  using forge.

All Blocks can be accessed via the Block class.
The attributes you want to change are called:

Hardness: This defines how often you have to mine the block for it to break
Resistance: This defines the Blast resistance

To set these you can use the provided setter functions, e.g.:
Block.obsidian.setHardness(2.5);
or
Block.obsidian.setResistance (25);
See the documentation for full explanation.


text:
Concerns about how to efficiently implement sprite atlas
I currently transform (translate, rotate, scale) a bunch of vertices in my own Java code, then populate an mPositions array and an mTextureCoordinates array, which draws a bunch of different textured sprites to the screen in one GL draw command. Works great.
However, I now wish to move the transformation process away from native Java code and over to the vertex shader, and so I will need to pass into the shader transformation matrices which encode the translation, rotation, and scaling operations for each sprite.
Given my current approach the naive and obvious choice is to introduce another array mTransformations, passed into the shader via a GLES20.glVertexAttribPointer command, which contains a matrix for each and every vertex.
But this way seems a little wasteful for two reasons:

I will have to add the same transformation matrix 6 times per sprite to the mTransformations array since each square sprite is made of 2 triangles (3+3 vertices)
Since I'm now going to use the shader to perform the transformations, the 6 canonical coordinates of each square sprite (two triangles) will be the same for every sprite. In effect I'd have to populate mPositions with the same coordinates over and over for each sprite.

Is there a more efficient way to do achieve what I want?

Why not just use uniforms?

Downvoter please explain.

For those also starting out trying to properly understand GLSL rather than just reuse online code, here's what I learned over the past few days. Note the below points refer to GLSL for GL ES 2.0.
Two key points were:

Get into the GPU mindset. GPU's have 100's or 1000's or cores all working in parallel, and a shader is basically designed to process lots of data via a Vertex Buffer Object (VBO) and process them in parallel.
uniform's are limited in number. I think I read somewhere that the Intel chip sets have a 16kb limit, whereas AMD/Nvidia have a 64kb limit, and I generally get an error if I try to use more than 1024 uniform's.

I managed to solve my original problem by passing in a VBO of vertexId's via attribute float a_vertexId. I could then get the spriteId using a_vertixId / 6 and the vertexId using a_vertexId - spriteId * 6. This enabled me to index into a uniform of canonical square vertices, which meant I didn't have to upload sprite vertices any more.
I was also able to address texture uv coordinates in this way too. I just sent up a texture ID per vertex via attribute float a_texId, then used the spriteId, vertexId, and a_texId to index into a uniform texture coordinates array. Even given the limits on the number of uniform's allowed this is able to cope with around 1000 different textures per sprite atlas.
For the transformations, I just sent up the transfer parameters (per-vertex), i.e. (tx, ty, angle, scalar) and applied the following matrix inside the vertex shader:
$$\left(
\begin{array}{cccc}
\sigma\cos(\theta) & -\sigma\sin(\theta) & 0 & t_x \\
\sigma\sin(\theta) & \sigma\cos(\theta) & 0 & t_y \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1
\end{array}
\right).$$
Ideally, it would be best to upload a per-sprite array of transformation matrices as a uniform, and use spriteId to index into that for the per-vertex processing. However, as mentioned above, given that we could have 1000's of sprites means that this just isn't possible. I have heard of Shader Storage Buffer Objects (SSBO's) in ES 3.0, but from what I've read, they're not always available in the vertex shader.
In general, I realised performance will differ between systems, and there will be a trade-off between data upload, and CPU vs GPU processing, so ultimately I'm going to create a few different sprite batch shaders and do some tests to see which ways work best.
Anyway, hope this helps someone.
UPDATE
In the end I used two shader programs, (i) a GL_TRIANGLES batcher for "dynamic" sprites that required rotation, scaling, translation, with transforms performed on the GPU as described above, and (ii) a GL_POINTS batcher (i.e. Point Sprites) for "static" sprites (such as background tiles) that required only scaling and translation (but not rotation); then again, it is possible to program the fragment shader to perform rotations on point sprites, but this is slow and comes with it's own limitations, e.g. it's the point sprite texture uv coordinates that are rotated and not the vertices so you have to be careful how you set up your sprite textures to avoid local boundary clipping.


text:
How to keep track of (count) vertices processed so far in GL ES SL 2.0 vertex shader?
I'm trying to learn how to use GLSL ES 2.0.
In OpenGL ES 2.0, there is no gl_VertexID keyword to obtain the number of vertices processed so far. So I was wondering if there's a way to make my own counter. I know the vertex shader is executed "per vertex," so if I can increase a counter which persists between executions then that will meet my case.
Now I know I can't use a uniform because by definition they cannot be altered.
So I thought about using an attribute, assuming the value will persist between vertex shader executions, but when I write
attribute int a_vertexCounter;

in my vertex shader, the shader compiler says that an attribute cannot have the type int.
So I thought maybe if I make a_vertexCounter a vec3 for example, and increment the first component of that vector instead... This works, except that when I try
gl_Position = u_MVPMatrix * u_canPos[int(a_vertexCounter.x)];

the compiler says
Error compiling shader: 0:23: S0027: Cannot modify an input variable

I also tried setting my attribute variable to be of type ivec3 but the shader says that's not allowed either.
Maybe there's no way to do this without ES 3.0, where I could simply use gl_VertexID ?

Remember that the whole reason to use a GPU is to process data in parallel. So you can't just increment a counter for each vertex processed serially: you might have hundreds of vertices all being evaluated "first". Have you considered adding an ID to each vertex in your vertex buffer instead, so you can just read the stored value as you would with a texture coordinate?

@DMGregory since all my sprites are square they have the same 6 vertices, so it seems inefficient to pass in any vertices at all. Would prefer to store 6 vertices in a uniform then just use the gl_VertexID % 6 (or some ES 2 equivalent) to access the appropriate vertex from the uniform. Sprites would get transformed via matrices I will pass in as an attribute buffer. Maybe there's no way to achieve this without OpenGL ES 3 then? Or maybe that won't even work given things may happen in parallel. Perhaps I have no choice but to pass in 6 canonical vertices per sprite?

Depending on your needs, point sprites might be an option. Otherwise it sounds like you could get away with sending just one number per vertex instead of 3 coordinates, and then look up the corresponding vertex properties from your uniform array as you describe with that one number.

@DMGregory not sure I can use Point Sprites, as my sprites could be any size (unless I misunderstood  what I read here: http://www.informit.com/articles/article.aspx?p=770639&seqNum=7). But I like your second point. I thought I might be able to get away with sending no point information then looking up the required vertex from the uniform but seems this is not possible then. Your solution of just sending in an id which indexes into the uniform would work. Thank you. New to all this, so just reading up on this: http://glslstudio.com/primer/

If you make it work, be sure to post your solution as an answer!

Given @DMGregory's comment I realised I couldn't just count the current vertex number inside the vertex shader, because GPU's run in parallel, and can have 100's or 1000's of cores working all at once so there could be any number of vertices being processed simultaneously.
To solve this I passed in an attribute float a_vertexId, where the corresponding VBO is:
vertexIdBuffer = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, ...}

Inside the vertex shader you can then do something like the following:
int spriteId;
int vertexId;

void main()
{
    spriteId = int(a_vertexId) / 6;
    vertexId = int(a_vertexId) - spriteId * 6;

    ...
}

I can then use the spriteId to access some uniform canonical vertices for a square (representing the sprite), without the need to upload 6 vec3/vec4's (a square is two triangles, 3 + 3 = 6 vertices)
Note I could not pass in an attribute int which would be preferable because GL ES SL 2.0 does not support it, nor does it support the % operator, hence the elaborate modulo math in the main() function.


text:
Which is a better way for moving 3d objects in OpenGL?
I'm learning OpenGL, and I'm a bit confused. I've just learned about projection and modelview matrices which can be used for moving things. This is the first way, which is convenient if I want to move everything. The other way is to calculate the new coordinates, and rebuffer the data. The second one seems a bit inefficient, because I have to rebuffer every single moved objects 60 times per frame. This has an advantage: I know the exact coordinates, and I  can check collision, and other stuffs. If I move my character with manipulating the matrix, how do I know if I hit the wall or not? Should I make the same calculation as the shader, and get the 'real' position?
Which is more practical and efficient solution?

Move the camera.

Mix of the both: move object for game logic, move the origin/camera (modify modelview matrix) for drawing.
As you said, recalculating the vertex buffer every frame is not going to be efficient, to put it lightly.
Imagine a 3D RTS game with hundreds of units on the map. One way is to create vertex array for each unit. You'll need to prepare and send [number of vertices] x [number of units] values to GPU. Other way is to store the model in GPU RAM buffer, and tell the GPU to draw the contents of the buffer at specific coordinates/rotation (so you only send 4x4 matrix for each unit, regardless of its model's number of vertices).
First one should be fine for a small game, but if you scale it up, second is the way to go (especially if you start using shaders, uniforms, skeletal animation and other nice looking stuff).

If I understand you well, you are saying the following: let's say I have a [2;2;2] position. I want it to be on the [3;3;3] position, so I store the second on cpu side, the first one stays at the gpu's memory, and I pass a matrix to the shader to look like it's on the [3;3;3]?

Exactly. Objects in your game are made of position, colliders (or anything else you need for physics), and model/sprite. Each frame you update position and resolve physics on CPU, and then tell the GPU to draw the model/sprite on specific position. If your model has its origin at the feet, and by objects position you mean its feet, then this way you'll be able to easily draw it correctly.


text:
How to fix double click problem in this code?
Please see the gif below to better understand what's going on.

On first click they all work normally but after first click I have to double click them to select them. I'm not a advanced developer so I've been trying to figure this out for straight 2 hours and last choice I wanted to ask you guys.
I declared select effect here. (White circle) And added an Array to get all select effects.
    public GameObject selectEffect;
    private bool isSelected = false;
    public GameObject[] selectEffectArray;

I put them inside the Array.
    private void Awake()
    {
        selectEffectArray = GameObject.FindGameObjectsWithTag("planetSelected");
        selectEffect = transform.Find("selectEffect").gameObject;
    }

I deactivate all select effects on start.
    void Start()
    {
        Deactivate();
    }

Here's Deactivate code.
    void Deactivate()
    {
        foreach (GameObject effect in selectEffectArray)
        {
            effect.SetActive(false);
        }
    }

When I click one of the planets these happens. (I'm a little confused so I hope you can understand it.)
    void OnMouseUp()
    {
        if (isSelected)
        {
            selectEffect.SetActive(false);
            travelbutton.SetActive(false);
            isSelected = false;
        }
        else
        {
            Deactivate();

            planetName_text.text = planet.name;
            requiredFuel_text.text = planet.requiredFuel.ToString();
            travelbutton.SetActive(true);
            selectEffect.SetActive(true);
            isSelected = true;
        }

    }

I don't want to double click a planet to select it.

What happens here is basically this:
When you click on a planet for the first time, isSelected is set to true. Then you click away, but since you don't check whether other planets were selected, isSelected remains true. The next time you try to select it, it first detects, that it is indeed the current active planet (based on the variable) and deactivates itself.
Instead of letting every planet handle this themselves, you need to make sure they consult with a parent object. Let's call it SelectionManager.
Every time a planet detects a click, send a message to the selection manager. This should set the selected planet to the one that sent the message:
class SelectionManager
{

    private GameObject selected = null; // null means no gameobject is currently the chosen one

    public void HandleSelection(GameObject planet)
    {
        if (selected == planet) // The user clicked on the selected planet again
        {
            selected = null;  // Deselect the planet
        }
        else
        {
            selected = planet;
        }
    }

}

And inside the planet gameobjects:
public SelectionManager selectionManager; // Set this using the drag 'n' drop feature

//....

void OnMouseUp()
{
    selectionManager.HandleSelection(this);
}

You can get the currently selected planet from the selection manager.


text:
Auto key bones with controller helpers
I have skinned and rigged a human character with IK / FK and helper objects to control the position of the IK goals and the rotation of the bones. For example, the characters' left arm IK goal is parented to a point helper, to make it easier to select and move around and the arm IK solves accordingly.
I have the skeleton (without the helpers) set up as an avatar in Unity and I want to use this rig to create and export animations to work with the avatar.
I create animations by moving the helpers in Auto Key mode in 3DS Max, so that when the helpers move, their new transform details (pos, rot, scale) are recorded in key frames.
My questions is this: using Auto Key only records the transform of the helpers I'm moving, it does not record the bone transforms, even though they have been changed by moving the linked helpers. Is there any way to record bone positions using Auto Key with this rigging method, or do I have to select the affected bones every time a movement is made and use Set Key?

Found the answer - bake the animation when exporting as fbx. This includes the movement of the bones even if they were not keyframed.
Select all bones > Export Selected, under Animation, tick Bake.


text:
How do I get the full path of Content?
To display an image from Content in a .NET Forms Dialog, I'm trying to make a function that loads an image through .NET's Image.FromFile(string fileName) function, but instead of taking a whole path, it takes the path you'd usually put in Content.Load<T>(string assetName).
For this, I need to be able to get the complete root directory of the Content folder, but how do I get that?
I've already tried Content.RootDirectory, but that seems to give only a relative file path (in my case, it just says "Content" because I left it at default)
Thanks in advance!

There's a few things you need to understand to get this to work.
First, what you're trying to do will be platform specific. So I'm going to assume you're only concerned with getting it working on Windows.
Second, if you're adding content to the Content.mgcb file it will be compiled by MonoGame's Content Pipeline and it will end up in a Content folder as an XNB file relative to the executable.
For example, let's say you've added a texture.png file to your Content.mgcb file. When the game or tool runs the image will be compiled and end up in the following place by default.
 - Game.exe
 - Content
     - texture.xnb

This means that the path relative to your executable would be Content\texture.xnb and you could use the regular C# method Path.GetFullPath("Content\texture.xnb") to get the full path relative to the executable.
Of course, you won't be able to load an XNB file with Image.FromFile(string fileName) because it's not a standard image format. To deal with that what you'll probably want to do is copy the original texture.png file to the output folder.
To do that you can use the Properties of the file and set the Build Action to Content and the Copy to Output Directory to Copy if newer.

Now the texture.png file will be available to load relative to the executable.
 - Game.exe
 - Content
     - texture.png

Lastly, if you want to actually load this PNG file directly into MonoGame without using the Content.Load method you can write you're own method using Texture2D.FromStream like this:
public Texture2D LoadTexture(string filePath)
{
    using (var fileStream = File.OpenRead(filePath))
    {
        var newTexture = Texture2D.FromStream(GraphicsDevice, fileStream);
        PremultiplyTexture(newTexture);
        return newTexture;
    }
}

private static void PremultiplyTexture(Texture2D texture)
{
    var data = new Color[texture.Width * texture.Height];

    texture.GetData(data);

    for (var i = 0; i < data.Length; i++)
        data[i] = Color.FromNonPremultiplied(data[i].R, data[i].G, data[i].B, data[i].A);

    texture.SetData(data);
}

Note: I've also included a method to pre-multiply the texture because this is something normally done by the MonoGame Content Pipeline. If you don't do this the texture won't work properly with AlphaBlend mode.

Thanks for the answer! Aside from the ability to preview the image in a windows form, is there any advantage of using png files over resuming to build them with Monogame's pipeline tool?

I don't understand what you mean by "resuming to build them"?

Oh sorry. I meant resuming to use MonoGame's Content Pipeline tool for managing them in xnb format instead of png. Like is there an advantage of using png's exclusively and circumventing the Content Pipeline Tool entirely?

The Content Pipeline essentially solves 2 problems. 1. It makes content cross platform by compiling it into a known format. 2. It sometimes adds extra information when processing it like premultiplying the alpha channel for rendering. If you want to bypass the Pipeline you can solve those problems yourself and a lot if the time you can easily enough. It really depends on the platforms you're targeting and what kind of content you need to load.

Use Application.dataPath to get the folder of your game, the concatenate the string with "Assets\Resources" or wherever your pictures may be.
https://docs.unity3d.com/ScriptReference/Application-dataPath.html

I feel like now would be a good time to mention I'm not using Unity, but MonoGame. The only classes that seem close to it are System.ApplicationId, System.ApplicationIdentity and System.ApplicationException.

string contentPath = System.Forms.Application.StartupPath + "\\" + Content.RootDirectory;

Did the trick for me. Unfortunately, the files it'll give you are in a .xnb format, making it impossible to pass on to the image of a Windows Form.


text:
Updating transform position after root motion
I have an animation of a character climbing with root motion in it (i.e. the character moves generally upwards for a couple of units during the animation). It is intended as a one shot, not a loop. The skeleton is fairly standard hips > spine 1, hips > right leg, hips > left leg etc. The root is the hips and the pivot is between the soles of the feet.
I know its generally best to make in-place animations without root motion but scripting the upward movement using Vector3.Lerp etc looks unrealistic (in reality when rock climbing for example the upward motion will come in perdiodic bursts as the knees are first bent, then extended, rather than a constant movement upwards), so I want to keep the root motion in the animation.
Problem is when the animation has finished Unity still considers the transform pivot to be in its original location, before the skeleton climbed up two units. Is there any way to instruct Unity that the new transform position is where the characters feet have ended up after the animation has finished?
I figure I could parent the hips to an empty which moves the charaters around normally, detatch the empty before the root motion climb, move it by the same amount the hips moved then re-attach but is there a less hacky way? Some kind of transform.returnToOriginalOffset method perhaps?

UPDATE
You are right my original explanation is a bit too light in details.
In details, in the root motion the Body Transform and Orientation are stored in the Animation Clip, so when the animation ends you can write a piece of code that gets the new info and translate the transform position to your desired location, just make sure you take in consideration the offset, might move it to the center of the character, if that happens easy fix, you can calculate that as well and move it.
some more info can be found in this link
https://docs.unity3d.com/Manual/ScriptingRootMotion.html

Can you be more specific? Do you mean in the animation itself?

@Absinthe meant was to store it in variable mostly Vector3 via script not in the animation

@DigvijaysinhGohil Thanks but I don't see the point of that. I want to update the transform to the new position of the mesh, not move the mesh back to its original position. If I've misunderstood can you explain in more detail? If you mean script the motion rather than animate it thats exactly what I'm trying to avoid as it will never look as good as an animation.

Firstly, could you tell me if that "Apply Root Motion" checkbox is selected in your characters Animator component?

@Sherlock Thanks, that does work as long as you offset the root back by the amount of overall position change

@DigvijaysinhGohil I just realised what that tick box is for! So, I've solved it by enabling it when starting a root motion anim and disabling it for other anims.


text:
How to make a smooth projectile in roblox?
I am trying to make a projectile (Energy ball) for my game. I am using body velocities, but the issue is is that it seems laggy. I shoot it then half a second through flight it seems to stop in mid air for a quarter of a second then continue. This only happens the first minute of playing.
Here is my code:
local Motion = Instance.new("BodyVelocity", Ball)
Motion.Velocity = ((MouseClickLocation - Player.Character.HumanoidRootPart.Position).Unit*100)

Why is the described behavior happening and how can I make it never happen?

It is a lot more complicated than that. As the ball travels out far enough away from the player, the network ownership changes from the client to the server. This produces very short, laggy moments. Don't ask me why this happens. All I know is that this can be fixed like this: (I am assuming your using a client activated remote event)
--Where ever you try to put the Motion in, replace that with this
Ball:SetNetworkOwner(Player --[[arg from OnServerEvent]])
RemoteEvent:FireClient(Player, Ball --[[so the client knows what to add the velocity to]])

--In the local script
RemoteEvent.OnClientEvent:Connect(function(Ball)
    local Velocity = Instance.new(BodyVelocity, Ball)
    Velocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
    Velocity.Velocity = game.Players.LocalPlayer.Character.PrimaryPart-game.Players.LocalPlayer:GetMouse().Hit.P
end)


text:
Easiest way to make a button in Gamemaker Studio 2
I want to make a menu for my title screen where the user can click on the option they want. The only way I can think of doing this is by making an object that checks if there is a click and then checks if the mouse is on top of it. This feels like a really round-about way to do this. Is there an easier way? I don't yet know how to use the GML so, please use DnD.

Use the Left Pressed event:

This way the action will only be performed if there is a mouse click on the object (in this case the button). The click area will exactly match the size of the sprite.
As a matter of curiosity/information:
Since you want to know the simplest way to do this and not the most optimized/functional way, the image shows how to do what you want. This case specifically (clicking a button) is quite simple to convert to GML.


text:
Problems With Opening Room Gamemaker
In Gamemaker, I have a main menu room, and hitting start takes you to the gameplay room. When testing it, it did not take me to the gameplay room. I made it load into the problem room first, and all it loaded was a black screen. I also noticed when I looked in the console it was said:

RequestStats - failed: 2

What's causing this and how do I fix it?
Here is my game:
https://drive.google.com/open?id=1xWota0WfzcwvYGHY4zFVwS0vXDwNQfDp

I have not found out what caused the problem, but I deleted the room, then created it again and readded all the objects, and it fixed the issue. The error in the console has not gone away, but the room loads properly.


text:
How to Make Different Instances of an Object Have Different Sprites
In Game Maker, I am trying to make it so that three instances of an object have three different sprites. Using DnD, what would be the optimal way to do this? If it helps, the three instances are different sizes and are in separate, fixed places.
EDIT: I have added the following, and it gives an error that the global variable has not been set.

What's in the step event?

@boneco It just opens and closes an ini file. I have not worked on that part of my game yet.

Do you try to pass the value of the global variable to this file.ini in the step event?

@boneco No it just opens and closes the ini file every step without doing anything to the file.

Please upload your project to google drive and give me the link. From the images I can not identify what is wrong.

@boneco https://drive.google.com/open?id=1xWota0WfzcwvYGHY4zFVwS0vXDwNQfDp

You have to give me the whole folder. Go to documents, select the game folder, copy it to your desktop, compress it and then upload it to google drive.

@boneco That's what I thought I uploaded. How do I upload what you want?

You just passed me the file.yyp.

@boneco You have the whole file, it just looks like you only have that because folders only show up as flat bars. Hit download all in the top right corner to get the whole file.

I edited my answer. The problem is happening because of the changes you made to the size of the objects in the room. Delete and add them again without making these modifications.

To do this, you will need:

1 controller/administrator/creator object (obj_Hades in my project)
1 global variable (global.number in my project)

The controller object (obj_Hades) will basically serve for you to declare the global variable (global.number).
Note that a sprite contains 3 images/frames:

In the controller object (obj_Hades):

Be careful to place the controller object to be initialized first (see lower left corner of image above).
In the object to have three different shapes:

Remember to set the image_speed variable to 0, so that you don't run an animation.
Result:

Reference:
https://docs.yoyogames.com/source/dadiospice/002_reference/001_gml%20language%20overview/variables/global%20variables.html

If you have separated the images:

Just make use of IF'S.

EDIT 1
Test done with your project:

I deleted the 3 objects and added them again. I realized that the ones you had placed in the room were different sizes, I don't know where you modified them, but apparently that was the cause of the problem.

I have the controller object initialized first as shown in the photo but for some reason, I keep getting an error saying that the global variable has not yet been set.

@K.O. Make an addition showing what you did and add to the question.

I have added the additions to the question.


text:
Not able to change Rigidbody 2d gravity scale
I have been trying to change the gravity scale of my Rigidbody2d when I click on it. By default it is by 0 and when I click on it, it should change to 1, so that it falls down. I have a square with a boxcollider2d and a Rigidbody2d and a square with just a box collider.
public bool gravity = false;
public bool m_isRunning = false;
public SpriteRenderer m_spriteRenderer;
private Rigidbody2D rb;

private void Update()
{
    if (gravity)
    {
        rb.gravityScale *= -1;
    }
}

private void Start()
{
    m_spriteRenderer = this.GetComponent<SpriteRenderer>();
    rb = GetComponent<Rigidbody2D>();
}

private IEnumerator Changecolor()
{
    yield return new WaitForSeconds(1);
    int random = Random.Range(1, 4);

    if (random == 1)
    {
        m_spriteRenderer.color = Color.blue;
    }
    else if (random == 2)
    {
        m_spriteRenderer.color = Color.red;
    }
    else if (random == 3)
    {
        m_spriteRenderer.color = Color.green;
    }
    else
    {
        m_spriteRenderer.color = Color.yellow;
    }

    this.StartCoroutine("Changecolor", 3f);
}

private void OnMouseDown()
{
    gravity = true;
    m_isRunning = !m_isRunning;

    if (m_isRunning)
    {
        StartCoroutine("Changecolor", 3f);
    }
    else
    {
        StopCoroutine("Changecolor");
    }
}

This line, from inside your code's update method:
rb.gravityScale *= -1;

is setting gravity scale to current gravity scale times -1. Since you have set gravity scale to start as 0 this highlighted statement is evaluating to gravity scale 0 times -1. So ultimately the gravity scale is being repeatedly set to 0.
Changing that line to:
rb.gravityScale = 1;

This code will now directly set gravity scale to one and you should see the object fall.

if you have no need to toggle the gravity back off you can simply replace the line in OnMouseDown() bool gravity = true; with rb.gravityScale = 1;  and remove the gravity bool and the if(gravity) check in the Update method.
public bool m_isRunning = false;
public SpriteRenderer m_spriteRenderer;
private Rigidbody2D rb;

private void Start()
{

    m_spriteRenderer = this.GetComponent<SpriteRenderer>();
    rb = GetComponent<Rigidbody2D>();
}

private void OnMouseDown()
{
     rb.gravityScale = 1;

    m_isRunning = !m_isRunning;

    if (m_isRunning)
    {
        StartCoroutine("Changecolor", 3f);
    }
    else
    {
        StopCoroutine("Changecolor");
    }
}


text:
Way to Get Collision Box Width Gamemaker
I was coding the wall collision system for my game, and I wanted to do it using intersect boundaries instead of checking every step if they are off the screen. When the player crosses the boundary they get moved back to half of the sprite, but because the intersect boundary uses the collision box, it appears to jitter when you walk into the wall. Is there a way to get the width and height of the collision box so I can move them half of that away from the wall?

You can get an instance's bounding box edges position by using the read-only bbox_* variables: they are expressed in world coordinates and can be used for your collision resolution purpose.


text:
Controlling loop frequency in a Coroutine
I want this coroutine to execute continuously and change the colors. But right now it just waits 1 second at the start and then loops the Coroutine very fast.
So my question is how can I loop the Coroutine every 2 seconds.
public class control : MonoBehaviour
{
    public bool gravity = false;
    public bool m_isRunning = false;
    public SpriteRenderer m_spriteRenderer;
    private Rigidbody2D rb;

    private void Update()
    {
        if (gravity)
        {
            rb.gravityScale = 1;
        }

        StartCoroutine("Changecolor", 3f);
    }

    private void Start()
    {
        m_spriteRenderer = this.GetComponent<SpriteRenderer>();
        rb = GetComponent<Rigidbody2D>();
    }

    private IEnumerator Changecolor() <--- this coroutine
    {
        yield return new WaitForSeconds(1);

        int random = Random.Range(1, 4);
        if (random == 1)
        {
            m_spriteRenderer.color = Color.blue;
        }
        else if (random == 2)
        {
            m_spriteRenderer.color = Color.red;
        }
        else if (random == 3)
        {
            m_spriteRenderer.color = Color.green;
        }
        else
        {
            m_spriteRenderer.color = Color.yellow;
        }

        this.StartCoroutine("Changecolor", 3f);
    }

    private void OnMouseDown()
    {
        gravity = true;
    }
}

You're making the classic mistake of starting a new coroutine every frame in Update.

So in your first frame you start a coroutine, which waits one second.
Then in your next frame, you start another coroutine, which waits one second. Meanwhile the first has only 1 second minus 1 frame left to wait.
In your third frame, you start another coroutine...
...
After one second, your first coroutine finishes waiting, and changes the colour, then itself starts another coroutine.
The very next frame, your second coroutine finishes waiting, changes the colour, and starts another coroutine...

So you change the colours every frame after the initial delay, and gradually fill up your memory and frame time with unwanted copies of the coroutine.
You can do all of this much simpler.
// Lookup table for colours.
static readonly Color32[] randomColors = new Color32[] {
    new Color32(0, 0, 255, 255),  // Blue
    new Color32(0, 255, 0, 255),  // Green
    new Color32(255, 0, 0, 255),  // Red
    new Color32(255, 255, 0, 0)   // Yellow
}

public bool gravity = false;
public bool m_isRunning = false;
public SpriteRenderer m_spriteRenderer;
private Rigidbody2D rb;

void Start()
{
    m_spriteRenderer = this.GetComponent<SpriteRenderer>();
    rb = GetComponent<Rigidbody2D>();

    // Start the coroutine just once, in Start. Call it directly, not via a string.
    // You can pass your desired loop delay as an argument.
    StartCoroutine(ChangeColor(2f));
}

IEnumerator ChangeColor(float loopDelay) {
    // Loop this one coroutine instance forever.
    while(true) {
        // Select a new random colour from the array.
        int colorIndex = Random.Range(0, 4);
        m_spriteRenderer.color = randomColors[colorIndex];

        // Wait the specified duration before looping again.
        // Move this to the top of the loop if you want a delay before changing colour the first time.
        yield return new WaitForSeconds(loopDelay);
    }
}

void Update() {
    if (gravity) {
        rb.gravityScale = 1;
    }

    // Do not start ever more copies of the coroutine here.
}


text:
unity update boolean from other script
So my problem is that the color of the sprite should only change if the Boolean is true. My theory is that the Boolean isn't being update. So how do I update the Boolean the whole time and see if it is getting changed.
Thanks Guys,
 public class controlborder : MonoBehaviour
    {
        private SpriteRenderer m_spriteRenderer;
        public float loopdelay = 2f;
        public static bool startstop;
        public void Start()
        {
            m_spriteRenderer = GetComponent<SpriteRenderer>();
            StartCoroutine(Changecolor(2f));
        }
        public void Update()
        {
        }
        private IEnumerator Changecolor(float loopdelay)
        {
            while (true)
            {
                startstop = control.changecolorborder; <== this bool
                Debug.Log(startstop);

                while (startstop)
                {
                    yield return new WaitForSeconds(1F);
                    int random = Random.Range(1, 4);
                    if (random == 1)
                    {
                        m_spriteRenderer.color = Color.blue;
                    }
                    else if (random == 2)
                    {
                        m_spriteRenderer.color = Color.red;
                    }
                    else if (random == 3)
                    {
                        m_spriteRenderer.color = Color.green;
                    }
                    else
                    {
                        m_spriteRenderer.color = Color.yellow;
                    }

                }
            }
        }
    }

This looks very similar to your previous question. Please consider editing your existing question rather than posting a new one about the same basic issue (not knowing how to reference variables between script instances)

I'm not sure about the intent of your code and what 'control' is in this context.
However, I think you are missing a yield return null; in the outer while(true) loop. Following your current logic, once you set startStop to false, nothing will be able to alter control.changecolorborder anymore because your code is stuck in that outer while loop constantly setting startStop to false over and over again...
I'm not sure if this is clear to you, but in case it is not, coroutines are not multi threaded and do not run asynchronously. They are run on the same thread in Unity. With yield return ...; you can halt the coroutine so that it can continue executing later (Unity decides how much (frames) later it will continue executing your method depending on what you yielded). Once you yield, your other code (Update, etc.) can run. If you never halt your coroutine (by yield returning something), your other code can't execute as it is still waiting for your coroutine to either finish or yield.
See also: the manual on coroutines.


text:
reseting timer unity
So I have been trying to reset this timer but for some reason I can't figure out why it isn't resetting.
Thanks,
public class controlborder : MonoBehaviour
{
    //varibles
    public static int time; //<== here I create my timer
    public static int random;
    public static bool boolreset = true;
    //varibles
    //get objects
    public SpriteRenderer m_spriteRenderer;
    //get objects

    public void Start()
    {
        m_spriteRenderer = this.GetComponent<SpriteRenderer>();
        StartCoroutine(Changecolortimer(2f));
    }

    IEnumerator Changecolortimer(float loopdaelay)
    {
        while (boolreset)
        {
            yield return new WaitForSeconds(1);
            time++; //<== here is set a interval
            if(time == 3)
            {
                boolreset = false;
                resettime();
            }
        }
    }
    public void changeColor()
    {
        if (random == 1 && time == 1)
        {
            m_spriteRenderer.color = Color.blue;
        }
        else if (random == 2 && time == 2)
        {
            m_spriteRenderer.color = Color.red;
        }
        else if (random == 3 && time == 3)
        {
            m_spriteRenderer.color = Color.green;
        }
        else if(random == 4 && time == 4)
        {
            m_spriteRenderer.color = Color.yellow;
        }
    }

    public void Update()
    {
        random = Random.Range(1, 4);
        changeColor();

    }

    public void resettime()
    {
        time += 0;
        boolreset = true;
        Debug.Log(time);
    }
}

In your resetTime function you are using the "+=" operator, which adds onto the variable's current value, rather than assigning it directly to the specified value. See this example to understand the difference between += and = operators:
int x = 1 //declaring int, initial value is 1
x += 5    // this evaluates to "x = x + 5", so x's value is now 6
x = 999   // this evaluates to "x = 999", setting x's value directly to 999

In the resetTime() method you are adding 0 to the current value of time, not setting time to 0. Change that line to use the = operator instead of the += operator and you should get the desired behavior.


text:
change color to rgb in c# unity
So I am trying to change my color of my sprite to a rgb color. Now I can just change it to a color like red, black or blue...
 m_spriteRenderer.color = Color.blue;

Thanks,

You can pass the color you want to the constructor of the Color object.
Here is a copy of the documentation's example:
using UnityEngine;

public class Example : MonoBehaviour
{
    void Start()
    {
        Color newColor = new Color(0.3f, 0.4f, 0.6f);
    }
}

You can also use it like that:
Color newColor = new Color(0.3f, 0.4f, 0.6f);
m_spriteRenderer.color = newColor;

You can see an example of how it can be used in the documentation of the SpriteRenderer.color function.

If you find it easier to think of colours in byte values, you can use new Color32(127, 63, 0xFF). These 32-bit colours will implicitly convert to and from the floating point color type, so you can use whichever is clearest for your needs.


text:
Higher order splines for use with pathfinding
In this page, Amit explains that splines can be used to achieve movement on a found path.
In the picture below, he explains that:

The blue paths use splines, with dark blue being low order splines and
  light blue being a higher order spline.

What are exactly high order splines? How to achieve the light blue movement?

A spline is a curve built from a number of conjoined polynomial equations. Higher order splines are splines built of higher order polynomials. Generally speaking the higher the order, the more fluid the curve (sort of), with linear splines being a series of straight lines.
Here are some examples or different orders (from the Wikipedia page on Bézier curves, a type of spline).
Linear:

Quadratic:

Cubic:

These GIFs show generally how these curves are constructed, and higher order = more control points. In Amit's example, those control points are consecutive points along the path, so a higher order spline means that there is a smoother interpolation along a larger set of those points at a time.
Put another way, instead of looking at just the next point to move toward (linear), it might look at the next two points (quadratic) or next three points (cubic). This allows for more natural movement of your game entities along the path that has been constructed - the underlying logical path doesn't change, just the actual movement on screen.
There is more information on the Wikipedia page about how to construct these curves.

Great thanks for your explanation, it works! Now I realise that I also need to be able to "join" multiples curves to follow a long path, but I will open a new question for that :)


text:
Way to Reset Varible After Collision Resolution
I have some code that, if a player is in contact with the wall, prevents the player from moving.

Is there any way with this code to reset the collide variable, and if not, what would be the simplest alternative.I have tried resting it at the start of the step but that did not work.

I would suggest doing a different approach to this question.
Assign a place_meeting with some X and Y distance so if your object gets close to the wall, its speeds are reduced to 0, but far from that place, its speed continues to work. Something like:
if (place_meeting(x-3,y,obj_wall)) {
   x +=0
}
else {
   speed (variable) = speed
}

Another suggestion for you to try like this:
if ((keyboard_check(vk_down)) AND
     NOT place_meeting (x,y+4(choose a good distance compared to the sprite), obj_wall))
{
   y +=4
}

The meaning: if you press the key and you are not close to the object it will move. It works in all directions.

I tried this but I found once they reached the wall, they could not move away from the wall.


text:
Are minecraft LANS and servers Filtering Enabled?
Non-filtering enabled means any given client can make changes and the server will replicate them. This is faster but opens doors for hackers and exploiters. Filtering enabled means the client provides user input, and the server decided what to do accordingly. This idea came from Roblox, but I wonder if Minecraft servers are filtering enabled?
In other words: Is Minecraft Filtering Enabled?

I'm voting to close this question as off-topic because it is not about developing a video game.

Yes
This isn't even a thing Roblox came up with. It's a thing known in the industry as "the client is a lying, cheating, bastard" (or its technical name, "authoratative server").
Minecraft utilizes it, even in single player (using an integrated server, which runs on a separate thread, see: sides). LAN is just the single player integrated server opened up to additional connections.
It should also be noted that in creative mode the client becomes authoratative over several aspects normally controlled by the server, eg. inventory contents, but this is usually regarded as fine because it's creative mode.


text:
Parts of 3D model disappear during animation
I'm trying to properly play an animation done in Blender 2.8 inside my OpenGL application. When the animation is running, it happens that at some particular frames, some parts of the 3D model "disappear", by "disappear" I mean that they obviously get relocated at some incorrect position and rotation in the 3D scene.
The model is an FBX file.
Has anyone got an idea about what could be the possible reasons for that?
Maybe some wrong settings in Blender?
Thanks in advance!

You might want to add a link to a youtube video or an animated gif showing the issue.

Do the errors always happen on the same frames & are things that go wrong the same across more than one test (i.e. does part X always get relocated to position Y)?

I think I've found something, the idle animation got some really really slight offsets of movements, I've printed the matrices being used on frame 1 and for all the parts not appearing on screen the matrices got the following pattern:
(0 0 0 a)
(0 0 0 b)
(0 0 0 c)
(0 0 0 1)
Those are glm matrices (column major).
Maybe due to the really slight difference of movement between two consecutive frames, the float precision isn't enough and the value is set to zero ?
Thus, all I got to do is doing some larger movements for the corresponding keyframes ?
I'll try that if that works, but I'm still open to some suggestions !

sorry I'm a bit late !
Yes the errors did always happened on the same frames for the exact same model parts across each test iterations, but I've managed to solve the issue.
So basically, I took a glance at the number of position, rotation and scaling keys, and I had noticed that some keys were missing.
For instance, the idle animation must have 48 keys, and for the parts that caused troubles, some animation keyframes were missing.
In my code I did a trick for that case, to just take the last known computed keyframe as the current keyframe and chain multiply it with all its parent joints matrices, but it didn't worked great.
So I eventually found on the web a nice addon for Blender which properly export 3D Blender files to the collada file format, and then all the keyframes were set the right way and all the weird things were gone.

In case someone would need that addon, here is the link => https://github.com/godotengine/collada-exporter


text:
Fill with Transparency in Built-In Sprite Editor
When I imported an image for a sprite, I realized it had a white background. I went into the built-in sprite editor to remove it. I tried using fill as there was a transparent color in the color selector. It did not work. Is there a way to do this, or an easier way than erasing it all by hand?

You can use the color remover tool. It works just like the fill tool, but it removes the color and replaces it with transparency. It does not work perfectly, but it should do the job. Keep in mind when using it, it removes all of that color in the sprite.


text:
How to use open dota api?
OpenDota, A community driven platform for DotA 2 matches and players data is the best open-access API in gaming scene. I found no casual tutorial for using its API, So, I decided to make a one. Your feedback is welcome for inquiries or further improvements
Sincerely,

Probably, You came along OpenDota's documention but did not know where to go from there.
As python is popular among data scientists, We shall use it in our tutorial. Python's standard library comes with URL handling module but for convenience I am going to use requests. If requests module is not already installed, obtain it via pip install requests. See the official installation guide for more details.
start by importing requests module by import requests
get a webpage from OpenDota's API. Its form is https://api.opendota.com/api/{entry1}/../{entry n}. For example, GET /players/{account_id}/matches is implemented as r = requests.get("https://api.opendota.com/api/players/107828036/matches")
Then, you could access the desired content by r.text. print(t.text) returns raw string. However, processing raw text is tedious and it would be more accessible if data where formed as dictionary. requests module comes with JSON parser out of the box by r.json(). Usually, r.json() is list, and r.json()[0] is the first element of the list which is a dictionary. You could print(r.json()) for manual check.
Finally, you might wish the write the modified data. Python's standard library comes with JSON writer out of the box. By the way, We could have parsed r.text to a dictionary using it instead of requests r.json(). Anyway, import json. Then
with open('<file-name>', 'w') as out:
                json.dump(<dictionary-object>, out, sort_keys=True, indent='\t')

where <dictionary-object> is r.json() in our case. both of sort_keys=True and indent='\t' beautify the writing by introducing tabs and newlines
Here is a sample code:
import requests
import json

r = requests.get("https://api.opendota.com/api/players/107828036/matches")

with open('output.json', 'w') as out:
                json.dump(r.json(), out, sort_keys=True, indent='\t')


text:
Node representations in a navigation mesh
There are different ways to represent nodes in a navigation mesh. It's either along triangle centroid, along triangle vertices or along edge midpoints.
As I understand if you choose triangle centroid or edge midpoints as nodes, the path isn't going to be optimal, but you can use a funnel algorithm to optimize it.
If you choose triangle vertices as nodes however, I understand you can find the more optimal path from get-go. But you will get a "wall hugging" issue. Which you can solve by using some algorithm I unfortunately forgot the name of.
What is the preferred or most optimal option?

I don't think there is any Generic "Optimal" way to do this. It mostly depends on your type of game.
For instance, in a RTS, you probably want to go with the center of a triangle rather than edges so that you can have lots of units walking over the Map.
In a FPS you might want to use edges to get a better and more complex node mesh. So that they AI might be able to flank you etc.
Could you tell us more about the type of project you are making? This way i guess it would be easier to help you find the more optimal solution for your needs.
Good luck!

It's an FPS game. When using edges do you only use the edges that are shared between triangles as nodes? And then I guess you use the same edges for path straightening with funnel algorithm? Also why not use triangle vertices as nodes, this way you can skip running funnel algorithm. Is it because more nodes are required?


text:
Way to Round Numbers
I have it when the player clicks the mouse they can move the peice aoround the board. I am trying to have the chess pieces snap to a grid after the mouse has been released. Is there any way to round numbers so that I can round the X and Y coordinates so that it will snap to the grid?

Use multiples of a number. If you want the pieces to be 100 by 100 pixels, position the declaration as x = 100 * (house number from 1 to 8). Now I do not understand if you want to position the pieces with the mouse, before or after the game starts..

@bon Is it more clear now?

The terms you were looking for were "integer division".

You will basically turn the position of your mouse click into an integer. To do this simply divide the coordinates obtained by the size of the grid you want to create (32 in my case).
Then just multiply by the same amount you divided (32 in my case).
Splitting has to be done using div, no /.
Create Event:
gridx=0;
gridy=0;

Global Left Pressed Event:
gridx=mouse_x div 32;
gridy=mouse_y div 32;

x=gridx*32;
y=gridy*32;

The way I suggested above is more didactic and simpler to change, but if you want it can be simply...
Global Left Pressed Event:
x=(mouse_x div 32)*32;
y=(mouse_y div 32)*32;


text:
Way to Prevent Stacking Pieces
I have a chessboard with all the black pieces that move with this code:

I found that when I move the pieces, they will stack on top of each other. How can I prevent this?
I have since changed the code to this:

When I move a piece over another it still picks that piece up, but now it will occasionally completely prevent any stacked pieces from moving. What can I do, and is there a way to do this while still being able to move one piece over top of another?
Also, the pieces origin and collision box ( all similar to the king) look like this:

Just use the function place_empty:
if(place_empty((mouse_x div 32)*32,(mouse_y div 32)*32)){
    x=(mouse_x div 32)*32;
    y=(mouse_y div 32)*32;
}

In my case, my piece has dimensions 32x32 and its origin is at the top left.
To understand this calculation, I recommend looking at your own question (Way to Round Numbers), the answer of which helps to understand.
If you have difficulties in this, or in converting the code to DnD, just comment.

I have tried this and updated my question with the results. Can you take another look at it?

@K00lman How size is your piece? What is the origin of your piece?

The pieces are 64 by 64 and have the center at the corner, outside the collision box if that matters.

@K00lman What size grid have you chosen? (https://gamedev.stackexchange.com/questions/177566/way-to-round-numbers)

@K00lman If all pieces have their origin in the same location, I ask you to add an image to the question showing the origin location.

Added the image of the King piece with the origin and colliosion mask visible.

@K00lman Place the collision mask on the entire image (64x64). I suppose the size of each square is 64x64 correct? So use this: Expression - place_empty((mouse_x div 64)*64,(mouse_y div 64)*64)

How would I put that in DnD?

Let us continue this discussion in chat.


text:
Multiple If Operations at Once
In my game, I want to have it so that if a chess piece tries to move farther away than a certain distance it won't work. To do this, I need it to have an if statement that works between two numbers, but I can only seem to do above or below a number, not between. Is there a way to do this, or am I going to have to use to if statements?

Have you tried using expressions? Something like: distance> = 50 && distance <= 100

@bon No, I did not even think of that. I will try that now

@bon That works. Could you put that as an answer?

What is the purpose of the DnD in the title?

@vaill Because of I though that I would have to use a special DnD block, and this is not really a problem in GML.

Ok, thanks I wasn't aware of that feature!

You can do it direct using the function point_distance() or create a variable and give it the value of that distance.
Code:


text:
Why is the pawn not moving?
I have a set of moving chess pieces and am now trying to implement the rules to prevent them from going anywhere. The pawns use this code to move: (Sorry for the blurriness, the IDE did it automatically when I zoomed out so I could get it all.)
When I go to move the Pawn, it won't move at all. Weirdly, when I had the if statement at the top set to true, it would work just fine, just excluding the moving double on the first move.
What is causing this problem, and how can I fix it?

The reason the pieces are not moving is that it never does the first section of code, and when it runs the second section, the only place it lets it move is the spot it is already in.
It never runs the first section because when you click on the pawn the first time it changes the value of the variable before it even moves. In the second section, the mouse_y >= y && mouse_y <= (y + 64) is the 64 by 64 grid the pawn is in as its location is determined by the top left corner.
To fix this, you would make it so that it does not change until after it has moved instead of when the player clicks on it, and change the y + 64 to y + 128.


text:
How to model chess knight movement in GameMaker?
I am making a chess game in GameMaker, and I have the basic movement down for all of the other pieces except for the knight. I am using a system where I have an if statement that checks if the mouse is in a location that it can move too, then if it moves the piece there. For example, the rook code is (mouse_y div 64) *64 == y || (mouse_x div 64) * 64 == x. What would be an expression that would work for knights? Would this strategy even work for knights?

I imagine you have to do 8 expressions. All expressions using the x and y axes:
if (mouse_x div 64) * 64 == x+64 && (mouse_y div 64) * 64 == y-128 ||
(mouse_x div 64) * 64 == x+128 && (mouse_y div 64) * 64 == y-64 ||
(mouse_x div 64) * 64 == x+128 && (mouse_y div 64) * 64 == y+64 ||
(mouse_x div 64) * 64 == x+64 && (mouse_y div 64) * 64 == y+128 ||

(mouse_x div 64) * 64 == x-64 && (mouse_y div 64) * 64 == y+128 ||
(mouse_x div 64) * 64 == x-128 && (mouse_y div 64) * 64 == y+64 ||
(mouse_x div 64) * 64 == x-128 && (mouse_y div 64) * 64 == y-64 ||
(mouse_x div 64) * 64 == x-64 && (mouse_y div 64) * 64 == y-128 {

This way you check every possible point.

Borrowing the diagram from disc_code22's answer, let's overlay it with some numbers. For each square, we're going to count how many squares it is left or right from the knight, and square it; then do the same for up/down; then add the two numbers together:

You might recognize this as Pythagorean theorem, just without the square root (we don't need it if we just want to tell the squares apart).
Knight moves that travel 2 out and 1 over are the only moves on the chess board with squared length exactly 5.
So, we can do something like this:
travelX = (mouse_x div 64) - (x div 64)

travelY = (mouse_y div 64) - (y div 64)

With these variables in hand, now we can write a variety of piece moves as one-liners:

Knight: travelX * travelX + travelY * travelY == 5
Rook: travelX == 0 || travelY == 0
Bishop: travelX == travelY || travelX == -travelY
King: travelX * travelX + travelY * travelY < 3

There are quite a few approaches you could take to validating this kind of movement, so you should choose whatever is cohesive with the style of your movement validation so far, but I'll suggest a simple approach and perhaps you and other answerers can build on it.
If your knight is at a position, lets say (x,y) on the chess board/grid, lets also imagine a second version of this grid that is relative to the knights position. To tie this in with the example image, if we drew these relative grid labels on the example image, the knight's position would be labeled (0,0), and the grid would range through (+/-2, +/-2).
Using these relative positions can make it a lot simpler to determine which knight moves are valid. Lets consider the movement where the knight heads north and then east. In the example image's grid this is the move that ends up on (3,0), but in our imaginary relative grid this would end up at (1, 2).
Since there are only 8 valid moves maximum for a knight, the simplest approach is likely to hard code these valid relative moves, then check the players attempted move against the list of valid relative positions representing knight's possible moves. The valid positions could most concisely be stated as (+/-1, +/-2) and (+/-2, +/-1)
So in conclusion, this approach simplifies stating which moves are valid for the knight, but adds in some trickiness about transforming between the absolute and relative grid so you can compare the players absolute grid mouse clicks with the relative grid moveset of the knight.
There are certainly other approaches to this problem but I hope this one is enough to get you started on tackling the issue.
If you are looking for more reading including some different approaches to this issue as well as some code samples, check out this Geeks4Geeks article on coding chess knight movement


text:
How to create a new civilization mod for Age of Empires 1 Definitive Edition?
I want to make a mod for Age of Empires 1 Definitive Edition, in which I split an existing civilization (Phoenicians) into two civilizations:

Eastern Phoenicians: Primarily representing Canaanites
Western Phoenicians: Primarily representing Carthaginians

I want to do so to fix an historical mistake in the development of AOE1 in which the Phoenician tech tree includes war elephants:
As far as I know --- none of the Eastern Phoenicians regularly used war Elephants in their armies:
Eastern Phoenicians from north to south and west to east:
Kingdom of Ugarit | Mittani polities
Kingdom of Tyre   | Kingdom of Aram-Damascus
Kingdom of Israel | Kingdom of Ammon
Kingdom of Judah  | Kingdom of Moab
Kingdom of Edom   | Nabataean polities

My problem
As a webmaster coding primarily in Bash-HTML-CSS-JavaScript-Wiki-Markdown stack who never wrote a GUI program with languages common for the task (such as XML, C++, C# and others) I have no idea where to start.
My question
How to create a new civilization mod for Age of Empires 1 Definitive Edition?

I do not have this game, cannot test if it works correctly.
I suggest the open source tool Advanced Genie Editor 2019. (github repository).
On the linked website it says:

Advanced Genie Editor
for Age of Empires, Rise of Rome, Age of Kings, The Conquerors (including HD), Star Wars Galactic Battlegrounds and Clone Campaigns.
This is a program for editing data of genie (DAT and DLL) files. It can edit properties of units, civilizations, technologies, graphics, terrains, sounds, player colors and some other things.

Definitive Edition
It should work with the 2018 Definitive Edition if you select this version on the Genie version drop down list when opening files, as pictured below:

Advanced Genie Editor "Open files..." dialog
The application has support for editing tech trees among other things:

Advanced Genie Editor main window, Tech Trees tab, no file open.
That should allow you to remove access to particular units for given civilizations. Remember to backup your dat files.
I found this tool linked from aoe.heavengames.com. I did not see any real alternatives while searching.

Update
I tried the tool on a friend's copy of the game. I had to put the path to the dat file manually. There is no language.dll file, so untick that when opening. There is an option to copy a civilization (on the "Civilizations" tab), and to disable units to particular civilizations (on the "Units" tab). However, editing the tech tree for a particular civilization was not available (there was no "Tech trees" tab).

Hello ; I thank you dearly for noting this --- just one point for future readers ; I am not sure it deals with Definitive Edition release from 2018 as well or only with the originals --- I have yet to buy the Definitive edition, I asked the question here on principal, for possible future times. Sadly I don't have enough reputation points to up vote your answer, at this point.

Dear Theraot - I was glad to read your answer, to upvote it a few days ago already and to you the bounty --- I waited a few days just a principle (and could wait about 4 more days + bounty grace period) but your work on this is in my opinion graceful and I also find it inspiring and of course I appreciate it much. I was glad to accept the answer and recommend users to upvote your answer.


text:
How to set root signatures specified in HLSL in my command list?
From Microsoft Docs, I can specify the root signature of my shader in HLSL. How do I use it though?
Since at the beginning of the command list, root signature is undefined. I need to use ID3D12GraphicsCommandList::SetComputeRootSignature(ID3D12RootSignature*) or ID3D12GraphicsCommandList::SetGraphicsRootSignature(ID3D12RootSignature*) set root signature, but having specified in HLSL instead of C++ code, I do not have a pointer to my root signature objects, how should it be done then?

You can provide any compiled shader blob that contains the desired root signature defined in HLSL when creating the root signature object:
Microsoft::WRL::ComPtr<ID3D12RootSignature> m_rootSignature

// Create root signature.
auto vertexShaderBlob = DX::ReadData(L"VertexShader.cso");

DX::ThrowIfFailed(
    device->CreateRootSignature(0, vertexShaderBlob.data(), vertexShaderBlob.size(),
        IID_PPV_ARGS(m_rootSignature.ReleaseAndGetAddressOf())));

…

// Use root signature
commandList->SetGraphicsRootSignature(m_rootSignature.Get());

The DX::ReadData function just loads the binary blob from disk (source here). The DX::ThrowIfFailed helper is explained here.

If you are using FXC.EXE you can also build a shader with the HLSL defined root signature using the rootsig_1_0 or rootsig_1_1 profile and the resulting compiled binary object will just have the root signature in it.

That worked! I was used to using D3D12SerializeVersionedRootSignature to produce the blob and didn't know the blob from compiling the shader can be used for it as well. Thank you.


text:
How do i writing timing function for lightning flash in C++?
I need to write a horror scene with lightning flash. Unfortunately I am new to both C++ and OpenGL and I am looking for efficient way to mimic lightning timing in C++/OpenGL?
I don't need graphical implementation, just algorithmic implementation.
as such, the function should return a float representing lighting intensity and the delay of lightning flash should be random (5 seconds followed by 10 seconds then 3 seconds.. etc)
I hope I made everything clear!

Presumably you tried using a random number generator? What does your code look like so far, and where are you stuck, or how does the output of your current code differ from what you want?

I am not there yet, I will be working on this in couple of days.  I asked this question to gain information about common practices.

You'll need some persistent state and a frame counter passed in:
float lightning(lightningState* state, uint64 frame){
    if(!state->enabled) return 0.0f;
    if(frame - state->lastStart < state->flashDuration)
         // during flash
         return 1.0f; //can also have a decreasing function here based on the difference
    if(frame - state->lastStart >= state->nextFlashDelay){
        //start of next flash
        state->lastStart = frame;
        state->nextFlashDelay = rollTimeOut(5, 20, *state->rngSeed);
        return 1.0f;
    }
    //no flash
    return 0.0f;
}

Frame you say? That is logical.

Thanks mate, I officially accept your post as an answer :))))


text:
How to draw lines round selected objects and lights?
I need two things to draw in Modern OpenGL.
Please see the image:

Draw lines to represent light's position and direction
Draw xyz axises at the origin of a selected objects

How do I draw these? should I use fragment shader or what?

It looks like you're trying to implement selection and transformation gizmos — does previous Q&A on that topic give you some leads you can build on?

@DMGregory yes, that answers my second question, thank you!


text:
How to create GUI or Menu for games?
I've advanced quite well in OpenGL and in graphics. However I lack a lot of experiences.
I have had this question in my mind since the beginning of my venture,
how do I create UI or Menu for my game?
I imagine I will create a menu just like creating a 2D game in OpenGL.

What have you tried so far, based on OpenGL game development tutorials you've researched?

@DMGregory  Since I don't want to waste time on working wrong methods, I always ask my questions before I try something.

I've tried nothing related to ui or menu rendering

I am not really sure what would be a wrong method in this case (as long as we rule out the obvious things that are wrong because they don't accomplish the goal of creating a GUI or a menu for games)

So the first place you asked was Google, right? And you worked through several tutorials to gain the benefits of the wealth of documented knowledge already out there? What's the next gap we can help you fill, what one question have you not yet found an answer to in your research?

@DMGregory, Yes I did make research on google and there are tons of suggestions, some suggests to write your own some suggests use 3th party libraries.  and All were relative.. some developers wanted to bring up a game at all cost, some developers enjoy their own creations at a reasonable time cost.

@htmlcoderexe your answer is based on experience and found it helpful, thank you!

Option 1: turn back now and find and tweak a ready made solution, there are tons of GUI libraries for every language and framework.
Option 2: roll your own for the sake of rolling your own. Continue reading!
If you intend to have anything more complex than a health/score display, you will want to do it in multiple "layers".
Start with the bottom layer - the lowest level. Create some classes and routines that draw the various graphic elements (drawButton(X, Y, text, state)). Create the next layer - GUI elements themselves, which then use your drawing functions to draw themselves appropriately. Let these both have a common ancestor - a Control class which then handles things like passing mouse clicks through to its child Controls or firing actions when clicked. Create your Window class that also derives from Control, but has its own extra functionality like dragging and closing, if you need windows in your GUI.
Finally create the top layer, the Window/GUI manager. This will then take mouse and key input, keep track of what's in focus and what's where, draw windows in the right order, all the things, so that in the end you will perhaps end up with 2-3 methods that are actively used on game runtime, not counting initialisation and death.
By layering your abstraction like this you can make changes easily exactly where you need them - I made the mistake of having it all flat before and gave up after realising that now that I want buttons to highlight when mouse over I had to change like 30 places which each defined its own button.
As usual I will drop the most recent version of what I have, most of it is readily reusable but it is not really finished and probably MonoGame specific. The higher leve stuff, however, gives you a good idea of the layered principles:
https://github.com/htmlcoderexe/3DGame/tree/master/GUI
Here, I have two lower levels, one that deals with creating all the appropriate geometry that's later handed to the graphics card, and one that requests the creation of said geometry to actually render graphical elements.