Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Akow), 1,403 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem with draw_line. #291603
09/26/09 17:17
09/26/09 17:17
Joined: Sep 2009
Posts: 12
Z
zero_karma Offline OP
Newbie
zero_karma  Offline OP
Newbie
Z

Joined: Sep 2009
Posts: 12
Here is the code to draw a box on an on-screen entity:

Code:
function draw_target(box_size)
{
	VECTOR pos[3];
	vec_set(pos.x,my.x);
	vec_to_screen(pos.x,camera);
	
	// draw target
	draw_line(vector(pos.x - box_size,pos.y - box_size,0),NULL,100);
	draw_line(vector(pos.x + box_size,pos.y - box_size,0),vector(255,255,255),100);
	draw_line(vector(pos.x + box_size,pos.y + box_size,0),vector(255,255,255),100);
	draw_line(vector(pos.x - box_size,pos.y + box_size,0),vector(255,255,255),100);
	draw_line(vector(pos.x - box_size,pos.y - box_size,0),vector(255,255,255),100);
}



The odd thing is that this code works, sort of. The box appears on the screen and rotates around all crazy while shifting positions. This problem goes away when I run this other function before I run the draw_target function

Code:
function register_nav()
{
	VECTOR temp[3];
	
	// create and store nav target panel
	you = ent_create("temp_invs.mdl",my.x,nav_marker);
	you.parent = me;
	
	pan_temp = ent_createlayer("nav_point_target.tga",0,4);
	text_temp = txt_create(1,4);
	text_temp.font = bit_dust_2_bmp;
	
	my.handle_nav_panel = handle(pan_temp);
	my.handle_nav_text = handle(text_temp);
	
	while(my.armor > 0)
	{
		
		// restore nav panel handle
		pan_temp = ptr_for_handle(my.handle_nav_panel);
		text_temp = ptr_for_handle(my.handle_nav_text);
		str_cpy((text_temp.pstring)[0],my.string1);
		
		// set placement of nav text
		vec_set(temp.x,my.x);
		if(vec_to_screen(temp.x,camera) != NULL)
		{
			text_temp.pos_x = temp.x + 24;
			text_temp.pos_y = temp.y - 16;
			set(text_temp,SHOW);
		}
		else
		{
			reset(text_temp,SHOW);
		}
		wait(1);
	}
	
	
	// delete associated nav panel
	text_temp = ptr_for_handle(my.handle_nav_text);
	txt_remove(text_temp);
}



This code creates a text on the screen that follows the entity like a label. This code also used to contain a panel that would follow the entity as a target, but I am moving away from using it, that's why the position updating part is no longer there... The problem also re-occurs when I remove the creation of the the pan_temp entity as well as the restoration of the pan_temp using ptr_for_handle.

Draw_line works fine as long as at least one entity in the level has called the last function. I don't get it, these two functions have nothing to do with eachother.

Re: Problem with draw_line. [Re: zero_karma] #291877
09/28/09 17:50
09/28/09 17:50
Joined: Sep 2009
Posts: 12
Z
zero_karma Offline OP
Newbie
zero_karma  Offline OP
Newbie
Z

Joined: Sep 2009
Posts: 12
Solved. Thanks. Apparently the pointer got messed up somewhere. It had to do with the first ent_create. The box was being drawn around my 3d mouse cursor, wierd it rotated with the mouse cursor lol.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1