Community functions

You must understand the Game Editor concepts, before post here.

Re: Community functions

Postby bat78 » Wed Aug 12, 2015 12:05 am

Oh look. I accidentally found this topic.
Hblade must see this and since he could not listen to me about that idea.. maybe he will listen from friendlier users.

To elaborate what I am on about..
Hblade released a function a day after I released the same function, coded better (concerning readability and performance).
I professionally (without being influenced by personal feelings) tried to explain that he is basically discrediting me, showing no research efforts and this is especially dangerous as if someone uses his approach w/o looking for mine. Sor all I wanted is at least something like a link in his post, leading to my version.
We ended up arguing, I was called "mean" and godmother words, because of that I called his code bad AND explained why.. For good. If there was vote system I would just down vote, skip saying it is bad, and explain why is it bad (it cannot be bad - worse though)
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Community functions

Postby bat78 » Wed Aug 12, 2015 1:49 am

lcl wrote:Here's a very simple and basic function that I made because I needed it in my game. This is a very global level function, and I think this should even be included in the built-in Game Editor functions, since it is really useful.

The function syntax is:

void screen_to_real(int * x, int * y)

What this function does is really similar to what functions screen_to_actor() and actor_to_screen() do.
You can give screen_to_real any screen coordinates, xmouse and ymouse for example, and it will convert them to "real" coordinates, e.g. coordinates relative to the Game Center (0, 0). After calling screen_to_real the coordinates you gave to the function will return the modified values, but only in that certain event, just like screen_to_actor and actor_to_screen.

Here is the function code:
Code: Select all
void screen_to_real(int * x, int * y)
{
    *x = view.x + *x;
    *y = view.y + *y;
}

And here's an example of how to call it:
Code: Select all
screen_to_real(&xmouse, &ymouse);

The reason why you have to add the ampersand (&) before the variables is that the function needs the pointer to the variable data in memory so that it can edit that data. Without the ampersand you'd just pass the value of the variable to the function, and Game Editor would give you an error message because the function requires the values to be pointers to integers variables, not the values of the variables.

Here is also a small demonstration of the function in use:
screenToRealExample.zip


Very well explained. If you explain SABRE on the same basis I see no future complications.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Previous

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest