Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Markolainen's Scripts - Accepting script requests

Hi,

I have been using Game Maker for some time and I've under these years become quite good at GML. So I decided to share my knowledge in a scripts thread so all of you that need help can come here and request help and look through my scripts. I'll keep all the scripts on the first post and add new as I have time and you request them. I'll only post GML coding. If there is something that you're unsure of please look for it on the GM wiki site or the official documentation before asking. All the scripts are made by me and if there is something I can't help you with I'll try to point you to a script/tutorial that does what you requested.
As for credit you can give it if you want, it is really not necessary.

If you'd like some script don't hesitate either posting in this thread or PM me if you'd like to be anonymous.
If you do a too big request I'll propably point you to another script/tutorial. I'm here to help if you got stuck on something and not for making your game for you.
You can read these scripts and do changes on them to better suit your needs and use them as a base or idea giver for your custom engines without having to credit me.

Difference between two values - Last update 100206
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//Difference between two values

<span style="font-style: italic; color: green;">//made by Markolainen

<span style="font-style: italic; color: green;">//Put in any event when this calculation is needed

<span style="font-style: italic; color: green;">//argument0=value 1

<span style="font-style: italic; color: green;">//argument1=value 2

<span style="font-style: italic; color: green;">//Example difference=script_difference(10,-10);

 

<span style="font-style: italic; color: green;">//If both positive or negative

<span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](argument0)=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](argument1){

    <span style="font-weight: bold; color: #000000;">return([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url]([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](argument0)-[url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](argument1)));}

<span style="font-style: italic; color: green;">//If one is negative and the other positive

<span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](argument0)!=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](argument1){

    <span style="font-weight: bold; color: #000000;">return([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url]([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](argument0)+[url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](argument1)));}
Movement in eight direction with pixel perfect collission - Last update 100206
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//8 directional movement

<span style="font-style: italic; color: green;">//made by Markolainen

<span style="font-style: italic; color: green;">//Put in step event for walking normally

<span style="font-style: italic; color: green;">//argument0=speed

<span style="font-style: italic; color: green;">//Example script_move(3);

{

<span style="font-style: italic; color: green;">//Declare temporary variables

<span style="font-weight: bold; color: #000000;">var xsp, ysp;

 

<span style="font-style: italic; color: green;">//Check if buttons are pressed

xsp=([url=http://www.zonamakers.com/gmlreference/keyboard_check.html]<span style="color: navy;">keyboard_check[/url](<span style="color: #663300;">vk_right)-[url=http://www.zonamakers.com/gmlreference/keyboard_check.html]<span style="color: navy;">keyboard_check[/url](<span style="color: #663300;">vk_left))*argument0;

ysp=([url=http://www.zonamakers.com/gmlreference/keyboard_check.html]<span style="color: navy;">keyboard_check[/url](<span style="color: #663300;">vk_down)-[url=http://www.zonamakers.com/gmlreference/keyboard_check.html]<span style="color: navy;">keyboard_check[/url](<span style="color: #663300;">vk_up))*argument0;

<span style="font-style: italic; color: green;">//Execute movement

<span style="font-weight: bold; color: #000000;">repeat([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](xsp)){

<span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x+[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp),<span style="font-weight: bold; color: #000000;">y) then <span style="font-weight: bold; color: #000000;">x+=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp);}

<span style="font-weight: bold; color: #000000;">repeat([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](ysp)){

<span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,<span style="font-weight: bold; color: #000000;">y+[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](ysp)) then <span style="font-weight: bold; color: #000000;">y+=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](ysp);}

}
Gravity - Last update 100207
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//Gravity

<span style="font-style: italic; color: green;">//made by Markolainen

<span style="font-style: italic; color: green;">//Put in step event for normal gravity

<span style="font-style: italic; color: green;">//argument0=gravity;

<span style="font-style: italic; color: green;">//argument1=maximum fall speed

<span style="font-style: italic; color: green;">//Example: script_gravity(0.2,4);

 

