• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

center view instead of room?

P

piksil_demon

Guest
ok, ive tried, and failed numerous times to adapt the code from this video to center onto my view as apposed to my room (i asked a similar question earlier that had less than satisfacroy results so heres hoping)

so, what code do i use to make it get to the exact center of the view?

this is the code im trying to center
Code:
draw_set_font(fnt_large);
draw_set_color(c_white);
draw_text (view_xview[0], view_yview[0], "GAME OVER!")}

{draw_set_font(fnt_small);
draw_set_color(c_white);
draw_text (view_xview[0], view_yview[0], "press R to restart")
 
B

BeastyBoy

Guest
view_xview[0]+view_wview[0]/2
and
view_yview[0]+view_hview[0]/2
 
Sorry I didn't want to watch the entire video, did you want to draw text in the exact center of the view?
Use the draw_set_halign and draw_set_valign functions before drawing your text.
It would look something like this
Code:
draw_set_font(fnt_large);
draw_set_colour(c_white);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text (view_xview[0]+(view_wview[0]/2), view_yview[0]+(view_hview[0]/2), "GAME OVER!");

draw_set_font(fnt_small);
draw_text (view_xview[0]+(view_wview[0]/2), view_yview[0]+(view_hview[0]/2), "press R to restart");

draw_set_halign(fa_left);
draw_set_valign(fa_top);
 
P

piksil_demon

Guest
Sorry I didn't want to watch the entire video, did you want to draw text in the exact center of the view?
Use the draw_set_halign and draw_set_valign functions before drawing your text.
It would look something like this
Code:
draw_set_font(fnt_large);
draw_set_colour(c_white);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_text (view_xview[0]+(view_wview[0]/2), view_yview[0]+(view_hview[0]/2), "GAME OVER!");

draw_set_font(fnt_small);
draw_text (view_xview[0]+(view_wview[0]/2), view_yview[0]+(view_hview[0]/2), "press R to restart");

draw_set_halign(fa_left);
draw_set_valign(fa_top);
perfect ^_^
 
T

TimothyAllen

Guest
ok, ive tried, and failed numerous times to adapt the code from this video to center onto my view as apposed to my room (i asked a similar question earlier that had less than satisfacroy results so heres hoping)
The guy in the other topic gave you the same code that you just now said is perfect... except he told you to look up draw_set_halign rather then outright give it to you... and thats less than satisfactory?
 
P

piksil_demon

Guest
"look up" and "heres how to use it" are worlds apart

if you want to learn something you usually ask a teacher who will tell you, not a librarian who will point to a book
 
Last edited by a moderator:
Top