Game Maker Language Tutorial Tutorial
(easy-to-learn)
version 6.2 Made by General_Leo (Pixel Pere!t Games)
"ndex #old $trl and %ress &. &. 'nter te keyord (in %ink) to ind tat se!tion o te tutorial KEYWORD PART
*+', T*2 T#0''1 &*03 &"5' 4"76
bout tis tutorial tutorial /asi! setu% o GML /asi! $ommands 4ort arrays ex%lanation 4mart !odes 'nding !omments
--------------------------------------------------------------------------------------------------------------------------------------------------ONE1 - About this Tutorial --------------------------------------------------------------------------------------------------------------------------------------------------8ou may tink tis is yet anoter !onusing tutorial attem%ting to ex%lain o game maker9s !oding orks. ell let me :ust say tat "9m ere to el% all o you o 0'LL 0'LL8 8 ant to learn it but don9t ant to take !lasses or attem%t to understand some o te mumbo :umbo o te oter GML tutorials out tere. " %romise " ill do at " !an to stay aay rom using te!ni!al terms. "9ll talk as i you guys ave no idea at you;re doing. Tis sould el% you understand tings a lot better. " <* re!ommend you at least kno te basi!s o <=< ( note tat !a%ital letters <* matter? Te built-in !ommands ill alays be loer !ase.
if someting someting do tis /y re%la!ing @someting@ it someting su! as a variable> you !an tell GM at to do but only i it meets a reAuirement. Let;s start by orrying about @someting@ rater tan te @do tis@ %art or no. if Timer Timer ", do tis Tat !ode ill do atever as long as te variable @Tim @Timer@ er@ eAuals ,. 8ou !an also use B (less ten) or C (greater ten) in te %la!e o te D sign. 0emember @timer@ and @Timer@ are dierent so be sure to use
!orre!t !a%italiEation !a%italiEation?? if Timer Timer #, do tis if Timer Timer # , do tis #ere " :ust ant to %oint out tat s%a!es beteen everyting doesn9t really matter. Te Te above !ode is te '7$T same same as te one belo it. Tey read te same so it9s :ust a matter o at is easier to read or you. if Timer Timer #" , #" , do tis noter ting you you !an do is use to to C> D> or B signs. signs. GM understands CD CD as being @greater tan tan or eAual to@. lso> instead o using a variable> you !an use a !ommand. Te @i@ !ommands are listed in te !odeing box at te bottom en you start to ty%e. ll o i! are ex%lained in te el% ile. (GM manual) if $ista%ce&to&ob'ect( if $ista%ce&to&ob'ect(me me)) " ,F do tis Tis may look like a big :um% rom te above !odes but let;s take a look at it. " te distan!e to te ob:e!t @me@ is eAual to ,F> it ill do te !ode. (tats ,F %ixels by te ay) &or tis !ommand> you %robably ould ant to use C or B instead. Tis !ommand is oten used in enemy " to dete!t o ar rom te %layer te enemy is or o ar rom a !ertain ob:e!t. Tere is a se!tion o tis tutorial ere " ex%lain a bun! o !ommands su! as tis one. $e!k te index. if $ista%ce&to&ob'ect( if $ista%ce&to&ob'ect(me me)) # F ** Timer ** Timer # , do tis *k> tis !ode is a little arder to understand but still easy to use. @==@ means :ust tat... it means @and@. 4o tis !ode means> i te ob:e!t @me@ is urter ten F %ixels aay rom tis ob:e!t +< tis ob:e!t9s variable @Timer@ @Timer@ is eAual to ,> it ill run te @do tis@ %art o te !ode. 0emember it ill +*T do anyting unless it meets bot reAuirements. 8ou 8ou !an add as many reAuirements as you ant by :ust %utting more and more ==9s in tere... if Timer Timer # , ** + ,F do tis $an you see anyting a nyting rong it tis !ode 8es it is 0*+G and GM ill %oint tat out. en using ==> it9s kinda like using @i@ only it9s mixing it it anoter. en using ==> you must re%eat te !ommand or variable as i it ere se%arate. no it ill also a!!e%t it i it9s eAual to it i! makes it give you a range rom , to ,F. 5'08 im%ortant you remember tat i one o te symbols are going to be an D sign> tat it9s se!ond. BC also ould ork. /asi!ally !e!king to make sure it is not te amount. if %ot if %ot Timer Timer " , do tis
+o tis !ode looks a little dierent but it is :ust like using BC only it looks better and may be a little easier to read. (i Timer Timer BC ,) Tere is yet anoter ay to use not... not... if Timer , " , do tis Tat !ode is te exa!t same as te last. %la!ing a ? in tere orks '7$TL8 '7$TL8 like %utting @not@. sing tis and == in tere you !an make your !odes looks %retty !om%li!ated. I) lso> note tat un!tions (almost anyting but variables) need te ? beore it instead o ater ater.. n easy ay to kno en it9s beore or ater is i it as an D sign or not. " it does> it !omes beore te D sign. " not> it !omes beore te un!tion itsel. if Timer Timer D , Timer Timer D 2 do tis Tis is te last o te sort!uts i9m gonna tell you about. Putting JJ in your !ode is like %la!ing a mirror in tere. Tis !ode ill a!tivate i Timer is eAual to , *0 eAual to 2. 8es> tis is a re%la!ement or %utting in @or@. Te J lines are made by olding sit and %ressing te button above your enter key.
+o let;s look urter into te same !odes as beore but mess it te @do tis@ %art. if . if . " 2 . " ,FF " ,FF Tis !ode ould !e!k to see i te ob:e!t9s x value is exa!tly eAual to 2. " it is ten it ill !ange te x value to te value ,FF K :um%ing your ob:e!t to a dierent s%ot in te room. if Timer Timer #" ,F #" ,F /o0e&toar$s&poi%t( ,F>2F>1F) ,F>2F>1F) Tat !ode ill !e!k i Timer is eAual or over ,F. " it is> it ill move te ob:e!t toards te %oint ,Fx2F at te s%eed o 1F. #o about e add more tan one ee!t if Timer , " 2 /o0e&toar$s&poi%t( ,F>2F>1F) ,F>2F>1F) Ti/er " 2 3 *k> no it9s starting to look like !ode u. ust break it don and see at it says. " timer is +*T (noti!e te ? in tere making it mean not) eAual to 2> it ill move toards te %oint +< !ange Timer Timer eAual to 2 making te !ode not do anyting else. sing and N in your !ode is :ust like using bra!kets in <=<. " you ave more tan one ee!t> you ill need to add ater te @i@ %art and ten add a N at te end i te entire ee!t list. " you are using ==> you still only need one set o bra!kets. if Timer Timer " , ** $ista%ce&to&ob'ect(me $ista%ce&to&ob'ect(me)) + ,F ** . #" ,F #" ,F xD, yD2 3 +oti!e " used 1 is but " still only need , set o bra!kets. 8ou9ll 8ou9ll never need more tan one set unless you ave a reAuirement inside o a reAuirement like tis. if Timer Timer D , Timer Timer D 2 2 . " 1FF " 1FF 4"2FF 4"2FF if Timer D 2 2 Timer D 1 33 " Timer Timer is eAual to , or eAual to 2> it ill move te ob:e!t to 1FFx2FF and i Timer as 2> it !anges Timer
to 1. 0emember tis !ode ould still a!tivate i Timer is , but it :ust ill remain , at te end o o tis !ode.
lso> remember you don9t alays need to use an @i@ in your !ode. Timer 5" , 5" , " your !ode is in te ste% event o an ob:e!t> %utting tis !ode ill make it !onstantly raise te value o @Timer@@ by ,. @Timer Timer D , Tis "4 dierent be!ause it ould !ange te value o @Timer@ to te value o , meaning it ill :ust kee% !anging it to , (i %ut under ste%). " you;re going to do someting like tat> (or lag reasons) you may ant to use someting like tis... if Timer , D , Timer D , +o again> assuming tis !ode is under te @ste%@ event o an ob:e!t> tis !ode ill *+L8 *+L8 !ange Timer to , i it isn9t already ,. sing te last !ode ill be !anging Timer to , every ste% o te game. anoter el%ul el%ul ting to learn learn is o to ee!t an ob:e!t ob:e!t it te !ode being being in anoter ob:e!t. ob:e!t. . " Me " Me6. 6. " tere is an ob:e!t named @Me@ in te room and you run tis !ode rom anoter ob:e!t> it ill !ange te x value o tis ob:e!t to te ob:e!t @Me@9s x value. 4till it me . " Me " Me6. 6. 4 " Me " Me64 64 Tis !ode ill make te ob:e!t 9sti!k9 to te ob:e!t @Me@ by kee%ing te x and y values te same Oee% in mind it ill only u%date every time you run te !ode. " in ste% and you aven;t !anged te game s%eed> it ill @:um%@ to te ob:e!t 1F times ea! se!ond. "t9s !ommon to see it trail beind you by a e %ixels beore u%dating again. "9d re!ommend draing a s%rite or tis instead o using ob:e!ts but anyays... . 5" , 5" , Tis !ode is most likely te ty%e o !ode used in most %latormers or 0PGs. " %ut into te @keyboard let@ event o an ob:e!t> it ill ra%idly move te ob:e!t to te rigt. using a - (minus) sign instead o te %lus sign ill !ause it to go ba!kards making it (in tis !ase) go let.
8ou sould no kno some o te ma:or %arts o !oding. +o all tat is let is learning te built-in !odes rom <=< and maybe a e more even. "9d re!ommend !e!king te el% ile (Game Maker Manual) and !li!k te index tab. Ten start to ty%e some stu in or use te sear! tab i you ave no idea o te !ode you need. nyays> ere are some im%ortant ones... --------------------------------------------------------------------------------------------------------------------------------------------------T7REE8 - Basic co//a%$s --------------------------------------------------------------------------------------------------------------------------------------------------Tese are only te most !ommon !ommands. PL'4' use te GM manual to look u% all o tem. 4im%ly o%en GM and go to @el%@. lso note tat all !ommands ill +*T ork i you use !a%ital letters. 4'TT"+G P + */'$T ------------------
,. i/a9e&alpha Tis !ontrols o trans%arent (see-troug) your ob:e!t is. F ould be !om%letely non-visible and , ould be !om%letely visible. sually F.3 is a good setting making it see-troug but not too mu! so you !an9t see it at all. GM6 !an do alot o al%a values it very little or no lag at all. GM.1 ad a lot o trouble doing tis.
2. i/a9e&i%$e. Tis !ontrols at rame your ob:e!t is on. (o te s%rite your ob:e!t !urrently as). 0emember s%rites start it rame F so i your s%rite as our rames> tey are numbered F-1. " you use tis> you %robably ant to also set your image_s%eed to F so your image_index isn9t !y!ling troug te rames ater you set it.
1. i/a9e&spee$ 4etting your image s%eed is setting o ast it ould %lay troug te rames o a s%rite. *ten times> %utting an ob:e!t in a room ill make te s%rite a%%ear really ast and it ill need to be sloed don. in te !reate event o an ob:e!t> %ut tis @image_s%eedDF.@ tis ill make your s%rite %lay al as ast i! el%s alot usually. usually. F ould make it stay on one rameK letting you use image_index to tell it i! rame to use.
3. sprite&i%$e. Tis !ommand !anges te s%rite o te ob:e!t. " you are making a %latormer> %latormer> you may ant your !ara!ter to use a dierent s%rite en :um%ing. en you %ress u%> %ut tis !ode in tere and %ut te name o te :um%ing s%rite.
. soli$ Tis ill !ange i te ob:e!t is solid or not. 8ou ill need to !ange it to @true@ or @alse@. solidDtrue ill make te ob:e!t solid...et!.
6. 0isible Tis ill !ange i te ob:e!t is see-able or not. 8ou 8ou ill need to !ange it to @true@ or @alse@. visibleDtrue ill make te ob:e!t see-able by te %layer...et!. %layer...et!.
. persiste%t Tis ill !ange i te ob:e!t is %ersistent or not. 8ou 8ou ill need to !ange it to @true@ or @alse@. %ersistentDtrue ill make te ob:e!t alays be in every room at te same lo!ation unless told oterise.
Q. spee$ 4etting te s%eed ill !ange o ast te ob:e!t is moving. Tis is +*T te same as !anging te image_s%eed. s%eed is used anytime an ob:e!t is moving in any dire!tion.
H. . n ob:e!t9s x value value is o ar over over it is. "t !an be !anged to @:um%@ @:um%@ te ob:e!t let let or rigt. Platormers Platormers use xR1 to move rigt andSor x-1 to move let. (!anging te @1@ o !ourse or s%eed.)
,F. 4 n ob:e!t9s y value value is o ar u% u% or don te s!reen it is. "t !an !an be !anged to @:um%@ @:um%@ te ob:e!t urter u% or don.
,,. hspee$ s%eed is kind o like !anging te x value only it9s better or a!!eleration. s%eedRD, ould !onstantly raise te oriEontal s%eed (going to te rigt) making it s%eed u% sloly sloly.. adding an i !ode beore it !an be used to limit te s%eed.
,2. 0spee$ vs%eed is kind o like !anging te y value only it9s better or a!!eleration. vs%eedRD, ould !onstantly raise te oriEontal s%eed (going donard) making it s%eed u% sloly. adding an i !ode beore it !an be used to limit te s%eed. vs%eed is usually a good ay to setu% gravity in a %latormer.
,1. 9ra0it4 nytime gravity gravity is greater tan tan F> you ill be be %ulled don. To make an ob:e!t sto% sto% on a solid %latorm> %latorm> you must set te gravity ba!k to F. 8ou 8ou !an use gravity or :um%ing by sloly in!reasing it but vs%eed is more idely used in tis !ase.
,3. i/a9e&a%9le "9m %retty sure you need a registered version to use tis but it is really el%ul. " you do someting like image_angle=point_direction(x,y,mouse_x,mouse_y) any ob:e!t ill a!e te mouse automati!ally itout you needing to make te s%rites ave a bun! o sub rames o it at dierent angles. Tis only needs , s%rite rame and uses te rigt side as te @ront@ o te s%rite. Te gra%i!s Auality dro%s a little i you use tis so it9s not alays te best ay to go. ust remember you ca% ca% ave ave an animated s%rite tat !an turn and everyting using tis? $anging tings "+-GM' ------------------
,. instance_create instance_create( (x,y,obj_whatever) Tis is used 5'08 oten oten to %ut an ob:e!t into te game tat asn9t already in te room en you started te game. x and y are te !oo rdinates o ere you ant te ob:e!t to be !reated at. F or x and F or y ould %ut te ob:e!t at te very to% let !orner o te room. ob:_atever sould be re%la!ed it te name o te ob:e!t you ant to !reate.
2. distance_to_object (obj_whatever) Tis ill tell you o ar @ob:@ is (in %ixels) rom te ob:e!t running tis !ode. Tis is mostly el%ul i used in a reAuirement su! as @i distan!e_to_ob:e!t(*/'$T) distan!e_to_ob:e!t(*/'$T) B ,FF@. "t el%s you !ange tings a!!ording to ere an ob:e!t is at te time.
1. distance_to_point (obj_whatever obj_whatever. .x,obj_whatever obj_whatever. .y) 4imilar to distan!e_to_ob:e!t. distan!e_to_ob:e!t. "nstead o using an ob:e!t> it uses any %oint in te room. $ange x and y to te %oint you ant it to measure to.
3. move_towards_point (x,y,speed) Tis ill move its ob:e!t to te x and y values you %ut in. re%la!e s%eed it te s%eed you ant it to move to te %oint it.
. keyboard_check keyboard_check( (vk_left vk_left) ) Tis !ode ill !e!k i an arro key is being eld don or not. 8ou !an re%la!e @let@ it any o te olloingI let> rigt> u%> don> a lt> anykey> anykey> ba!ks%a!e> !ontrol> nokey nokey... ... et!. 8ou !an also !ange it to keyboard_!e!k_%ressed() or keyboard_!e!k_released() to !e!k *+L *+L8 8 en tey button is %ressed don (on!e at a time) or en te key is released (on!e at a time).
6. instance_place instance_place( (x,y,obj_whatever) Tis el%ul !ode !e!ks i @ob:@ is at a !ertain %oint. Tis !an be used a lot in :ust about all ty%es o games.
. sleep sleep(ms) (ms) 4lee% is like a built in timer ere GM !om%letely %auses or te amount o millise!onds you %ut in te %la!e o @ms@ (i! stands or millise!onds). 0emember +*T#"+G +*T#"+G !an !ange during tis %ause time. " tink te only ting it doesn9t sto% is sounds.
Q. sound_play sound_play( (snd_whatever snd_whatever) ) Tis is te basi! !ode or %laying a sound ee!t or ba!kground musi! o some kind. 8ou 8ou !an run sound_loo%(snd) ater tis !ode to make te sound %lay over and over again till te room ends or until you %ut sound_sto%(snd). 0e%la!e snd it te name o te sound.
H. random random() () Making a variable random is someting lots o %eo%le ave Auestions on. random(1) ould give you +8 number beteen F and 1 in!luding de!imal numbers. " you ant it to %i!k a rounded number> you !an do tis... round(random(1)) tis ill %i!kI F> ,> 2> or 1. lso> you !an %ut a number ater it to tell it i! number is te loest tat sould be %i!ked. round(random(1)R2) ould give you 2>1>3> or . lso> you don9t ave to use round()> you !an also use !eil() to round u%ard or loor() to round donard. To To use
random> you most likely need to set it as a variable.
,F. instance_nearest (x,y,obj_whatever obj_whatever) ) Tis !ode inds te nearest o te ob:e!t you %ut into it. sing tis !ode> it ill take its on x and y and ind te nearest ob:e!t o @ob:_atever@. &inding te nearest enemy i! !ould be many dierent ob:e!ts is L*T more !om%li!ated...
--------------------------------------------------------------------------------------------------------------------------------------------------:O;R< - =hort arra4s e.pla%atio% --------------------------------------------------------------------------------------------------------------------------------------------------*k> "9m going to try to ex%lain te very basi!s o arrays. #o%eully you kno exa!tly at global variables are by no. Te arrays all start it F but " like to start it , :ust be!ause it looks a little more normal. 4o en !reating a ne one> te irst ould be arraynameF>FU ...et! arraynameVU Tis is te basi!s o an array. ust like any variable> you give it a name and set a number or it. "tem,U *k> no te number , is +*T it9s value> it9s merely te nu mber o te array. +o you;re ready to set tis array to someting> instead o a number number>> let;s give it a senten!e. "tem,UD@Tis item is used or ealing@ +o tat e ave set all 1 %arts> it9s ready to be used. "t !an be used '7$TL '7$TL8 8 like a variable !an. dra_text(x>y>"tem,U) +o tis %art o a !ode ill dra te text @Tis item is used or ealing@. nderstand Tis array setu% is almost exa!tly like a variable. Let;s do a e no. "tem,UD@Potion@ "tem2UD@'ter@ "tem1UD@$oins@ +o tis !ould be used to dra an inventory list o you9d like. /y setting ea! one as a dierent number> number> your setting tem all dierent. " tink you kno o to dra tem rom ere so no let;s try someting a little more !om%li!ated it tese. "tem,>FU "tem,>,U +o you;re %robably looking at tis tinking @t is e doing no@. n o@. Tis is ere arrays be!ome very el%ul (and maybe a little !om%li!ated). 8ou 8ou !an set a sort o 2nd layer to ea! number. Oinda like kee%ing multi%le %arts on one variable. Let;s say you ant to set u% a %otion or your game. "tem,>FUD@Potion@
"tem,>,UD@#eals "tem,>,UD@#eals F #P@ "tem,>2UD, "tem,>1UD,FF "tem2>FUD@%%le@ "tem2>,UD@#eals "tem2>,UD@#eals #P@ "tem2>2UD1 "tem2>1UD2FF *k> irst " ave made %arts o a %otion. #ere> "9m using F as te name> , as te ino> 2 as te Auantity you ave> and 1 as te selling %ri!e. +o your ree to dra tese ea! ere e ver tey are needed. +o i you ant to dra %arts or te a%%le> all you need to !ange is te irst number o ea!. " you still don9t understand> let me so an exam%le to make multi%le items. Make a s!ri%t and run it on!e in te beginning o your game to !reate tese items so you !an reer to tem in your game. "tem,>FUD@Potion@ "tem,>,UD@#eals "tem,>,UD@#eals F #P@ "tem,>2UD2 "tem,>1UD,FF "tem2>FUD@'ter@ "tem2>,UD@#eals "tem2>,UD@#eals 1F MP@ "tem2>2UD1 "tem2>1UD,2 "tem1>FUD@$oins@ "tem1>,UD@$urren!y "tem1>,UD@$urren!y o te island@ "tem1>2UD,2FFF "tem1>1UD,FF "tem3>FUD@Lie u%@ "tem3>,UD@0evives "tem3>,UD@0evives a allen team member@ "tem3>2UD, "tem3>1UD,FFF remember arrays aren9t only or draing> tey !an be used +8#'0' +8#'0' a normal variable !an be used. Last but not least> you !an make arrays global too. 8ea> 8ea> you guessed it... global."tem3>2UD, ...ould allo you to reer to it anyere and ould make it kee% its value rom room to room. Tis %art o te !ode being te Auantity o te item @lie u%@ bt. +o i you really ant to make your game im%ressive and kee% tings orderly> !e!k tis out... dra_text(x>y> global."tem+umb>FU) sing @+umb@ as your variable and %utting it as te irst number in te array> you !an !ange at text sos u% a!!ording to at you set @+umb@ to. 4etting it to , (using te above list as an exam%le) it ould so te text @Potion@ and !anging @+umb@ to 2 ould !ange it so it rites @'ter@ instead. +ote tat you !an %ut a variable in te %la!e o eiter o te 2 numbers in te array to allo !anges. Tis el%s a T*+ it making inventories> so%s> status s!reens ...et!.
--------------------------------------------------------------------------------------------------------------------------------------------------:>?E@ - =/art o$es ---------------------------------------------------------------------------------------------------------------------------------------------------
,. $ustom alarms not using alarms timerRD, if timerCF timerCF do tis do tis do tis timerDF3 timerDF3 sing tis is a lot more a!!urate tan using alarms. "t9s also better be!ause it9s in-!ode and reAuires less o a mess in your ob:e!ts. ust make sure you %ut it in te ste% event o an ob:e!t. 8ou 8ou !an also add anoter @i@ beore te timerRD, so it doesn9t :ust kee% going ater your done it it.
2. utomati! ad:usting ad:usting s!reen vie_border Dvie_vie vie_vieS2 S2 -obj_player .s%rite_idt vie_vborder Dvie_vie vie_vieS2 S2 -obj_player .s%rite_eigt Tis is %robably one o te best @smart !odes@ " kno kno.. "t resets your vie so tat @ob:_%layer@ is alays %ere!tly in te middle. " you ave a game ere te %layer9s s%rite !anges siEes or sa%es> all you gotta do is run tis !ode on!e ater it !anges s%rites and it is %ere!t every time? ust make sure you ave vies turned on.
1. Pere!t landing (%latormers) if vs%eed if vs%eed C C F == ?%la!e_ree ?%la!e_ree((x>yRvs%eed vs%eed)) move_!onta!t(2F) move_!onta!t (2F) vs%eed D vs%eed D F 8ou may noti!e in your %latormer tat en you land> your !ara!ter sto%s :ust above te ground> beore landing> ten dro%s te last e %ixels. "t !an get very annoying at times. se tis !ode on your !ara!ter en e !omes in !onta!t it te ground. "t tells GM te exa!t amount o donard s%eed it needs to land %ere!tly. %ere!tly. 8ou 8ou on9t noti!e any dieren!e oter tan landing ill be ni!e and smoot.
3. 'asy gravity (%latormers) instance_place( (x,y!",obj_#olid !",obj_#olid) ) if instance_place gravity=$.% gravity =$.% instance_place( (x,y!",obj_#olid !",obj_#olid) ) if instance_place gravity =$ gravity=$ vspeed&"$ &"$ if vspeed vspeed="$ vspeed ="$ Tis !ode el%s be!ause it !reates gravity *+L8 *+L8 i tere is s%a!e under you tat doesn9t ave a solid ob:e!t. "t also limits your verti!al s%eed i! el%s it alling troug loor bugs. Loering Loering te number el%s more but may make it look less realisti!. Try using dierent limit amounts. $ange ob:_4olid to
atever ob:e!t you use or your ground. "t !an be a %arent ob:e!t i you use more tan , or your ground ob:e!ts.
. 0otate S orbit ob:e!t spin!="$ x=obj_'layer obj_'layer. .x!lengthdir_x lengthdir_x( (obj_'layer obj_'layer. .sprite_width sprite_width",spin) ",spin) y=obj_'layer obj_'layer. .y!lengthdir_y lengthdir_y( (obj_'layer obj_'layer. .sprite_height sprite_height",spin) ",spin) Tis is a nity little !ode tat automati!ally makes te ob:e!t go in !ir!les around atever ob:e!t you %ut in te %la!e o @ob:_Player@. "t uses te ob:e!ts s%rite to ind out o large o a !ir!le it needs to make to go around it. lso> it ill automati!ally :um% into %la!e so it doesn9t matter ere you !reate te rotating ob:e!t in te room. "t ill :um% into %la!e and start rotating at te s%eed o te variable @s%in@ in tis !ase. ust make sure tis goes in your ste% event to kee% it !ir!ling.
6. 16F degree turning image_single =facing"$ image_single=facing"$ facing = point_direction point_direction( (x,y,mouse_x mouse_x, ,mouse_y mouse_y) ) Tis is a very !ommonly used !ode or !reating an ob:e!t tat !an turn all te ay around %ointing toard te mouse at all times. "t sets , sub s%rite (rame) or ea! dire!tion. orks best en te s%rite9s irst sub s%rite is a!ing rigt and te s%rite as 16 rames and s%inning !ounter !lo!kise. +o tis !ode does tat as ell as makes te ob:e!t a!e toard te mouse at all times. Te 2nd line !an be !anged or taken out de%ending on ere you ant te ob:e!t to a!e.
. 4etting a s%rite as your ont $reateI
font_add_sprite( (s_*ont#prites s_*ont#prites, ,ord ord(+ (+ +),false +),false,$) ,$) global.#pecial*ont= font_add_sprite
"9ve seen alot o %eo%le ask o to do tis. Tis lets you make a s%rite and use it en you use dra_text() instead o a normal ont. 8ou !an name @4%e!ial&ont@ as atever you ant and set dra_set_!olor() as atever !olor you ant te text to be. (ite makes it use te s%rites a!tual !olors) te @ord@ you see tells it you ave numbers> letters> and symbols in!luded in your ont. you !an %ut @ord(9F9) and ave rame F starting as te number F i you only ant to ave numbers. "t took me Auite a ile to ind te order game maker ants tese to be in so " in!luded one o te onts " %ut togeter so you !an kno te order too. Tere may still be some more symbols " aven;t ound but all te most !ommon (and some o te lesser !ommon) ones> "9ve already ound or you.
sprite font.gif
Q. Good #ealt bar //DRAW:
draw_set_color (c_red draw_set_color( c_red) ) draw_line( draw_line (x,y"$,x "$,x!linelength,y !linelength, y"$) if hpamount & hpmax hpamount = hpmax if hpamount - $ hpamount = $ //STEP:
linelength= hpamount hpmax sprite_width "9ve been asked many time on o to make a ealt bar and many times te %erson ants it to only be so long even i it9s alot o #P. (:ust goes don sloer...et!) ell tis !ode does it all. Tis one uses a line i! is smaller and !leaner looking rater tan a re!tangle. ust set %amount> %max> and make sure linelengtDF is in !reate. lso lso be sure to %ut te irst %art o te !ode in dra and te se!ond %art in ste%. 8ou !an mess it te numbers like te ,Fs or te eigt (raise number to raise bar). +o you !an set any ob:e!ts ealt and not orry about line lengts? I)
H. 0oom angling vie_angleFUD-dire!tion vie_angleFUDdire!tionRHF RHF image_angleD image_angle Ddire!tion Tis !ode is a little more advan!ed ten you may tink. "t angles te entire room a!!ording to te ob:e!t you %ut te !ode on (under ste%). sually you9d ant it on your main %layer i! te vie ollos. Tis Tis !an give your game a really ni!e look but you must ave a registered version o GM to do tis. --------------------------------------------------------------------------------------------------------------------------------------------------=>C - E%$i%9 co//e%ts --------------------------------------------------------------------------------------------------------------------------------------------------Lastly> "9d like to say tank you or reading tis and " o%e it el%s you get started using GML. /asi!ally try Lastly> to use te GM manual (el% ile) as mu! as %ossible till you learn alot more !odes. 'x%eriment using a mixture o dierent !odes. The o%l4 real a4 to lear% this is b4 usi%9 it alot6 ny Auestions or !omments !omments 'mail me or "M me it any Auestions or !omments you may ave... PMI 'mailI
e%eral&Leo ( tt%ISSorums.gamemaker tt%ISSorums.gamemaker.nlSindex.%%souser .nlSindex.%%souserD1,11 D1,11 ) Outlaecil9/ail6co/
I don't mind being emailed or PMed simple questions. /ut %lease try not to email me asking me to make %ra!ti!ally your entire game. " migt el% i you ask but you;re going to learn a lot better i you try it yoursel irst ten email me and ask at you did rong.