1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

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:
    570
    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:
    570

Share This Page