Daniel Mallett
Member
I have been using Game maker for a while. It's worked very well for me up till now. It has recently come to light that I may have been doing this wrong the whole time.
I understand that GMS2 has events obviously. Draw create step. Great. Until now I have been doing things like if mouse is clicked then do this under the step code and sometimes In create and draw events.
Now there are other events such as mouse clicks a asynchronous events etc. I have always been under the impression that a step event with a if 'mouse is clicked is then' is the same as a mouse event 'just do it'.
Apparently according to my source 'A programmer but not used GMS' seems to think that this is really important.
It is the difference between an 'interrupt' (I use this term loosely) and lets say a structured loop based approach. I.E do it again and again as many times as you can within one 'cycle'.
This is not an RTFM situation. This is I have read the manual and I'm not sure situation.
The problem I have is that I like to do thing correctly but because of the speed of modern computing makes it difficult to determine if what you are dong Is in fact correct. Because everything is so damn fast you can't easily tell by eyeballing it if it's truly correct or not.
I almost preferred it where everything was slow and short on memory. It makes it hard to learn because your not punished for it. As one should be.
Any advise would be gold. For example what is technically the most efficient way possible (In GMS2) to draw a square in the middle of the screen if a mouse has been clicked screen. (draw event)
This is what I would do:
x1 = 0;
y1 = 0;
x2 = 128;
y2 = 128;
if point_in_rectangle(mouse_x, mouse_y, x1, y1, x2, y2)
{
if mouse_check_button_pressed(const_action_click)
{
draw_rectangle(x1, y1, x2, y2, 1);
}
}
Basically given the very simple code stated above. Is this the best, most effective and efficient way possible to do this in GMS2? Or should I put all mouse events under the mouse event?
Sorry this was a long one I hope this makes sense.
(I'm not a total noob have made several games but my confidence is shaken because I may have been doing it totally ass about face the whole time)
I understand that GMS2 has events obviously. Draw create step. Great. Until now I have been doing things like if mouse is clicked then do this under the step code and sometimes In create and draw events.
Now there are other events such as mouse clicks a asynchronous events etc. I have always been under the impression that a step event with a if 'mouse is clicked is then' is the same as a mouse event 'just do it'.
Apparently according to my source 'A programmer but not used GMS' seems to think that this is really important.
It is the difference between an 'interrupt' (I use this term loosely) and lets say a structured loop based approach. I.E do it again and again as many times as you can within one 'cycle'.
This is not an RTFM situation. This is I have read the manual and I'm not sure situation.
The problem I have is that I like to do thing correctly but because of the speed of modern computing makes it difficult to determine if what you are dong Is in fact correct. Because everything is so damn fast you can't easily tell by eyeballing it if it's truly correct or not.
I almost preferred it where everything was slow and short on memory. It makes it hard to learn because your not punished for it. As one should be.
Any advise would be gold. For example what is technically the most efficient way possible (In GMS2) to draw a square in the middle of the screen if a mouse has been clicked screen. (draw event)
This is what I would do:
x1 = 0;
y1 = 0;
x2 = 128;
y2 = 128;
if point_in_rectangle(mouse_x, mouse_y, x1, y1, x2, y2)
{
if mouse_check_button_pressed(const_action_click)
{
draw_rectangle(x1, y1, x2, y2, 1);
}
}
Basically given the very simple code stated above. Is this the best, most effective and efficient way possible to do this in GMS2? Or should I put all mouse events under the mouse event?
Sorry this was a long one I hope this makes sense.
(I'm not a total noob have made several games but my confidence is shaken because I may have been doing it totally ass about face the whole time)