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

[ANSWERED]: Textboxes that follow Player View

S

sjschindler

Guest
Hello yet again everyone. I am back with another forum post. This time, however, I have a question, not a problem.
My question is this: How would I make it so that when I draw a textbox to the screen(rectangle), regardless of the players position in the room, it would always be directly below the player?
Right now I have my room view set up to always follow the player. Say I want a quarter of the screen to have a grey rectangle drawn on it. I want that grey rectangle to be in the exact same position every time I talk to an NPC, similar to that to typical RPGs.
For example, if my room view is 300 x 200, and I have my player at position x 1472 and y at 352, I want it so that even if I was at x 500 and y 200, the textbox would always draw the same in the same position.
Any help would once again be extremely appreciated, you all have shown incredible support and knowledge on this and I already thank you all for reading and attempting to help!!
 
S

siggi

Guest
room view is 300 by 200 - draw rect at x1: obj_pc.x-150, y1: obj_pc.y+80, x2: obj_pc.x+150, y2: obj_pc.y+100; make sure you make your rooms bigger than needed though, otherwise the text box and other hud elements will sneak off the edge of the screen when you adventure to the edge of the room :)

also if that method makes the hud jittery, maybe try rounding your player's x and y coords at the end of each frame, that might help; i think the official older method is to put the hud objects way outta the way in your room and assign them individual views, then you could like change the "visible" var when yuckin it up with npcs :)
 
Top