Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,184 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Crash with pixel_to_vec #263596
04/30/09 18:22
04/30/09 18:22
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
can anyone tell me why this function crashes? I'm sure its something to with the line "if (temp_vec[0]==255)" ..in old c-script you used to be able to assign the pixel to temp and read it like temp.red ..this doesnt work in lite C apparently.

Code:
var treemask_array[256][256];

BMAP* treemask = "treemask.tga"; 

function init_treemask()
{	
	var format;
	var pixel;		
	var county=0;
	var countx=256;
	
	var temp_vec[3];

	format=bmap_lock(treemask,0);

	while(countx>0)
	{			
		while(county<256)
		{		
			pixel = pixel_for_bmap(treemask,countx,county);
			pixel_to_vec(temp_vec,NULL,888,pixel);
			
			//only write to array if red is 255
			if (temp_vec[0]==255) 
			{
				treemask_array[countx][county]=255;				
			}
			
			else {treemask_array[countx][county]=0;}
			
			county+=1;
		}	
		
		if (county>=256)
		
		{
			county=0;
		}
		
		countx-=1;
	}

	bmap_unlock(treemask);	
}



Sphere Engine--the premier A6 graphics plugin.
Re: Crash with pixel_to_vec [Re: Matt_Aufderheide] #263598
04/30/09 18:31
04/30/09 18:31
Joined: Oct 2003
Posts: 4,131
M
Matt_Aufderheide Offline OP
Expert
Matt_Aufderheide  Offline OP
Expert
M

Joined: Oct 2003
Posts: 4,131
never mind, i was overrunning the array.. duh.

Re: Crash with pixel_to_vec [Re: Matt_Aufderheide] #263674
05/01/09 10:54
05/01/09 10:54
Joined: Feb 2006
Posts: 385
Oldenburg,Germany
Ralph Offline
Senior Member
Ralph  Offline
Senior Member

Joined: Feb 2006
Posts: 385
Oldenburg,Germany
From the manual:
pixel_to_vec(COLOR* color,var alpha,var format,var pixel);

You have to use a Vector or Color at the first parameter not a array.
This should solved your problem.
EDIT : shocked I dont see your secound post ... I need glasses! argh!

Last edited by Ralph; 05/01/09 10:56.

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