GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2009-06-08 03:20:28

EneilShade
Member
Registered: 2009-06-08
Posts: 4

draw_self()

I really cannot believe that I am submitting something this simple: but it really will save a lot of time. Those of you out there whom have played with Game Maker more than a little bit will be familiar with Game Maker's trait of not drawing the current sprite when any code is put in the draw event. While this is a good feature, occasionally, it can get a little annoying. If, for some debug reason, you want to draw a value on top of your sprite (to see the value of some variable) you need to put in code similar to this: draw_sprite_ext(sprite,subimg,x,y,xscale,yscale,rot,color,alpha); (the values would of course be filled in). But once you do this a few times, while you quickly memorize the code, gets a little annoying. So one day I decided to create a little, very simple script that any newbie could figure out:

draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,image_blend,image_alpha);

(pardon me for not using the proper submission rules, but this is just too simple to waste that effort).

Have fun!

EneilShade

Offline

#2 2009-06-08 08:08:08

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: draw_self()

Well, thanks, that's useful, but it's also one of the first scripts submitted to GMLscripts.com.

http://www.gmlscripts.com/script/draw_me


Abusing forum power since 1986.

Offline

#3 2009-06-08 14:10:33

EneilShade
Member
Registered: 2009-06-08
Posts: 4

Re: draw_self()

AAAGH!! I looked for a duplicate before I posted! I could not find one! It would appear that I overlooked it. I apologize for that.

Offline

#4 2009-06-08 16:07:04

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: draw_self()

Tell me if I am wrong but such a script is maybe useful but is also considerably slower than writing this in the draw event. I think everyone should take 30 more seconds to write this down instead of using a script.

Offline

#5 2009-06-08 16:10:09

EneilShade
Member
Registered: 2009-06-08
Posts: 4

Re: draw_self()

Marchal_Mig12 wrote:

Tell me if I am wrong but such a script is maybe useful but is also considerably slower than writing this in the draw event. I think everyone should take 30 more seconds to write this down instead of using a script.

What? All you have to add in the draw event with this as a script is 'draw_self();'. Could you please better explain what you mean by the

slower than writing this in the draw event

Last edited by EneilShade (2009-06-08 16:10:44)

Offline

#6 2009-06-08 20:43:26

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: draw_self()

Calling scripts has a certain amount of overhead. This would be faster if it was in a code box in the Draw Event. I don't agree that it would be better placed there. The whole point of a script is to save time writing, editing, and reading code, as well as to reduce repeated code. I think in everyday use, the difference between their execution speeds is negligible. For special cases where you have hundreds of instances, hard-coding it in the Draw Event might produce a noticeable difference in speed.

In the Game Maker community, a lot of people put too much focus on the speed of the interpreter. They should spend more time thinking about how to do things differently, rather than how to shave off a few milliseconds with simple yet tedious optimizations. I'd save those optimizations only for deeply iterated functions that represent a substantial total percentage of the game's CPU demands.


Abusing forum power since 1986.

Offline

#7 2009-06-08 20:48:48

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: draw_self()

For such a script I think it does not need a script but this is my opinion and my coding style.

xot wrote:

In the Game Maker community, a lot of people put too much focus on the speed of the interpreter.

Yeah, but in that case, I think that 10 letters or 40 letters will not affect the time consumption of your coding.

Last edited by Marchal_Mig12 (2009-06-08 20:52:56)

Offline

#8 2009-06-08 20:50:25

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: draw_self()

Of course, code how you like. Personally, I think this should be built-in function of Game Maker. That's why I wrote it (as have had many others before and after me).


Abusing forum power since 1986.

Offline

#9 2009-06-08 20:53:23

Marchal_Mig12
Member
Registered: 2009-05-21
Posts: 75

Re: draw_self()

xot wrote:

Of course, code how you like. Personally, I think this should be built-in function of Game Maker. That's why I wrote it (as have had many others before and after me).

That is right.

Offline

#10 2009-06-08 22:51:38

EneilShade
Member
Registered: 2009-06-08
Posts: 4

Re: draw_self()

Oh! That makes sense. Hmm... Good point.

Offline

Board footer

Powered by FluxBB