• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

draw_self() Unknown Function [SOLVED]

N

NizarPlayz

Guest
I can't use draw_self() it says Unknown function or script. Please help! I'm using GM 8.0 Pro any help would be really appreciated! What code do i use instead of draw_self() if i can't use it.. :/
 
N

NizarPlayz

Guest
I was searching on YT for car physics and then i copied and pasted this code
Code:
draw_set_alpha(1)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation+90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation+90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation-90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation-90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_self()
and then it gave error at the last line
Unknown function or script: draw_self() and then i used angle_difference code in other object it also gave the same error please anyone help me
 
Last edited by a moderator:

Tthecreator

Your Creator!
Well the point of a yt video is for you to learn what he is doing. Not really for you to copy it over without understanding the code.
My question is: do you understand what draw_self() is even supposed to do?
as for the answer to your question: check your profile post, someone else already gave it.
 
W

Wayfarer

Guest
I was searching on YT for car physics and then i copied and pasted this code
Code:
draw_set_alpha(1)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation+90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation+90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation-90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation-90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_self()
and then it gave error at the last line
Unknown function or script: draw_self() and then i used angle_difference code in other object it also gave the same error please anyone help me
Replace "draw_self();" with "draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);".

For "angle_difference()"... I've forgotten off the top of my head, but am looking now.

Edit: Copy/Paste this code into a new script titled "angle_difference":
Code:
/// angle_difference(angle1, angle2)
//
//  Returns the relative angle [-180..180] between the given angles.
//
//      angle1      1st direction in degrees
//      angle2      2nd direction in degress
//
/// GMLscripts.com/license
{
   return ((((argument0 - argument1) mod 360) + 540) mod 360) - 180;
}
Tell me if that works.
 
N

NizarPlayz

Guest
Well the point of a yt video is for you to learn what he is doing. Not really for you to copy it over without understanding the code.
My question is: do you understand what draw_self() is even supposed to do?
as for the answer to your question: check your profile post, someone else already gave it.
I'm using GM 8.0 and i'm not good in coding as i'm learning it and i don't know what to do because the draw_self() code does not exists and also angle_difference
 
N

NizarPlayz

Guest
like this?
Code:
draw_set_alpha(1)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation+90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation+90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation-90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation-90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_sprite_ext
??
 
N

NizarPlayz

Guest
Replace "draw_self();" with "draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);".

For "angle_difference()"... I've forgotten off the top of my head, but am looking now.

Edit: Copy/Paste this code into a new script titled "angle_difference":
Code:
/// angle_difference(angle1, angle2)
//
//  Returns the relative angle [-180..180] between the given angles.
//
//      angle1      1st direction in degrees
//      angle2      2nd direction in degress
//
/// GMLscripts.com/license
{
   return ((((argument0 - argument1) mod 360) + 540) mod 360) - 180;
}
Tell me if that works.
I don't know what to do with the draw_self() cuz i'm bad at coding as i'm learning it so.. :/
 
W

Wayfarer

Guest
The answers are listed above :p
If you follow it directly you should have it working.

Like @Tthecreator said, you should try to understand what's going on too.
 
N

NizarPlayz

Guest
The answers are listed above :p
If you follow it directly you should have it working.

Like @Tthecreator said, you should try to understand what's going on too.
I didn't even understand a word what you said there ''Replace "draw_self();" with "draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);".''
 
W

Wayfarer

Guest
Code:
draw_set_alpha(1)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation+90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation+90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation-90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation-90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);
You literally just replace draw_self() as shown above. And then make a script called angle_difference with the code in the earlier post for that.
 
S

ScrabbitRabbit

Guest
I've never used GM 8 but is it possible that draw_self() simply isn't a function in that version of Game Maker? You could probably just use one of the other draw functions and just name the sprite that you want to use (or just put sprite_index). You're already using draw_sprite_ext so you could just use that for the main body, too, just use the default variables in all the fields, basically.

Is there no way you could upgrade to Studio 1.4? The professional version is Pay What You Want on Humble Bundle right now.
 
N

NizarPlayz

Guest
Code:
draw_set_alpha(1)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation+90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation+90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
 draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation-90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation-90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle, image_blend, image_alpha);
You literally just replace draw_self() with that line shown above. That manually produces draw_self().
Oh i see ok i will try and tell you in a few mins if it works or not
 
N

NizarPlayz

Guest
I've never used GM 8 but is it possible that draw_self() simply isn't a function in that version of Game Maker? You could probably just use one of the other draw functions and just name the sprite that you want to use (or just put sprite_index). You're already using draw_sprite_ext so you could just use that for the main body, too, just use the default variables in all the fields, basically.

Is there no way you could upgrade to Studio 1.4? The professional version is Pay What You Want on Humble Bundle right now.
Well yes draw_self() isn't a function :/ and i like sticking to the main GM which i use
 
N

NizarPlayz

Guest
God dammit now i have another error...
Unknown function or script: physics_apply_force
FUUUUUUUU
 

Tthecreator

Your Creator!
but do you know what draw_self() is supposed to do?
Whether it is working or not, please tell me what it's supposed to do.
Okay, I would be a little too harsh if I just asked you that so here is a link: http://docs.yoyogames.com
This is the link to the Game Maker: Studio manual. (I know, not the gm8 one, but we are looking at a studio function after all)
Now without copy and pasting stuff, would you be able to use given manual to search for what this function does.

Also in your latest example you just wrote "draw_sprite_ext" which is wrong.
Do you know what a function is? A function is a piece of code that you can give some data and then does something with that data. (In some cases it can also give you some data back)
Now a function can be something like c=add(5,3); (the function add doesn't actually exist, this is all theoretical)
What that add function would do is take 5 and 3 and add them together. The "c=" part would indicate that we put the answer of that function inside the variable "c". If you don't know what variables are, then please ask.
Now a function starts with a name, in this example "add". Followed by a "(". Then there are the arguments. arguments are the information that your function needs to do its job. Like our add function would need 2 numbers. one argument would be 5 and the other would be 3. An argument could also be a variable, some math or the output of another function. A function could have any number of arguments, even none in which case the "(" is directly followed by ")". You can differentiate between different arguments using a "," and at the end of your arguments you put a ")". Now you are using the function draw_sprite_ext go ahead and look at the manual what kind of arguments it needs.
I think you have a lot to learn but with a little bit of patience you can come anywhere. But please, try to be a little bit less "pushy" and a little bit less "spammy". This response took quite a while to write, and in the meantime you've kept spewing out messages. I'm sorry that I said what I just said.
The thing is, I don't want you to just blindly copy and paste code without knowing what it does. You need analyze and understand it. Maybe not every bit at the beginning, but when some piece of code uses a function you've never seen then it's at least worth it to look it up in the manual. I don't even remember if gm8 had one, but press f1 and see what happenes.
 
N

NizarPlayz

Guest
Nevermind i got rid of this error but i only have this error:
ERROR in
action number 1
of Draw Event
for object obj_player:

Error in code at line 2:
draw_sprite_ext(spr_wheel,0,x+lengthdir_x(center_to_front*0.75,-phy_rotation)+lengthdir_x(center_to_front/2-center_to_front/5,-phy_rotation+90),y+lengthdir_y(center_to_front*0.75,-phy_rotation)+lengthdir_y(center_to_front/2-center_to_front/5,-phy_rotation+90),1,1,-phy_rotation + richting*0.8,c_white,image_alpha)
^
at position 45: Unknown variable center_to_front
:/
 
W

Wayfarer

Guest
@NizarPlayz: By upgrading to GMS1 (as mentioned above, you can get it on the Humble Bundle). From there you can upgrade to GMS2 for a cheaper rate too.

You won't be able to get those physics functions in GMS8 :p
 

Llama_Code

Member
Now how the heck am i gonna solve this one.. :/
I would suggest you either search for a GM8 specific car physics tutorial or upgrade to Studio. Now with the humble bundle deal would be an excellent time.

I would also suggest you get a better handle on coding before tackling something like car physics but that's on you.

That one last error won't be the last one you encounter, you will get more once you fix that. I hardly think anybody wants to downgrade an entire example for you.
 
N

NizarPlayz

Guest
but do you know what draw_self() is supposed to do?
Whether it is working or not, please tell me what it's supposed to do.
Okay, I would be a little too harsh if I just asked you that so here is a link: http://docs.yoyogames.com
This is the link to the Game Maker: Studio manual. (I know, not the gm8 one, but we are looking at a studio function after all)
Now without copy and pasting stuff, would you be able to use given manual to search for what this function does.

Also in your latest example you just wrote "draw_sprite_ext" which is wrong.
Do you know what a function is? A function is a piece of code that you can give some data and then does something with that data. (In some cases it can also give you some data back)
Now a function can be something like c=add(5,3); (the function add doesn't actually exist, this is all theoretical)
What that add function would do is take 5 and 3 and add them together. The "c=" part would indicate that we put the answer of that function inside the variable "c". If you don't know what variables are, then please ask.
Now a function starts with a name, in this example "add". Followed by a "(". Then there are the arguments. arguments are the information that your function needs to do its job. Like our add function would need 2 numbers. one argument would be 5 and the other would be 3. An argument could also be a variable, some math or the output of another function. A function could have any number of arguments, even none in which case the "(" is directly followed by ")". You can differentiate between different arguments using a "," and at the end of your arguments you put a ")". Now you are using the function draw_sprite_ext go ahead and look at the manual what kind of arguments it needs.
I think you have a lot to learn but with a little bit of patience you can come anywhere. But please, try to be a little bit less "pushy" and a little bit less "spammy". This response took quite a while to write, and in the meantime you've kept spewing out messages. I'm sorry that I said what I just said.
The thing is, I don't want you to just blindly copy and paste code without knowing what it does. You need analyze and understand it. Maybe not every bit at the beginning, but when some piece of code uses a function you've never seen then it's at least worth it to look it up in the manual. I don't even remember if gm8 had one, but press f1 and see what happenes.
Jeez dude i told you i'm learning to code since i left GM for 6 months now i have came back and i forgot all the coding that i learned before..
 
N

NizarPlayz

Guest
I would suggest you either search for a GM8 specific car physics tutorial or upgrade to Studio. Now with the humble bundle deal would be an excellent time.

I would also suggest you get a better handle on coding before tackling something like car physics but that's on you.
Fine I will get GMS
 
N

NizarPlayz

Guest
And i'm 11 Year old Kid the coding is hard for me i'm still learning it. It was my dream to make games I didn't knew I would get errors in GM 8.0 :/
 
W

Wayfarer

Guest
Well, it's worth upgrading to GMS1. Ask your parents! You can get GMS1 in the Humble Bundle for $1.
 

Cpaz

Member
Aren't there also tutorials in both GM8 and GMS 1.4? I would think that would be a nice starting point.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
If the topic is solved, please do NOT remove the title. Add [SOLVED] to the title but keep the original text too, as otherwise the topic becomes useless as the search function won't find it and you can't see from the forum overview what was being discussed.
 

Tthecreator

Your Creator!
Hey! I got GMS 1 and when i load my project it says GMX Saving and suddenly it stops responding help meh ;p
Great you got it! That's a dollar well spend! Now the GMX saving thing can take some time, but not something like 15 minutes or more.
What step are you at? Did you just use the import function and are you getting it directly after importing?
 
N

NizarPlayz

Guest
Great you got it! That's a dollar well spend! Now the GMX saving thing can take some time, but not something like 15 minutes or more.
What step are you at? Did you just use the import function and are you getting it directly after importing?
Yes i used import thing to load my .GMK project it says loading data and after that it says GMX Saving and then it gets stuck it won't load ahead then when i click it, it says Game Maker Studio has stopped responding i don't know why this is happening i really want to complete my project :/
 

Tthecreator

Your Creator!
Yes i used import thing to load my .GMK project it says loading data and after that it says GMX Saving and then it gets stuck it won't load ahead then when i click it, it says Game Maker Studio has stopped responding i don't know why this is happening i really want to complete my project :/
This sounds like some sort of bug... Maybe you can open gms1, open the help menu and click "report a bug". I do have to say that since the release (and even amidst the making) of gms2 support hasn't been that great for gms1. Let's just hope you have some luck.
 
N

NizarPlayz

Guest
This sounds like some sort of bug... Maybe you can open gms1, open the help menu and click "report a bug". I do have to say that since the release (and even amidst the making) of gms2 support hasn't been that great for gms1. Let's just hope you have some luck.
Without GMS 1 I can't complete my project :/ Well i'm uploading a video of the error.. When it's done i will give the link to you and ya watch it and tell me how to fix the error
 

Tthecreator

Your Creator!
Sorry, I'm currently on a databundle and won't be able to download stuff, watch videos, etc. I should put that in my signature. In fact, I will do that right now.
 
N

NizarPlayz

Guest
This sounds like some sort of bug... Maybe you can open gms1, open the help menu and click "report a bug". I do have to say that since the release (and even amidst the making) of gms2 support hasn't been that great for gms1. Let's just hope you have some luck.
I'm making a top down 3D Racing game in GM 8.0 you can't use some codes,variables and functions so i decided to get GMS 1 but bad luck :/ it won't open my project
 

Xer0botXer0

Senpai
So I had a similar problem and used the search box to find topics that may help me solve mine.. alas they were renamed to 'solved' so I couldn't find any matches.
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
If the topic is solved, please do NOT remove the title. Add [SOLVED] to the title but keep the original text too, as otherwise the topic becomes useless as the search function won't find it and you can't see from the forum overview what was being discussed.
You seem to have missed this post so I'll just remind you again to make sure...

Oh and just in case you miss this post too, I've edited the topic title for you.

;)
 
Top