1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 Display text?

Discussion in 'Programming' started by Rhqusa, Oct 15, 2017.

  1. Rhqusa

    Rhqusa Guest

    I have a new problem. The text for a certain variable won't show up on my screen. I have the text set to show up at my character sprite's origin, but it does not appear. The room background is blue by the way.

    step event:
    Code:
    var hinput_ = keyboard_check(vk_right) - keyboard_check(vk_left);
    var vinput_ = keyboard_check(vk_down) - keyboard_check(vk_up);
    if hinput_ != 0 {
        hspeed_ += hinput_ * Accel_
        hspeed_ = clamp(hspeed_,-maxhspeed_,maxhspeed_)
    } else {
        hspeed_ = lerp(hspeed_,0,.3)
    
    }
    if vinput_ != 0 {
        vspeed_ += vinput_ * Accel_
        vspeed_ = clamp(vspeed_,-maxvspeed_,maxvspeed_)
    } else {
        vspeed_ = lerp(vspeed_,0,.3)
    
    }
    if keyboard_check(vk_space) {
        if supersecretvariable_!= 0 and othersecretvariable = 1{
            instance_create_depth(x_,y_,1,o_secretobject);
            alarm_set(0,5);
            reloaded = 0
            supersecretvariable_ -= 1;
        }   
    }
    draw_text_colour(512,608, "secret:" + string(supersecretvariable),c_black,c_black,c_black,c_black,1);
    x_=x;
    y_=y
    x += hspeed_;
    y += vspeed_;
    
    create event:
    Code:
    /// @description Insert description here
    keyboard_set_map(ord("W"),vk_up);
    keyboard_set_map(ord("A"),vk_left);
    keyboard_set_map(ord("S"),vk_down);
    keyboard_set_map(ord("D"),vk_right);
    hspeed_=0;
    vspeed_=0;
    maxhspeed_=7;
    maxvspeed_=7;
    Accel_=1;
    x_=x;
    y_=y
    Velocity_=6;
    supersecretvariable_ = 300;
    othersecretvariable = 1;
    
    alarm event (alarm 0):
    Code:
    /// @description Insert description here
    // You can write your code in this editor
    othersecretvariable = 1
    
     
  2. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    558
    First I'd change the draw_text to this if you want to draw at the players origin (assuming your player is called oPlayer):
    draw_text_colour(oPlayer.x ,oPlayer.y, "secret:" + string(supersecretvariable),c_black,c_black,c_black,c_black,1);

    And then move that line from step event to draw event right after
    draw_self();
     
  3. Rhqusa

    Rhqusa Guest

    The problem is that I'm not using a draw event for my player, or at all. Is that code supposed to go in the draw event anyway?
     
  4. The Reverend

    The Reverend Member

    Joined:
    Sep 8, 2016
    Posts:
    558

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice