2 registered members (AndrewAMD, VoroneTZ),
740
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Handy DEBUG_VEC function
#455738
10/28/15 19:21
10/28/15 19:21
|
Malice
Unregistered
|
Malice
Unregistered
|
function DEBUG_VEC(VECTOR* vec, var p_pos, var p_offset)
{
DEBUG_VAR(vec.x,p_pos);
DEBUG_VAR(vec.y,p_pos+p_offset);
DEBUG_VAR(vec.z,p_pos+(p_offset*2));
}
Call and pass a vector, pass the start y-pixel of the first vec.member, pass the y-pixel offset between each vec.member. Example
action player_act()
{
.....
while(1)
{
my.x+= 5*time_step;
my.y-=5*time_step;
DEBUG_VEC(my.x,100,25);
wait(1);
}
}
Hope this is helpful, It sure is for me... Game-On, lol Mal
Last edited by Malice; 10/28/15 19:21.
|
|
|
Re: Handy DEBUG_VEC function
[Re: ]
#455740
10/28/15 19:32
10/28/15 19:32
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Probably the most used function in my isometric game:
void draw_num3d(var num, VECTOR* pos, var offset, VECTOR* color, var flags)
{
VECTOR temp;
temp.x = ((pos.x-camera.x)/camera.right*0.5+0.5)*screen_size.x;
temp.y = ((pos.z-camera.z)/camera.bottom*0.5+0.5)*screen_size.y;
temp.z = 0;
draw_text2(str_for_num(NULL,num),temp.x,temp.y+offset,color,flags);
}
...
draw_num3d(my.skill80,my.x,00,COLOR_RED,SHADOW);
draw_num3d(my.skill59,my.x,20,COLOR_WHITE,SHADOW);
draw_num3d(my.skill78,my.x,40,COLOR_GREEN,SHADOW);
Super handy but in its state obviously unusable for most other projects. Something like the following should work and help though (untested):
void draw_num3d(var num, VECTOR* pos, var offset, VECTOR* color)
{
VECTOR temp;
vec_set(temp,pos);
if(vec_to_screen(temp,camera))
{
draw_text(str_for_num(NULL,num),temp.x+1,temp.y+offset+1,COLOR_BLACK);
draw_text(str_for_num(NULL,num),temp.x,temp.y+offset,color);
}
}
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Handy DEBUG_VEC function
[Re: Superku]
#455746
10/28/15 20:21
10/28/15 20:21
|
Malice
Unregistered
|
Malice
Unregistered
|
^ Awesome !! Thanks, I'll add these to my lib functions and hack them for the VECTOR versions..
|
|
|
|