Jump to content


Photo

Game Maker Suggestions


  • This topic is locked This topic is locked
1165 replies to this topic

#1141 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 16302 posts
  • Version:GM:Studio

Posted 23 April 2012 - 08:35 PM

...


Good but stop thinking of local and temp that way... The new help, as stated, reinforces proper terminology
_variableName = 0; // instance scope
var variableName = 0; // local scope
global.variableName = 0; // global scope
globalvar variable_name = 0; // global variables that are recognized as resources, like sounds or sprites
VARIABLE_NAME = 0; // constants

I may add, but it's up to you, in the industry, variables with a leading _ and __ tend to mean temp variables. temp variables are usually global variables (or in GM, instance variables) used to hold data that will be fetched readily... You can see where the use of the term temp variables on the GMC to mean var brings a whole lot of confusion for people coming in with prior experience there.

example c++

float __nz,__ny,__nz;

float normalize(float vx, float vy, float vz)
float d; d= sqrt(vx*vx + vy*vy + vz * vz);
__nx = vx/d;
__ny = vy/d;
__nz = vz/d;
return d;


normalize(100,200,300);
float nx = __nx;
float ny = __ny;
float nz = __nz;

It's a bad example, but it has a more pertinent use in GM and in languages that do not allow retuning multiple values via the arguments.
  • 0

#1142 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1944 posts
  • Version:GM:Studio

Posted 23 April 2012 - 08:45 PM

Well, I'm using the leading underscore as a by-product of prefixing member variables with 'm_' or just '_', and then using no leading underscore for variables used inside functions. I realize that, for example in C#, a lot of people are sticking to the standard and using the this. prefix but the only thing resembling it in GM is self. which I've never really seen anyone use to serve this purpose.
  • 0

#1143 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 16302 posts
  • Version:GM:Studio

Posted 23 April 2012 - 08:47 PM

Well, I'm using the leading underscore as a by-product of prefixing member variables with 'm_' or just '_', and then using no leading underscore for variables used inside functions. I realize that, for example in C#, a lot of people are sticking to the standard and using the this. prefix but the only thing resembling it in GM is self. which I've never really seen anyone use to serve this purpose.



It's alright, pretty sure the _ thing is not universal though common in my region.
  • 0

#1144 Big J

Big J

    GMC Member

  • GMC Member
  • 2852 posts
  • Version:GM8.1

Posted 23 April 2012 - 10:15 PM

The smallest scope is always used. Scope, from smallest to largest, is script-local -> instance-local -> global.

The potential problem is that variables declared with globalvar override instance variables.

For example, objectA has this Create event:
value = 0;
This Step event:
value += 1;

Suddenly, objectB does this:
globalvar value;
value = 0;
Oops, now the Step event of objectA will forever increment the global value. I think self.value could solve that, but that's messy. :yucky:

Of course, the ideal solution is to avoid using the same names for globalvar and instance variables in the first place.

Edited by Big J, 23 April 2012 - 10:17 PM.

  • 0

#1145 Desert Dog

Desert Dog

    GMC Member

  • GMC Elder
  • 6409 posts
  • Version:Unknown

Posted 23 April 2012 - 10:39 PM

Of course, the ideal solution is to avoid using the same names for globalvar and instance variables in the first place.


I don't really understand why one needs to use globalvar, anyway. Although typing out global.everytime might be a little annoying, readability wise, it's worth it, surely.
  • 0

#1146 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9515 posts
  • Version:GM:Studio

Posted 23 April 2012 - 11:24 PM

The smallest scope is always used. Scope, from smallest to largest, is script-local -> instance-local -> global.

The potential problem is that variables declared with globalvar override instance variables.

For example, objectA has this Create event:
value = 0;
This Step event:
value += 1;

Suddenly, objectB does this:
globalvar value;
value = 0;
Oops, now the Step event of objectA will forever increment the global value. I think self.value could solve that, but that's messy. :yucky:

Of course, the ideal solution is to avoid using the same names for globalvar and instance variables in the first place.

Oh. Then the correct scope hierarchy is globalvar->var->instance-local->global. You can tell I don't ever use globalvar at all. Like Desert Dog, I prefer the global.variable syntax because it keeps global variables clearly in the global scope.

-IMP
  • 0

#1147 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • GMC Elder
  • 16302 posts
  • Version:GM:Studio

Posted 23 April 2012 - 11:31 PM

Of course, the ideal solution is to avoid using the same names for globalvar and instance variables in the first place.


I don't really understand why one needs to use globalvar, anyway. Although typing out global.everytime might be a little annoying, readability wise, it's worth it, surely.


It's helpful in the case where you originally had an instance variable that now needs to be global. adding globalvar variable; allows the variable to be accessed remotely without the need to go though all the existing code that referenced the variable.

For example, I had a zoom variable in a particular instance with a lot of code associated with it. Then I started to need to use it everywhere external to the instance that created it and I did not want to switch context because from now on, that variable would be used intensively.
  • 0

#1148 Samuel Venable

Samuel Venable

    GMC Member

  • Banned Users
  • 632 posts
  • Version:GM:Studio

Posted 23 April 2012 - 11:41 PM

-import multiple include files at once.
-select and delete multiple include files.
-select and delete multiple resources in the resource tree even if they aren't in a resource group.

#1149 Magicnanners

Magicnanners

    GMC Member

  • New Member
  • 11 posts
  • Version:GM8

Posted 28 April 2012 - 12:14 AM

Please for the love of god move the drag and drop tabs from the side of the object creator to the top. It is so hard to read them without physically rotating my head.
  • 4

#1150 GStick

GStick

    All Secrets Exposed

  • GMC Member
  • 1944 posts
  • Version:GM:Studio

Posted 29 April 2012 - 09:55 PM

I was reading Coding Horror the other day, and this seemed like something fit for GM to me:
http://www.codinghor...ail-faster.html
  • 2

#1151 Erik Leppen

Erik Leppen

    GMC Member

  • GMC Member
  • 2616 posts
  • Version:GM:Studio

Posted 30 April 2012 - 04:20 PM

I was reading Coding Horror the other day, and this seemed like something fit for GM to me:
http://www.codinghor...ail-faster.html

Thanks. Now I spent the whole afternoon reading through that website :lol:
  • 1

#1152 Tsn

Tsn

    GMC Member

  • GMC Member
  • 282 posts
  • Version:Unknown

Posted 30 April 2012 - 05:18 PM

Some of the things i've found missing from Game Maker for a long time.
1 if variable = 1 else variable = 0
{
variable = 2
}
This allows avoiding typing extra lines and what happens after else would be more easily seeable. Sometimes i type lots of code and then add a one line code after else.
2 instance_has_variable(variable,instance,set)
Checks if any of the instances has a variable set to something and returns how many of those instances there are.
This would allow me to see how many enemies there are with health set to higher then 10 for example.
3 Possibility to hide code.
4 Automatic execute code instead of select drag and drop icon menu.
5 Possibility to put an if statement inside a script, so i can do.
scriptname()
{
variable = 1
}
I use similar if statements in many places.
6 Possibility to combine numbers into text.
sprite_index = "sprite"+string(variable)
7 Possibility to create variables like this.
"variable"+string(variable) = something
8. Add x1,y1,z,z1 constants. It would be easier to seperate them from other code.
9. Add event functions. So i can do create event in step event or outside room event in step event for example. This can save time moving between events.
10. Add mouse_collision_check_button(). This also checks if the mouse collides with an object.

Edited by Tsn, 30 April 2012 - 11:53 PM.

  • 0

#1153 IceMetalPunk

IceMetalPunk

    InfiniteIMPerfection

  • GMC Elder
  • 9515 posts
  • Version:GM:Studio

Posted 01 May 2012 - 12:46 AM

Some of the things i've found missing from Game Maker for a long time.
1 if variable = 1 else variable = 0
{
variable = 2
}
This allows avoiding typing extra lines and what happens after else would be more easily seeable. Sometimes i type lots of code and then add a one line code after else.

I don't understand this. What does that mean? If the variable equals 1, then set it to 2, otherwise set it to 0? What's the benefit of that over:

if (variable==1) { variable=2; }
else { variable=0; }

? Or is it supposed to mean "if the variable is 1 or 0, then set it to 2"? In that case:

if (variable==1 || variable==0) { variable=2; }

What are you trying to accomplish with that strange syntax?

2 instance_has_variable(variable,instance,set)
Checks if any of the instances has a variable set to something and returns how many of those instances there are.
This would allow me to see how many enemies there are with health set to higher then 10 for example.

You can do that in GM already:

with (instances) {
  if (variable==set) {
    //whatever code here
  }
}

It's kind of a fringe case to replace a 4-line syntax with a 1-line syntax which would require the extra parsing for it.

5 Possibility to put an if statement inside a script, so i can do.
scriptname()
{
variable = 1
}
I use similar if statements in many places.

I don't think you understand what scripts actually do. The normal way to do something like that is simply to have the script return true or false, then do this:

if (scriptname()) {
  variable=1;
}

Again, what are you trying to accomplish?

6 Possibility to combine numbers into text.
sprite_index = "sprite"+string(variable)

You can already. "sprite"+string(variable) does, in fact, combine the number into the string. In that case, though, you're trying to reference a sprite_index, which is actually a number to begin with. It's not text, it's not a string--it's a number.

Something like *_get_index("string_name") has been requested many times before, but until it's added, there are always these workarounds: map_* scripts.

7 Possibility to create variables like this.
"variable"+string(variable) = something

That makes no sense, since variable names are not strings...but if you need to do that, you can already use execute_string() for it:

execute_string("variable" + string(variable) + " = something");

8. Add x1,y1,z,z1 constants. It would be easier to seperate them from other code.

What? What are x1, y1, and z1? I understand a z constant for D3D, but what the heck are the other 3?

9. Add event functions. So i can do create event in step event or outside room event in step event for example. This can save time moving between events.

Check the help file--these already exist. There are two main functions for that: event_perform() and event_perform_object(). Look them up.

10. Add mouse_collision_check_button(). This also checks if the mouse collides with an object.

There are events for this. If you really need to code it, it's simple to do yourself:

if (collision_point(X, Y, obj, prec, notme) != noone && mouse_check_button(mb_left|mb_right)) {
  /* Here */
}

Considering the events for this already exist, what's the point?

-IMP
  • 0

#1154 Big J

Big J

    GMC Member

  • GMC Member
  • 2852 posts
  • Version:GM8.1

Posted 01 May 2012 - 01:13 AM

Some of the things i've found missing from Game Maker for a long time.
1 if variable = 1 else variable = 0
{
variable = 2
}

Did you mean:
if (variable == 1)
{
    variable = 2;
}
else
{
    variable = 0;
}

2 instance_has_variable(variable,instance,set)
Checks if any of the instances has a variable set to something and returns how many of those instances there are.
This would allow me to see how many enemies there are with health set to higher then 10 for example.

I think this is a silly suggestion.

It is already possible to count how many enemies satisfy a certain condition:
/*
    This code will count how many enemies have hp > 10
    and store them in an array.
*/
var count, array;
count = 0;
with (objEnemy)
{
    if (hp > 10)
    {
        array[count] = id; //store the ID
        count += 1; //increase count
    }
}

5 Possibility to put an if statement inside a script, so i can do.
scriptname()
{
variable = 1
}
I use similar if statements in many places.

Scripts can return values.

//Script: scriptname()
return choose(true, false); //this is just an example
if (scriptname())
{
    //do something
    variable = 1;
}

6 Possibility to combine numbers into text.
sprite_index = "sprite"+string(variable)

This is already possible with variable_*_get/set() or even the dreaded execute_string(), but if you find yourself needing to do this, you're probably designing your game incorrectly. Regardless, the best solution would be to use an array, or make scripts to retrieve the ID of the resources, such as sprite_get_index():
var i, name;
name = argument0;
for (i = 0; i < 1000; i += 1)
{
    if (sprite_get_name(i) == name)
    {
        return i;
    }
}
return -1;
Or perhaps take it a step further and map all the resources at the beginning of the game for faster retrieval.

7 Possibility to create variables like this.
"variable"+string(variable) = something

This is what arrays are for. variable[0], variable[1], variable[2], etc.

8. Add x1,y1,z,z1 constants. It would be easier to seperate them from other code.

These would be completely useless as constants. I think a built-in instance "z" variable would be nice, but how hard is that to create yourself? In a way, "depth" is similar to z, but it determines drawing order. x1, y1, and z1 would be variables I create myself if I need them, and sometimes they are script-local with "var" declaration, so they should NOT be built-in.

9. Add event functions. So i can do create event in step event or outside room event in step event for example. This can save time moving between events.

I'm not sure what you mean. If you mean to perform other events from the current event, this is already possible with event_perform() and event_perform_object(). If you want to merge all the code from all events into the Step Event, that implementation might be slower than using separate events.

10. Add mouse_collision_check_button(). This also checks if the mouse collides with an object.

This is easy to check yourself:
return (instance_position(mouse_x, mouse_y, all)) != noone);

The built-in events for the mouse buttons that are not global mouse already have a similar check.

EDIT: I never got an email notification of IMP's reply. :P

Edited by Big J, 01 May 2012 - 01:14 AM.

  • 0

#1155 TeamSteeve

TeamSteeve

    GMC Member

  • GMC Member
  • 1311 posts
  • Version:GM:Studio

Posted 04 May 2012 - 06:37 AM

A lot of posts in this topic so I hope I'm not posting aything that has already been talked about.

I would really like it if you could put names for the arguments in the name of the script.
So say I had a script named "scr_change_position" and it had two arguments which I used to determine the x and y coordinates of whatever instance was calling the script, I want to actually name the script "scr_change_position(x,y)".

Also, when the auto-complete box pops up when typing in code it could show "scr_change_position(x,y)" instead of just "scr_change_position(...)".
I'm very forgetful and have to keep re-opening my scripts to make sure I'm using them right and haven't put the arguments around the wrong way.
This would be very helpful to me.

Thoughts?
  • 3

#1156 Dark Matter

Dark Matter

    RPG Expert

  • GMC Member
  • 3196 posts
  • Version:GM:Studio

Posted 07 May 2012 - 07:24 AM

A lot of posts in this topic so I hope I'm not posting aything that has already been talked about.

Unfortunately, as you say, so many topics have been covered it's nearly impossible to come up with something useful and yet unmentioned. This has already been discussed. It's a good idea though :P
  • 0

#1157 Jobo

Jobo

    Freelancer

  • Local Moderators
  • 2796 posts
  • Version:GM:Studio

Posted 09 May 2012 - 09:03 PM

I'm still waiting for them to add the simple approach of variable increase/decrease, as such;
variable++;
variable--;

It's astonishing they've never added this.
  • 1

#1158 Desert Dog

Desert Dog

    GMC Member

  • GMC Elder
  • 6409 posts
  • Version:Unknown

Posted 09 May 2012 - 09:27 PM

I'm still waiting for them to add the simple approach of variable increase/decrease, as such;

variable++;
variable--;

It's astonishing they've never added this.


It isn't the simple approach at all, it's the complex way of adding 1 to a variable.
  • 1

#1159 Yal

Yal

    Gun Princess

  • Global Moderators
  • 9160 posts
  • Version:GM:Studio

Posted 22 May 2012 - 01:20 PM

The only place where I ever used them was in for loops, because I thought it was hilarious to write "c++" for the counter variable. The habit still lingers, I always use "c" as the counter index in my for loops (except when nested).
  • 0

#1160 Big J

Big J

    GMC Member

  • GMC Member
  • 2852 posts
  • Version:GM8.1

Posted 22 May 2012 - 05:34 PM

I too find it amusing to use a variable named "c" or even "C" in a for loop. :D
  • 0

#1161 Dark Matter

Dark Matter

    RPG Expert

  • GMC Member
  • 3196 posts
  • Version:GM:Studio

Posted 22 May 2012 - 09:29 PM

The only place where I ever used them was in for loops, because I thought it was hilarious to write "c++" for the counter variable. The habit still lingers, I always use "c" as the counter index in my for loops (except when nested).

How dare you break the unwritten law that the increment variable in loops must be "i"!
  • 0

#1162 Tsn

Tsn

    GMC Member

  • GMC Member
  • 282 posts
  • Version:Unknown

Posted 24 May 2012 - 04:47 AM

There should be a transparent color avaivable in the sprite editor.
  • 0

#1163 Zoltan Kriven

Zoltan Kriven

    GMC Member

  • GMC Member
  • 388 posts
  • Version:GM8.1

Posted 25 May 2012 - 05:56 AM

Here's one, for drawing games, make the sprite editor available for the player while playing the game.
  • 2

#1164 Samuel Venable

Samuel Venable

    GMC Member

  • Banned Users
  • 632 posts
  • Version:GM:Studio

Posted 25 May 2012 - 06:10 PM

^ +1 that's a good idea, that way we wouldn't need dlls for that.

An undo function for the resource tree couldn't hurt.
This is good for when you accidentally delete the wrong object or something else important.

Edited by time-killer-games, 25 May 2012 - 06:13 PM.


#1165 Dark Matter

Dark Matter

    RPG Expert

  • GMC Member
  • 3196 posts
  • Version:GM:Studio

Posted 27 May 2012 - 07:36 AM

There should be a transparent color avaivable in the sprite editor.

There is. You can change the opacity of your current drawing colour.

Here's one, for drawing games, make the sprite editor available for the player while playing the game.

This would be a bad idea. It's a niche thing, and it's far better to make your own, more customisable editor for your game.

An undo function for the resource tree couldn't hurt.
This is good for when you accidentally delete the wrong object or something else important.

Yeah, the undo features in GM are very lacking. You can delete a lot of things accidentally and have no way of retrieving them afterwards, which can be very, very frustrating.
  • 1

#1166 paul23

paul23

    GMC Member

  • Global Moderators
  • 3918 posts
  • Version:GM:Studio

Posted 30 May 2012 - 09:39 PM

Closed this awaiting some moderation discussion.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users