My text isn't showing

Discussion in 'Programming' started by SpaceKill, Oct 11, 2019.

  1. SpaceKill

    SpaceKill Member

    Joined:
    Apr 3, 2019
    Posts:
    18
    So I'm trying to do a game-over screen but my buttons aren't visible but they're working
    Here's the code
    Creation code:
    menu_x = x;
    menu_y = y;
    button_h = 32;
    button[0] = "Yes"
    button[1] = "Do not"
    buttons = array_length_1d(button);
    menu_index = 0
    last_selected = 0;
    Step event:
    menu_move = keyboard_check_pressed(vk_left) - keyboard_check_pressed(vk_right);

    menu_index += menu_move;

    if (menu_index < 0) menu_index = buttons - 1;
    if (menu_index > buttons -1) menu_index = 0;
    if (menu_index != last_selected) audio_play_sound(Menu_Scroll,1,false);
    last_selected = menu_index;

    Draw event:
    var i = 0;
    draw_set_font(GameOver)
    draw_set_halign(fa_middle)
    draw_set_color(c_white)

    repeat(buttons) {
    draw_set_color(c_white);
    if (menu_index== i) draw_set_color (c_red);
    draw_text (menu_x, menu_y + button_h * i, button);
    i++;
    }

    Key press:
    switch (menu_index) {
    case 0:
    room_goto(room3)
    break;
    case 1:
    room_goto(room1)
    break;
    }
     
    Last edited: Oct 11, 2019
  2. Azenris

    Azenris Member

    Joined:
    Oct 30, 2016
    Posts:
    63
    should the line
    Code:
    draw_text (menu_x, menu_y + button_h * i, button);
    
    not be accessing an array for the final parameter
    Code:
    button[0] = "Yes"
    button[1] = "Do not"
    
    eg.
    Code:
    draw_text (menu_x, menu_y + button_h * i, button[0]);
    
     
    ParodyKnaveBob likes this.
  3. SpaceKill

    SpaceKill Member

    Joined:
    Apr 3, 2019
    Posts:
    18
    I changed the code and the same thing happens
    Maybe my sistem isn't good at all?
    Do you have a tutorial suggestion I could watch to make a gameover screen ?
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,889
    He did. His actual code is
    Code:
    draw_text (menu_x, menu_y + button_h * i, button[i]);
    [ i ] is the italics BBCode.

    When you say "buttons" do you mean just the text, or do you have button sprites which are supposed to be under the text as well?

    Is the instance this code is in marked as visible?
     
    ParodyKnaveBob likes this.
  5. SpaceKill

    SpaceKill Member

    Joined:
    Apr 3, 2019
    Posts:
    18
    It's just text
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,889
    Is the object marked visible?
     
  7. SpaceKill

    SpaceKill Member

    Joined:
    Apr 3, 2019
    Posts:
    18
    Yes but I solved it anyway.
    I just rewrote all the code and it seems to be working now lmao.
    Thanks tho I really apreciated the help.
    But there's another problem.
    I get 2 Yes and 2 Do not buttons
    How do I solve this ?
     
  8. SpaceKill

    SpaceKill Member

    Joined:
    Apr 3, 2019
    Posts:
    18
    Ok I solved that too but how do I make the text go from left to right instead of up and down ?
    And how do I make a sprite appear when i have a button selected.
    Like the heart in Undertale when you have a piece of dialogue or a choice selected
     
  9. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,889
    It's going up and down because you set them to

    menu_x, menu_y + button_h * i

    You'd need to make it menu_x+button_w*i, menu_y

    If i undertsand the last part, you just place the icon at

    menu_x+button_w*menu_index-16, menu_y

    Replace the 16 with the width of your icon, roughly.
     

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