• 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!

3D [Solved] Angled HUD

T

trentallain

Guest
How do I angle my HUD sprite like these bars at the top? (I'm pretty sure they would use 3D for the right perspective of them)screen-2.jpg
Everything else will be 2D. And would I use something like d3d_set_projection? (I don't know how to use that though, since I've only done 2D games).
 

Jakylgamer

Member
for the text you can use
draw_text_transformed(); then just set an angle
for the sprites i guess you could do something like
Code:
for(var i=0; i<hp; i++) {
    draw_sprite_ext(spr_hp,0,posx+(i*sprite_width),posy-i,xscale-(i*.01),yscale-(i*.01),0,c_white,1);
}
the (i*.01) on xscale and y scale is just for a taper
 
T

trentallain

Guest
for the text you can use
draw_text_transformed(); then just set an angle
for the sprites i guess you could do something like
Code:
for(var i=0; i<hp; i++) {
    draw_sprite_ext(spr_hp,0,posx+(i*sprite_width),posy-i,xscale-(i*.01),yscale-(i*.01),0,c_white,1);
}
the (i*.01) on xscale and y scale is just for a taper
Thanks, but do u think just changing the angle or actually using 3D would be better?
 

Jakylgamer

Member
3d for a hud in a 2d game just seems like overkill to me.

EDIT: this might actually be a better way to go about drawing the sprite
Code:
///just some random values 
var angle = 5;
var space = 20;
var posx = 10;
var posy = 32;
var xscale = 1;
var yscale = 1;
var alpha = 1

draw_sprite_ext(spr_hp_dot,0,posx+lengthdir_x(i*space,angle),posy+lengthdir_y(i*space,angle),xscale,yscale,0,c_white,alpha);
 
Last edited:
I've got an idea...

you can skew everything you draw by modifying the world matrix in this way. I'll show the code i used, and then a screenshot of the results.

click spoiler for code:
Code:
//create event:
mat = matrix_build(0,0,0,0,0,0,1,1,1);

//gui draw event:
var _tilt = 0.5;
var _gui_w = display_get_gui_width();

//drawing stuff from the left side with a negative slope
mat[1] = _tilt;
mat[13] = 0;
matrix_set(matrix_world, mat);
draw_sprite_ext(spr_thing,0,0,0,10,1,0,c_green,1);
draw_set_halign(fa_left);
draw_text( 0,40,"SADFSJKDHKJSHDFKJHSDKFJHSKDSDF");

//drawing stuff rom the right side with a positive slope
mat[1] = -_tilt;
mat[13] = _gui_w * _tilt;
matrix_set(matrix_world, mat);
draw_sprite_ext(spr_thing,0,_gui_w-32*10,0,10,1,0,c_green,1);  //width of sprite is 32
draw_set_halign(fa_right);
draw_text( room_width,40,"SADFSJKDHKJSHDFKJHSDKFJHSKDSDF");

d3d_transform_set_identity();


click spoiler to see screenshot:
upload_2017-6-4_16-55-24.png
 
Last edited:

Hyomoto

Member
The HUD in your example is probably designed like that. If there's one thing I've learned, it's that a lot of effects are not. Why waste processing power trying to stagger and bend when you could just draw it that way to begin with. Just some food for thought.
 
T

trentallain

Guest
Ok I went with @Jakylgamer 's idea of just drawing it on an angle (and angle of 5° worked perfectly). I also drew the HUD to the GUI and scaled it up by 6 so that it would be on an angle and still maintain a pixel art effect and it looks pretty good. Thanks everyone!
 
Top