Friday, February 3, 2017

Newbie Tutorial GameMaker Studio 2 - The Sign Post

Hello there. Today i'm gonna write about how to make a sign post on GameMaker Studio 2.

This is not really a tutorial, is just step by step how i do it.
If you ask me where i get the font on the left gif picture, its called m3x6 font, and i download it from managore.itch.io 

You should have your player and movement set up before you can follow this step by step how to make a sign post.

From my point of view, a sign post is similar from Non Playable Character or NPC. The different is a sign stand still and an NPC wanders around. Well, NPC also need you to push the action button to interact and -maybe- he/she can have multiple answer/branch.

Ok. First, prepare the sprites for the sign. Set the origin to Top Center and then...
..... err, maybe i should skip into the code instead?

Create a font asset, and set it to your needs. For this example i name the asset fntDefault, use m3x6 font, set the font size into 11 and turn off anti-aliasing mode.
Create object Sign Post. Assign the sprite that we draw earlier into the object, and then add 3 events.

Create - the code that runs on the creation of the object
Step - the code that runs on every game frame
Draw - also runs on every game frame to draw something

On the Create events :

// initialize the object
trigger = 0;          // the on and off trigger
textToShow = "";      // the text to draw







On the Step events ;

if (place_meeting(x,y,objPlayer)){     // if the player is touching the sign
    trigger = 1;                       // turn the trigger on
    }                                    
else {                                 // if there is no player around
    trigger = 0;                       // turn back the trigger off
    }                                  // end of code

On the Draw events :

draw_self();                          // Draw the Sign Sprites

if (trigger == 1){                   // if the trigger is on
                                      // this section is to draw the black shadow font
    draw_set_alpha(0.7);              // set the font to 30% transparant
    draw_set_color(c_black);          // the font color, black
    draw_set_halign(fa_center);       // the horizontal align, center
    draw_set_valign(fa_bottom);       // the vertical align, bottom
    draw_set_font(fntDefault);        // font to use, fntDefault
    draw_text (x+1,y-5+1,textToShow); // draw textToShow
// the magic number -5- is how hight your font from the origin of the sprites and
// the x+1 and y+1 is one pixel away to the right and down from the original font
   
                                      // this section to draw the font
    draw_set_alpha(1);                // set the font to 100% visible
    draw_set_color(c_white);          // same as above
    draw_set_halign(fa_center);
    draw_set_valign(fa_bottom);
    draw_set_font(fntDefault);
    draw_text (x,y-5,textToShow);

    }


put the object into the room. And.. nothing happened. 😐




No text to show?

Ofc. remember the code?
textToShow = "";

We have to write something into it. But wait, how to make every object different?
Instead of filling the "textToShow" into the object code, we alter the value from the creation code. Go to the room and double click the object.

And thats it. I hope you like what i write. See ya next time.


2 comments:

  1. Tukitanotes.Blogspot.Com: Newbie Tutorial Gamemaker Studio 2 - The Sign Post >>>>> Download Now

    >>>>> Download Full

    Tukitanotes.Blogspot.Com: Newbie Tutorial Gamemaker Studio 2 - The Sign Post >>>>> Download LINK

    >>>>> Download Now

    Tukitanotes.Blogspot.Com: Newbie Tutorial Gamemaker Studio 2 - The Sign Post >>>>> Download Full

    >>>>> Download LINK Vx

    ReplyDelete