<span style="font-weight: bold; color: #000000;">gravity=[url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,y<span style="color: #cc66cc;">+1)*argument0;

<span style="font-weight: bold; color: #000000;">vspeed=[url=http://www.zonamakers.com/gmlreference/min.html]<span style="color: navy;">min[/url](<span style="font-weight: bold; color: #000000;">vspeed,argument1);
Collision with floor (to be used with gravity NOT with Manual Gravity. On MG you only need to put the objects to solid!) - Last update 010207
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//Collision with floor

<span style="font-style: italic; color: green;">//To be used with gravity

<span style="font-style: italic; color: green;">//Remember to use parents if you have multiple floors such as slopes

<span style="font-style: italic; color: green;">//made by Markolainen

<span style="font-style: italic; color: green;">//Put in collision event with your floor/wall object

<span style="font-style: italic; color: green;">//Example script_collison_with_floor();

 

<span style="font-weight: bold; color: #000000;">if vspeed><span style="color: #cc66cc;">0{

    [url=http://www.zonamakers.com/gmlreference/move_contact_solid.html]<span style="color: navy;">move_contact_solid[/url](<span style="color: #cc66cc;">270,<span style="color: #cc66cc;">10);

    <span style="font-weight: bold; color: #000000;">y=[url=http://www.zonamakers.com/gmlreference/round.html]<span style="color: navy;">round[/url](<span style="font-weight: bold; color: #000000;">y);}

<span style="font-weight: bold; color: #000000;">if vspeed<<span style="color: #cc66cc;">0{

    [url=http://www.zonamakers.com/gmlreference/move_contact_solid.html]<span style="color: navy;">move_contact_solid[/url](<span style="color: #cc66cc;">90,<span style="color: #cc66cc;">10);}

<span style="font-weight: bold; color: #000000;">vspeed=<span style="color: #cc66cc;">0;

<span style="font-weight: bold; color: #000000;">gravity=<span style="color: #cc66cc;">0;
Variable jumping - Last update 100207
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//Variable jumping

<span style="font-style: italic; color: green;">//by Markolainen

<span style="font-style: italic; color: green;">//Put in step event for jumping normally

<span style="font-style: italic; color: green;">//argument0=jump speed (has to be negative)

<span style="font-style: italic; color: green;">//argument1=If variable jumping should be used. Options: true & false.

<span style="font-style: italic; color: green;">//Example script_jump(-4,true);

 

<span style="font-weight: bold; color: #000000;">if ![url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,y<span style="color: #cc66cc;">+1) and [url=http://www.zonamakers.com/gmlreference/keyboard_check_pressed.html]<span style="color: navy;">keyboard_check_pressed[/url](<span style="color: #663300;">vk_up){

    <span style="font-weight: bold; color: #000000;">vspeed=argument0;}

<span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,y<span style="color: #cc66cc;">+1) and [url=http://www.zonamakers.com/gmlreference/keyboard_check_released.html]<span style="color: navy;">keyboard_check_released[/url](<span style="color: #663300;">vk_up) and vspeed<<span style="color: #cc66cc;">0 and argument1=<span style="color: #cc66cc;">1{

    <span style="font-weight: bold; color: #000000;">vspeed/=<span style="color: #cc66cc;">2;}
Platform movement with slopes - Last update 100206
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//Platform movement with slopes

<span style="font-style: italic; color: green;">//made by Markolainen

<span style="font-style: italic; color: green;">//Put in step event for walking normally

<span style="font-style: italic; color: green;">//argument0=speed

<span style="font-style: italic; color: green;">//Example script_move(3);

{

<span style="font-style: italic; color: green;">//Declare temporary variables

<span style="font-weight: bold; color: #000000;">var xsp;

 

<span style="font-style: italic; color: green;">//Check if buttons are pressed

xsp=([url=http://www.zonamakers.com/gmlreference/keyboard_check_direct.html]<span style="color: navy;">keyboard_check_direct[/url](<span style="color: #663300;">vk_right)-[url=http://www.zonamakers.com/gmlreference/keyboard_check_direct.html]<span style="color: navy;">keyboard_check_direct[/url](<span style="color: #663300;">vk_left))*argument0;

<span style="font-style: italic; color: green;">//Execute movement

<span style="font-weight: bold; color: #000000;">repeat([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](xsp)){

    <span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x+[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp),y<span style="color: #cc66cc;">+1) and ![url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,y<span style="color: #cc66cc;">+1){

        <span style="font-weight: bold; color: #000000;">x+=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp);

        <span style="font-weight: bold; color: #000000;">y+=<span style="color: #cc66cc;">1;}

    <span style="font-weight: bold; color: #000000;">else <span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x+[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp),<span style="font-weight: bold; color: #000000;">y){

        <span style="font-weight: bold; color: #000000;">x+=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp);}

    <span style="font-weight: bold; color: #000000;">else <span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x+[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp),y<span style="color: #cc66cc;">-1) and ![url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,y<span style="color: #cc66cc;">+1){

        <span style="font-weight: bold; color: #000000;">x+=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](xsp);

        y-=<span style="color: #cc66cc;">1;}}

}
Pixel Perfect Gravity (Manual Gravity) - Last update 100403
Code:
<div class="gml" id="{CB}" style="font-family: monospace;"><ol><span style="font-style: italic; color: green;">//Pixel Perfect Gravity (Manual Gravity)

<span style="font-style: italic; color: green;">//made by Markolainen

<span style="font-style: italic; color: green;">//Put in step event for normal gravity on always

<span style="font-style: italic; color: green;">//argument0=gravity;

<span style="font-style: italic; color: green;">//argument1=maximum fall speed

<span style="font-style: italic; color: green;">//Example: script_gravity(0.2,4);

 

<span style="font-style: italic; color: green;">//You need to put ysp=0 in Create event of each object that uses this code!!!

 

<span style="font-weight: bold; color: #000000;">repeat([url=http://www.zonamakers.com/gmlreference/abs.html]<span style="color: navy;">abs[/url](ysp)){

    <span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,<span style="font-weight: bold; color: #000000;">y+[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](ysp)){

        <span style="font-weight: bold; color: #000000;">y+=[url=http://www.zonamakers.com/gmlreference/sign.html]<span style="color: navy;">sign[/url](ysp);}}

<span style="font-weight: bold; color: #000000;">if [url=http://www.zonamakers.com/gmlreference/place_free.html]<span style="color: navy;">place_free[/url](<span style="font-weight: bold; color: #000000;">x,y<span style="color: #cc66cc;">+1){

    ysp=[url=http://www.zonamakers.com/gmlreference/min.html]<span style="color: navy;">min[/url](argument0+ysp,argument1);}

<span style="font-weight: bold; color: #000000;">else{

    ysp=<span style="color: #cc66cc;">0;}
 

OS

Sponsor

Hey, these are great! I'm supposed to make a game for class, and your platform code is a great help! I may be able to make my platform game with this, since it actually seems to work (unlike the countless tutorials I've looked at that require some complicated system to operate efficiently).

Nice work.

~OS
 
OS":3vyqrvxr said:
Hey, these are great! I'm supposed to make a game for class, and your platform code is a great help! I may be able to make my platform game with this, since it actually seems to work (unlike the countless tutorials I've looked at that require some complicated system to operate efficiently).

Nice work.

~OS
Thanks for the reply! Glad to finally see one.:) Yes I try to make them flexible and new user friendly. You only have to know a little about scripts in order to make them work. And you can even see how my engine work and try to make your own out of it.

If you have any requests or find any errors please reply.
 
OS":ox0v42s1 said:
It all worked pretty well, but it helped me to learn GML quickly, so I am now using my own code. I appreciate it.
Ok. Good that you try to learn from the code. It's a very good method of learning, and it's always fun to use your own code instead of other peoples codes.:)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top