Monday, January 30, 2017

GML Movement Engine - Bug Fixing

It is very annoying when your character stuck in a wall, or just zapping into another location out of control. There's always a bug to fix in a game. And doing bug-fixing is not fun at all.

I learn the function of draw_text() and string() this week out of bug-fixing. Hey! whats the use of these function anyway? from the GameMaker Help File :

draw_text(x,y,string);

With this function you can draw any string at any position within the room (for drawing real numbers you should use the string function to convert them into text). To combine strings you can use + (see example below), you can also use # to add a line break to the string (should you need to display the # symbol, then you should precede it with a backslash like this "this will draw a \#") and you can also draw quotations by using inverted commas (for example 'I said "Hello"...'). The colour of the text and the alpha are governed by the current base alpha and colour values as set by draw_set_alpha and draw_set_colour

NOTE: The actual position of the text will be influenced by the alignment values set by draw_set_halign and draw_set_valign.

string(val);

With this function you can turn any real number into a string. If the real number is an integer, it will be saved with no decimal places, otherwise, it will be saved with two decimal places.

Well for me, i just draw the result of the custom condition i make on to the screen. For example is, is there a wall in front of my character? if yes make my character stop. 

so i make a custom condition : 
isWall = position_meeting(x+(7*image_xscale), y, objSolid);

...but how do i know that the condition is true or false? is the addition of 7 pixel correct?
and yes thats it. i use the draw_text() and string() to know the result. I just write 
draw_text(objPlayer.x,objPlayer.y,string(isWall));

And suddenly the unclear become more clear . 😄


No comments:

Post a Comment