Central Games Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Making GML Easier Pt.2 (Custom Functions)

4 posters

Go down

Making GML Easier Pt.2 (Custom Functions) Empty Making GML Easier Pt.2 (Custom Functions)

Post by John(GmMkr-Admin) Wed Oct 01, 2008 6:27 pm

GML KNOWLEDGE NEEDED

I'm sure that you've checked out my old topic on making GML easier.
It talked about creating your own variables. Such as shortening "keyboard_check_pressed(ord('A'))" to something as small as "A" and as useful as that was I will now be showing you how to make your own functions!
(If you haven't seen my other topic then I believe you should, it's simpler than this.)

Now, I don't want to over-complicate this so here is something for your relief.
AFTER YOU DO THIS, EXPORT ALL OF YOUR SCRIPTS!
That way all you have to do later is import them.

Let's get started!

Now, let's say I wish to make a function that sets the direction and speed. (I know there is one already.)
You would create a script.

Code:

speed = argument0
direction = argument1

(Please do this now.)
Now I want you to name your script something like "motion" without the quotes.

(I'll explain how this works later.)

Now, create an object (make sure it has a sprite) and make a create event.
There are two ways to execute scripts, "script_execute" or you can just type the name of the script and give it parenthesis.

i.e. motion();

That would also execute the script. NOW REMEMBER! Your script has arguments!

So, in order, you would write the arguments within the parenthesis.

motion(4,0)

That would make your objects move at a speed of 4 in direction 0.

TADA!

Using this method you can make as many functions as you wish.
Combine them or make them from variables!

Even pros will find this useful.

All it does is set the arguments accordingly. motion(argument0,argument1)
There are up to 16 arguments so you can make really nice functions this way.

Well, enjoy!

-John

(If you find something wrong with this tutorial please tell me so I may fix it.)
John(GmMkr-Admin)
John(GmMkr-Admin)
Admin
Admin

Number of posts : 501
Warning :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Reputation :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue100 / 100100 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Registration date : 2008-07-17

Back to top Go down

Making GML Easier Pt.2 (Custom Functions) Empty Re: Making GML Easier Pt.2 (Custom Functions)

Post by SoulRed12 - Moderator Wed Oct 01, 2008 11:31 pm

This is indeed a useful technique, and it helps keep code organized. I wish more people did this, especially when I'm helping someone by looking through their gmk... <_<
SoulRed12 - Moderator
SoulRed12 - Moderator
Admin
Admin

Male
Number of posts : 428
Age : 33
Location : USA
Job/hobbies : Music, psychology, programming, acting, basketball, and martial arts.
Warning :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Reputation :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue100 / 100100 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Registration date : 2008-07-19

http://soulred12.wordpress.com

Back to top Go down

Making GML Easier Pt.2 (Custom Functions) Empty Re: Making GML Easier Pt.2 (Custom Functions)

Post by John(GmMkr-Admin) Thu Oct 02, 2008 5:18 pm

Well thank you.
John(GmMkr-Admin)
John(GmMkr-Admin)
Admin
Admin

Number of posts : 501
Warning :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Reputation :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue100 / 100100 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Registration date : 2008-07-17

Back to top Go down

Making GML Easier Pt.2 (Custom Functions) Empty Re: Making GML Easier Pt.2 (Custom Functions)

Post by DT-170x Thu Oct 02, 2008 5:47 pm

What about

render_HalfQ_BG (Number) 1 or 0
render_HalfQ_sprite ()
Sprite_Skip_frame (Number,Number)

This will half the graphics of the sprite.

Some time you want to half the visuals of the graphics. If you got a low-end computer.

Sprite_Skip_frame will skip the frames per each sprite. Also good for low end Computer.

The frames go as 1,3,5,7
The second number how much ship. Like I enter 2 then it will go as 0,2,4,6 frame.
DT-170x
DT-170x
Junior Member
Junior Member

Male
Number of posts : 109
Age : 34
Location : Be a physic to know that question
Warning :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Reputation :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue9 / 1009 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Registration date : 2008-08-22

Back to top Go down

Making GML Easier Pt.2 (Custom Functions) Empty Re: Making GML Easier Pt.2 (Custom Functions)

Post by John(GmMkr-Admin) Thu Oct 02, 2008 6:24 pm

What are you getting at?
John(GmMkr-Admin)
John(GmMkr-Admin)
Admin
Admin

Number of posts : 501
Warning :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Reputation :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue100 / 100100 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Registration date : 2008-07-17

Back to top Go down

Making GML Easier Pt.2 (Custom Functions) Empty Re: Making GML Easier Pt.2 (Custom Functions)

Post by panneers740 Thu Nov 05, 2009 2:04 am

Not necessarily. There's no reason a given input couldn't be converted to GML and stuck in an object's event where it would be compiled and run at normal GML speed.

Creating your own language gives you a lot more control over what you let users do. GML might be too general and give too much control to users for your purposes.
======================
high speed internet providers
cv template download

panneers740
Newbie
Newbie

Number of posts : 3
Warning :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Reputation :
Making GML Easier Pt.2 (Custom Functions) Left_bar_bleue0 / 1000 / 100Making GML Easier Pt.2 (Custom Functions) Right_bar_bleue

Registration date : 2009-11-05

Back to top Go down

Making GML Easier Pt.2 (Custom Functions) Empty Re: Making GML Easier Pt.2 (Custom Functions)

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum